aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig
diff options
context:
space:
mode:
authorIan Liu Rodrigues <ian.liu88@gmail.com>2023-03-23 02:49:52 -0300
committerGitHub <noreply@github.com>2023-03-23 13:49:52 +0800
commitb7a1a1ffd96eb89c937ee63e00a20096c73e0035 (patch)
tree86ff676417957d7824ad1348623d770c0744e3a5 /lua/lspconfig
parentdocs: update server_configurations.md (diff)
downloadnvim-lspconfig-b7a1a1ffd96eb89c937ee63e00a20096c73e0035.tar
nvim-lspconfig-b7a1a1ffd96eb89c937ee63e00a20096c73e0035.tar.gz
nvim-lspconfig-b7a1a1ffd96eb89c937ee63e00a20096c73e0035.tar.bz2
nvim-lspconfig-b7a1a1ffd96eb89c937ee63e00a20096c73e0035.tar.lz
nvim-lspconfig-b7a1a1ffd96eb89c937ee63e00a20096c73e0035.tar.xz
nvim-lspconfig-b7a1a1ffd96eb89c937ee63e00a20096c73e0035.tar.zst
nvim-lspconfig-b7a1a1ffd96eb89c937ee63e00a20096c73e0035.zip
feat: add PyrightSetPythonPath command to pyright config (#2519)
* feat: add PyrightSetPythonPath command to pyright config The new command accepts a single path for a python executable that will be used to reconfigure the pyright language server. This is useful to change which python will be used by pyright without having to activate the python environment beforehand. The act of finding which python executable to use isn't handled here. * docs: update server_configurations.md skip-checks: true --------- Co-authored-by: Ian Liu Rodrigues <il@moray.ai> Co-authored-by: github-actions <github-actions@github.com>
Diffstat (limited to 'lua/lspconfig')
-rw-r--r--lua/lspconfig/server_configurations/pyright.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/lua/lspconfig/server_configurations/pyright.lua b/lua/lspconfig/server_configurations/pyright.lua
index a198477f..1bd3dbb6 100644
--- a/lua/lspconfig/server_configurations/pyright.lua
+++ b/lua/lspconfig/server_configurations/pyright.lua
@@ -24,6 +24,17 @@ local function organize_imports()
vim.lsp.buf.execute_command(params)
end
+local function set_python_path(path)
+ local clients = vim.lsp.get_active_clients {
+ bufnr = vim.api.nvim_get_current_buf(),
+ name = 'pyright',
+ }
+ for _, client in ipairs(clients) do
+ client.config.settings = vim.tbl_deep_extend('force', client.config.settings, { python = { pythonPath = path } })
+ client.notify('workspace/didChangeConfiguration', { settings = nil })
+ end
+end
+
return {
default_config = {
cmd = cmd,
@@ -45,6 +56,12 @@ return {
organize_imports,
description = 'Organize Imports',
},
+ PyrightSetPythonPath = {
+ set_python_path,
+ description = 'Reconfigure pyright with the provided python path',
+ nargs = 1,
+ complete = 'file',
+ },
},
docs = {
description = [[