Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Pass Python environment as parameter #1938

Closed
LanderMoerkerke opened this issue Mar 13, 2020 · 4 comments
Closed

Pass Python environment as parameter #1938

LanderMoerkerke opened this issue Mar 13, 2020 · 4 comments

Comments

@LanderMoerkerke
Copy link

I use mspyls with Neovim Language Client. The settings are statically defined in a settings.json and so is the InterpreterPath. I work with a lot of virtual environments so I want to define my Python binary location based on the project I'm working in.

settings.json

{
  "enabled": true,
  "initializationOptions": {
    "displayOptions": {
      "preferredFormat": "markdown",
      "trimDocumentationLines": true,
      "maxDocumentationLineLength": 0,
      "trimDocumentationText": true,
      "maxDocumentationTextLength": 0
    },
    "interpreter": {
      "properties": {
        "InterpreterPath": "/usr/bin/python",
        "UseDefaultDatabase": true,
        "Version": "3.8"
      }
    }
  }
}

Now my question arises, is it possible to define the InterpreterPath using terminal arguments?

For example:

dotnet /usr/local/lib/microsoft-python-language-server/Microsoft.Python.LanguageServer.dll \
    --python /usr/local/bin/python

Or is there a more simpler solution to my problem?

@jakebailey
Copy link
Member

There is no such support at the moment, though I've personally considered a change (not sure in which issue) where providing no path/version will call out to python in PATH and fill in the required info, so if you run nvim with an environment activated this would be handled for you.

@LanderMoerkerke
Copy link
Author

That would be a solution, I always open my vim buffers inside a virtualenv so the Python Path would be correct. I search in the issues to find the appropriate one.

@LanderMoerkerke
Copy link
Author

I forked the repository with automatic generation of the InterpreterPath and its version. Its located at: MoerkerkeLander/python-language-server: Microsoft Language Server for Python.

@jakebailey
Copy link
Member

Note that the method there isn't cross-platform; the correct method would be to look up PATH and then split on Path.PathSeparator to search for python.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants