Skip to content

Commit

Permalink
update python lspconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesChung committed Aug 22, 2024
1 parent 726ad13 commit 812626b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lua/plugins/lspconfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ return {
})
lspconfig.pyright.setup({
capabilities = capabilities,
on_new_config = function(config, root_dir)
local venv_path = root_dir .. '/.venv/bin/python'
if vim.fn.executable(venv_path) == 1 then
config.settings.python.pythonPath = venv_path
else
-- Fallback to system Python if no .venv is found
config.settings.python.pythonPath = vim.fn.exepath('python3') or vim.fn.exepath('python')
end
end,
})
lspconfig.rust_analyzer.setup({
capabilities = capabilities,
Expand Down

0 comments on commit 812626b

Please sign in to comment.