Code Monkey home page Code Monkey logo

Comments (5)

dbarnett avatar dbarnett commented on June 18, 2024

Oh, I wasn't getting how python package dependencies were relevant until I saw the specific example with coverage. But are you imagining cases where there's no system-wide install of python & coverage, or what?

from vim-maktaba.

Lilja avatar Lilja commented on June 18, 2024

But are you imagining cases where there's no system-wide install of python & coverage, or what?

Yes:
image

from vim-maktaba.

malcolmr avatar malcolmr commented on June 18, 2024

For running the right Python, this might be able to be worked around with a ~/bin/python (or whatever) in your PATH (or making the command overridable inside Maktaba, yes).

However, that still leaves the problem that maktaba#python#Eval only runs binaries as a fallback if Vim itself doesn't have Python support, and that seems like the more-likely case in general.

I'm not familiar with poetry, but would it make sense to run Vim itself in an environment where python -m coverage works? (i.e. for virtualenv, this'd be running something like source venv/bin/activate first).

In that case, everything should just work, whether we use Vim's native Python support, or fall back to running a python binary.

from vim-maktaba.

Lilja avatar Lilja commented on June 18, 2024

I think poetry run <command> is just syntax sugar for source ~/some/venv/in/a/folder/near/you/activate && <command>.

As a side note, I've recently began using coc.nvim and coc-pyright which is a LSP that has some nice features like knowing if the workspace/project uses some kind of dev tool like poetry/pipenv. I feel spoiled/privileged to not having to know about if vim's environment is properly sourced through a virtualenv.

As a workaround for now, I added petobens/poet-v to my vimrc and ran :PoetvActivate. That loaded the proper python environment into vim and I'm able to run :CoverageShow coverage.py inside the project and not get an error.
The workaround is not amazing, since it would require a manual :PoetvActivate every launch. I think it would be great if there were tooling to sort of automatically know what kind of environment a project is in and could set the provider from vim-coverage and be able run coverage-commands more smoothly!
Maybe this is out of scope for this plugin and should be done/thought of elsewhere?

from vim-maktaba.

dbarnett avatar dbarnett commented on June 18, 2024

Looks like another option would be to run poetry shell or source $(poetry env info --path)/bin/activate in the terminal before starting vim. Or you could set up an autocmd to run :PoetvActivate for you from the vim side.

As a maintainer I'm a little concerned about adding too much magic at this level, but specifically for the vim-coverage case I can see some justification for using the same coverage install you're using for the project, since people have run into versioning issues from accessing the same coverage data with different system/project versions of coverage.py. The snag is I think it'd be brittle to introduce a dependency on CWD for detecting which project settings to use. It could in theory detect based on which buffer you're showing coverage for, but that would require changing the library interface and doesn't sound appropriate for ALL existing python we invoke to try to use per-project versions of python & deps. Might be a reasonable vim-coverage feature request, but a pretty effort-intensive one to implement if so.

from vim-maktaba.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.