[Newbie] Cannot alter extra_paths from neovim lspconfig setup
Closed this issue · 6 comments
Using jedi-vim
I can do let g:jedi#added_sys_path = ['./lib', './src',]
and enjoy completion with lookup in local modules.
For the love of God I cannot make it work with neovim, 0.7.2, 0.8, 0.9 in particular.
I am using nvim-lsp-installer
to easy install the plugin, then nvim-lspconfig
in particular.
Thus extending should happen in the setup, here is what I try:
require('lspconfig')['jedi_language_server'].setup{
...
settings = { ... }
root_dir = require("lspconfig/utils").root_pattern(".git") -- ensure root directory is found for proejcts
...
}
Added references:
- extraPaths, neovim discussions
- jedi.workspace.extraPaths , coc-jedi
- python.autoComplete.extraPaths, python-language-server
- nvim-lsp
I'm guessing that, in your setup
function, you'll need to configure the initialization option under the init_options
parameter.
See: https://github.com/pappasam/jedi-language-server#configuration
"workspace": {
"extraPaths": [],
}
For documentation about this option, see: https://github.com/pappasam/coc-jedi#jediworkspaceextrapaths
I tired
...
settings = {
extraPaths = { "./lib" }
}
....
also per documentation analogue for pylsp.plugins.pycodestyle.ignore
for jed.workspace.extraPaths
...
settings = {
jedi = { --also jed_language_server
workspace = {
extraPaths = { './lib'}
}
}
...
with no succes, I have no clue how to check value passing for those.
NOTE: I am aware tha I can just append to PYTHONPATH, but I am seeking the flexibility per configuration per project.
This is apparently how they pass initOptions to esbonio, should be similar with this language server: https://github.com/neovim/nvim-lspconfig/blob/24edc8eb05eff926b5aca2225e6115f24c1a72d6/lua/lspconfig/server_configurations/esbonio.lua#L40
initOptions for jedi-language-server are shown, exactly as typed, here: https://github.com/pappasam/jedi-language-server#configuration
GREAT! 5 days of pain ended!
require('lspconfig')['jedi_language_server'].setup{
on_attach = on_attach,
flags = lsp_flags,
root_dir = require("lspconfig/util").root_pattern(".git"),
init_options = {
workspace = {
extraPaths = {'./lib'}
}
}
}
👍