Troubleshooting
Automatic setup failed
To figure out what happened use the function require('lsp-zero.check').run()
in command mode, pass a string with the name of the language server.
Here is an example with lua_ls
.
:lua require('lsp-zero.check').run('lua_ls')
Note:
The name of the language server must match with one in this list: server_configurations.
If the language server is not being configured you'll get a message like this.
LSP server: lua_ls
- was not installed with mason.nvim
- hasn't been configured with lspconfig
This means mason.nvim
doesn't have the server listed as "available" and that's why the automatic setup failed. Try re-install with the command :LspInstall
.
When everything is fine the report should be this.
LSP server: lua_ls
+ was installed with mason.nvim
+ was configured using lspconfig
+ "lua-language-server" is executable
If it says - "lua-language-server" was not found
it means Neovim could not find the executable in the "PATH".
You can inspect your PATH using this command.
:lua vim.tbl_map(print, vim.split(vim.env.PATH, ':'))
Note: if you use windows replace ':' with ';' in the second argument of
vim.split
.
The executable for your language server should be in one of those folders. Make sure it is present and the file itself is executable.
Root directory not found
You used the command :LspInfo
and it showed root directory: Not found.
This means nvim-lspconfig couldn't figure out what is the "root" folder of your project. In this case you should go to lspconfig
's github repo and browse the server_configurations file, look for the language server then search for root_dir
, it'll have something like this.
root_pattern("somefile.json", ".somefile" , ".git")
root_pattern
is a function inside lspconfig
, it tries to look for one of those files/folders in the current folder or any of the parent folders. Make sure you have at least one of the files/folders listed in the arguments of the function.
Now, sometimes the documentation in lspconfig just says see source file
. This means you need to go the source code to figure out what lspconfig looks for. You need to go to the server config folder, click in the file for the language server, look for the root_dir
property that is inside a "lua table" called default_config
.
Inspect server settings
Let say that you added some "settings" to a server... something like this.
lsp.configure('tsserver', {
settings = {
completions = {
completeFunctionCalls = true
}
}
})
Notice here that we have a property called settings
, and you want to know if lsp-zero did send your config to the active language server. Use the function require('lsp-zero.check').inspect_settings()
in command mode, pass a string with the name of the language server.
:lua require('lsp-zero.check').inspect_settings('tsserver')
If everything went well you should get every default config lspconfig added plus your own.
If this didn't showed your settings, make sure you don't call lspconfig
in another part of your neovim config. lspconfig can override everything lsp-zero does.
Inspect the entire server config
Use the function require('lsp-zero.check').inspect_server_config()
in command mode, pass a string with the name of the language server.
Here is an example.
:lua require('lsp-zero.check').inspect_server_config('tsserver')
Note:
The name of the language server must match with one in this list: server_configurations.