Giter Club home page Giter Club logo

pyenv-pyright's Introduction

pyenv-pyright

pyenv-pyright is a pyenv plugin to help setup Microsoft Pyright LSP Server to use virtualenv for local projects. This plugin helps to create or update venvPath and venv attributes in pyright config file pyrightconfig.json to pyenv virtualenvs.

This plugin may come in handy when working with pyright in neovim while using pyenv to manage your virtualenvs, since pyright doesn't uses pyenv set with pyenv local, a good way to overcome this problem is to explicitly set the desired venv in pyright config file pyrightconfig.json. So with this plugin you can do this with only one command:

pyenv pyright

Installation

This will install the latest development version of pyenv-pyright into the $(pyenv root)/plugins/pyenv-pyright directory.

Important note: If you installed pyenv into a non-standard directory, make sure that you clone this repo into the 'plugins' directory of wherever you installed into.

$ git clone https://github.com/alefpereira/pyenv-pyright.git $(pyenv root)/plugins/pyenv-pyright

Usage

  • From an activated pyenv virtualenv (set by pyenv local for example) run pyenv pyright to set pyright config file to this venv:
 (myvenv) pyenv pyright
  • Considering you have a pyenv virtualenv named myvenv, to set pyright config file to use this virtualenv, pass it as argument:
 pyenv pyright myvenv

Note: It works only for virtualenvs, it doesn't work for python instalations, for example pyenv pyright 3.10.0 won't work.

  • Command help:
pyenv pyright --help

Usage: pyenv pyright [virtualenv]
       pyenv pyright --help

       [virtualenv] should be a Python version known to pyenv.

Additional Notes

Update existing pyrightconfig.json file:

This script creates pyright LSP server config file pyrightconfig.json in the current directory, setting its venv attribute to selected virtualenv and venvPath to PYENV_ROOT/versions. If pyrightconfig.json file already exists, the script will update those attributes in the existing file instead.

Uses pyenv-virtualenv for venv management and command completions:

The pyenv-pyright plugin supports only virtualenvs known to pyenv, and pyenv-virtualenv is the way to go for venv management in pyenv. This plugin requires pyenv-virtualenv not only for the venvs but also for command completions.

If your workflow don't involve using venvs or you don't use pyenv-virtualenv, pyenv-pyright plugin may not have any use for you. But if you use venvs, and use pyenv to manage python versions, you probably use pyenv-virtualenv to manage venvs. If you installed pyenv using its installing tool pyenv-installer you already have pyenv-virtualenv (if you are not sure check by running pyenv virtualenvs), in case you don't have it installed yet, install it using the guide in pyenv-virtualenv installing section or with the pyenv-installer tool.

License

(The MIT License)

  • Copyright (c) 2015 Yamashita, Yuu

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

pyenv-pyright's People

Contributors

alefpereira avatar vihu avatar

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.