'How to set up Angular Language Service in Neovim
My setup at the moment looks like this:
local cwd = vim.fn.getcwd()
local project_library_path = cwd .. "/node_modules"
local cmd = {
DATA_PATH .. "/lsp_servers/angularls/node_modules/@angular/language-server/bin/ngserver",
"--ngProbeLocations",
project_library_path,
"--tsProbeLocations",
project_library_path ,
"--stdio",
}
require'lspconfig'.angularls.setup{
cmd = cmd,
on_new_config = function(new_config, new_root_dir)
new_config.cmd = cmd
end
}
On :LspInfo, I can see that the cmd is executable, but somehow it doesn't attach.
I have difficulty to differentiate @angular/language-server from @angular/language-service...
I am not sure what the tsProbeLocations and ngProbeLocations do and if my path is correct.
Finally, I red from Angular Language Service website and there isn't a good guideline for neovim. (except for coc-angular, but I don't use coc.)
Solution 1:[1]
I used the default require'lspconfig'.angularls.setup{} for my lspconfig and also installed @angular/language-server as a dev dependency in the angular project and it worked.
With angular language server installed globally with npm and the default lspconfig, I also saw that the cmd is executable with no client attaching to the buffer.
Solution 2:[2]
I had a similar setup and the same problem. Make sure that version of the installed language-server matches the major-version of the angular-version used in your project. That solved the issue for me:
npm -g uninstall @angular/language-server
npm -g install @angular/language-server@[the latest matching angular-version]
With that, the standard lua require'lspconfig'.angularls.setup({}) should work without problems.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | whkelvin |
| Solution 2 | rgroli |
