chore: add custom python path to pyright lsp

This commit is contained in:
Joao P Dubas 2024-03-17 21:38:04 +00:00
parent 33abae2b6e
commit 5269902be0

View File

@ -1,5 +1,5 @@
diff --git a/init.lua b/init.lua
index 506bbaf..b8d0561 100644
index 506bbaf..d546b62 100644
--- a/init.lua
+++ b/init.lua
@@ -91,7 +91,7 @@ vim.g.mapleader = ' '
@ -145,7 +145,7 @@ index 506bbaf..b8d0561 100644
}
-- Ensure the servers and tools above are installed
@@ -592,6 +677,21 @@ require('lazy').setup({
@@ -592,6 +677,33 @@ require('lazy').setup({
-- by the server configuration above. Useful when disabling
-- certain features of an LSP (for example, turning off formatting for tsserver)
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
@ -163,11 +163,23 @@ index 506bbaf..b8d0561 100644
+ server = vim.tbl_extend('keep', server, { cmd = { vim.fn.expand('$LOCAL_SRC_HOME') .. ex_server.path } })
+ ::continue::
+ end
+ elseif server_name == 'pyright' then
+ local python_paths = {
+ { name = 'poetry', cmd = { 'poetry', 'env', 'info', '--executable' }},
+ { name = 'system', cmd = { 'which', 'python' }},
+ }
+ for _, py_server in ipairs(python_paths) do
+ local cmd = vim.system(py_server.cmd, { text = true }):wait()
+ if (cmd.code > 0) then goto continue end
+ local python_path = string.gsub(cmd.stdout, '\n', '')
+ server = vim.tbl_extend('keep', server, { settings = { python = { pythonPath = python_path } } })
+ ::continue::
+ end
+ end
require('lspconfig')[server_name].setup(server)
end,
},
@@ -793,7 +893,31 @@ require('lazy').setup({
@@ -793,7 +905,31 @@ require('lazy').setup({
'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate',
opts = {
@ -200,7 +212,7 @@ index 506bbaf..b8d0561 100644
-- Autoinstall languages that are not installed
auto_install = true,
highlight = {
@@ -830,14 +954,14 @@ require('lazy').setup({
@@ -830,14 +966,14 @@ require('lazy').setup({
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
--
-- require 'kickstart.plugins.debug',