Prechádzať zdrojové kódy

nixpkgs/neovim: use venv if present for pyright

Thomas Dy 4 týždňov pred
rodič
commit
3b630daa8c

+ 12 - 0
.config/nixpkgs/neovim/config/lua/user/lsp.lua

@@ -62,6 +62,18 @@ vim.lsp.config('ruby_lsp', {
 })
 
 vim.lsp.config('pyright', {
+  before_init = function(_, config)
+    local git_root = vim.fn.FugitiveGitDir()
+    if git_root == '' then
+      return
+    end
+
+    -- if a venv is present, use it
+    local venv_path = vim.fn.finddir('.venv', '.;' .. git_root)
+    if venv_path ~= '' then
+      config.settings.python.pythonPath = vim.fs.joinpath(venv_path, 'bin', 'python')
+    end
+  end,
   handlers = {
     ['$/progress'] = function()
       -- this is quite noisy so just disable it