neovim / nvim-lspconfig

Quickstart configs for Nvim LSP
Apache License 2.0
10.73k stars 2.08k forks source link

configuring custom language server broken #876

Closed dimbleby closed 3 years ago

dimbleby commented 3 years ago

How to reproduce the problem from neovim startup

I use the YANG language server and, since it is not natively supported here, I have added custom configuration for it following the pattern in the README, like this:

local configs = require'lspconfig/configs'
if not lspconfig.yang_language_server then
  configs.yang_language_server = {
    default_config = {
      cmd = {'yang-language-server'};
      filetypes = {'yang'};
      root_dir = lspconfig.util.root_pattern("yang.settings", ".git");
      settings = {};
    };
  }
end
lspconfig.yang_language_server.setup{}

With configuration like that, open neovim.

Actual behaviour

Error detected while processing /home/dch/.vim/vimrc:
line  203:
E5108: Error executing lua cannot open /home/dch/.vim/plugged/nvim-lspconfig/lua/lspconfig/yang_language_server.lua: No such file or directory

Expected behaviour

Everything should be fine!

git bisect reckons that this was introduced at 04f223f3d08388eac74a571516145154bf5af64c.

Minimal init.vim or init.lua and code sample

https://github.com/neovim/nvim-lspconfig#example-custom-config

Health check

Checkhealth result health#lspconfig#check ======================================================================== ## Checking language server protocol configuration - ERROR: gopls: The given command "gopls" is not executable. - INFO: terraformls: configuration checked. - INFO: jedi_language_server: configuration checked. - INFO: rust_analyzer: configuration checked. - ERROR: ccls: The given command "ccls" is not executable.

LSP log

N/A

mjlbach commented 3 years ago

it should be an easy fix if you want to PR it, just try wrapping dofile in a protected call

dimbleby commented 3 years ago

indeed that seems to do it, PR made

anand-bala commented 3 years ago

I am not sure if wrapping the dofile in a pcall helps here as it breaks texlab. Essentially, in the latest commit, when the config for texlab is loaded, the new table for texlab is not created in configs.__newindex.

I replaced the dofile here with the old call to require. This works fine.

I am in the process of debugging why this happens, but would love some help.

mjlbach commented 3 years ago

Texlab works fine for me, can you reproduce with our minimal config? I haven't seen your config, but are you doing something like this? https://github.com/neovim/nvim-lspconfig/pull/861#issuecomment-825862325

anand-bala commented 3 years ago

Hey @mjlbach, my texlab config is here and the call to setup is here.

Edit: Didn't see the minimal config suggestion.

So I tried the minimal config, and it seems to work. I guess there is some issue with my texlab configuration 😅 . Thanks!

mjlbach commented 3 years ago

I'd recommend matching the recommended method of adding custom language servers per our readme. Anything else is unsupported (if you want, you're free to override our internal use of dofile with require).

No problem! I'm guessing it's what nanotee commented on

anand-bala commented 3 years ago

Turns out the issue was this line. Not sure why, but removing that (unnecessary) line solves my issue.