How to set up Angular Language Service in Neovim
Asked Answered
M

3

7

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.)

Mid answered 4/3, 2022 at 10:7 Comment(0)
B
7

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.

Bowleg answered 13/4, 2022 at 12:9 Comment(0)
H
2

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.

Herod answered 21/3, 2022 at 19:49 Comment(0)
R
1

Replace

local project_library_path = "/usr/lib/node_modules/@angular/language-server/"
Rheinlander answered 15/2, 2023 at 5:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.