I'm using nvim-lsp
and pyright
. That latter provides a command PyrightSetPythonPath
to reset the path to the python interpreter. Since I can see no other way to perform the same task, I'd like to call this command whenever it becomes available.
NB LspAttach
does not work since PyrightSetPythonPath
seems to only become available a bit later after LSP attaching.
local callback = function ()
if vim.fn.exists ':PyrightSetPythonPath' == 2 then
local wherepython = (function ()
local f = io.popen('where python')
local where = f:read()
f:close()
return where
end)()
vim.cmd.PyrightSetPythonPath(wherepython)
end
end
local pyright_group = vim.api.nvim_create_augroup('pyright_set_path', {})
vim.api.nvim_create_autocmd('LspAttach', { callback = callback
, pattern = '*.py'
, group = pyright_group
})
-- does not work