GithubHelp home page GithubHelp logo

venv-lsp.nvim's Introduction

venv-lsp.nvim

Automatically handles python virtualenvs with nvim-lspconfig
NOTE: Currently supports pyright lsp with poetry virtual environments

Usage

The easiest way to use this plugin is to call init method before any lspconfig setup

local venv_lsp = require 'venv-lsp'
venv_lsp.init()
-- source/setup lspconfig after
local lspconfig = require 'lspconfig'

How it works

There are plugins like poet-v, vim-virtualenv, vim-pipenv (which are inspiration for this plugin) that automatically detects and activates virtualenv for the current buffer.
The problem with those plugins is that if the LSP process has started before the right virtualenv is activated, python executable for that process is not the one from the activated virtual environment.
To fix that it requires manual process restart (:LspRestart)
This plugin uses on_new_config lspconfig hook to detect and activate virtualenv before the buffer is attached to the LSP client, providing the right Python path to the LSP.
The plugin works nicely for the monorepo projects that have multiple virtualenvs where different parts of the project belong to a different venv.
Jumping between buffers in such monorepo where LSP detects different root dir by patterns (workspace) is not going to produce issues like with the mentioned plugins above.

TODO

  • Support pipenv venvs
  • Support pyenv venvs
  • Support for jedi-language-server
  • Support for pylsp
  • Support for pylyzer

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.