pappasam / jedi-language-server

A Python language server exclusively for Jedi. If Jedi supports it well, this language server should too.
MIT License
572 stars 44 forks source link

[Newbie] Cannot alter extra_paths from neovim lspconfig setup #229

Closed dpopchev closed 1 year ago

dpopchev commented 1 year ago

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:

pappasam commented 1 year ago

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": [],
}
pappasam commented 1 year ago

For documentation about this option, see: https://github.com/pappasam/coc-jedi#jediworkspaceextrapaths

dpopchev commented 1 year ago

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.

pappasam commented 1 year ago

https://github.com/neovim/nvim-lspconfig/blob/03a09b930b6efee91844ccffe96cb3fcc01da385/doc/lspconfig.txt#L158

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

dpopchev commented 1 year ago

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'}
            }
        }
}
pappasam commented 1 year ago

:+1: