chore: add custom python path to pyright lsp
This commit is contained in:
parent
33abae2b6e
commit
5269902be0
@ -1,5 +1,5 @@
|
|||||||
diff --git a/init.lua b/init.lua
|
diff --git a/init.lua b/init.lua
|
||||||
index 506bbaf..b8d0561 100644
|
index 506bbaf..d546b62 100644
|
||||||
--- a/init.lua
|
--- a/init.lua
|
||||||
+++ b/init.lua
|
+++ b/init.lua
|
||||||
@@ -91,7 +91,7 @@ vim.g.mapleader = ' '
|
@@ -91,7 +91,7 @@ vim.g.mapleader = ' '
|
||||||
@ -145,7 +145,7 @@ index 506bbaf..b8d0561 100644
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- Ensure the servers and tools above are installed
|
-- 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
|
-- by the server configuration above. Useful when disabling
|
||||||
-- certain features of an LSP (for example, turning off formatting for tsserver)
|
-- certain features of an LSP (for example, turning off formatting for tsserver)
|
||||||
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
|
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 } })
|
+ server = vim.tbl_extend('keep', server, { cmd = { vim.fn.expand('$LOCAL_SRC_HOME') .. ex_server.path } })
|
||||||
+ ::continue::
|
+ ::continue::
|
||||||
+ end
|
+ 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
|
+ end
|
||||||
require('lspconfig')[server_name].setup(server)
|
require('lspconfig')[server_name].setup(server)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
@@ -793,7 +893,31 @@ require('lazy').setup({
|
@@ -793,7 +905,31 @@ require('lazy').setup({
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
build = ':TSUpdate',
|
build = ':TSUpdate',
|
||||||
opts = {
|
opts = {
|
||||||
@ -200,7 +212,7 @@ index 506bbaf..b8d0561 100644
|
|||||||
-- Autoinstall languages that are not installed
|
-- Autoinstall languages that are not installed
|
||||||
auto_install = true,
|
auto_install = true,
|
||||||
highlight = {
|
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).
|
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
|
||||||
--
|
--
|
||||||
-- require 'kickstart.plugins.debug',
|
-- require 'kickstart.plugins.debug',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user