1

I have the angular language server installed but client doesn't attach when I'm in an angular project because it doesn't have an angular.json in the root (since it is an Nx workspace), which (according to the lsp-config documentation) is the root_pattern for this language server.

In VSCode the language server is fine, and this Stack Overflow question mentions the "legacy view engine" which seems to be related.

I can't find any useful information about how I can set up the lsp config for neovim that will get it to work without the angular.json file present.

I should add I'm using lsp-zero to handle the lsp configuration. I've found scattered bits of info indicating I could use project.json as the root_pattern but I'm stumped as to how I can actually do that in the config.

2
  • Welcome to Vim :-) I suppose we would need more information about your problem in order to reproduce it. In particular: What angular language server you have installed? How did you configure lsp in Neovim in regard to the angular language server? What is the structure of the project (a simplified structure is better than the real one)? Mar 2 at 13:48
  • @VivianDeSmedt I've added some more details. As far as I am aware there is only 1 angular language server, the angularls one. If project.json is a viable substitute for angular.json the question then becomes "how do I configure that?" Mar 2 at 13:57

1 Answer 1

1

I'll self answer this question, since I've just stumbled across a post elsewhere that gave me a hint.

I've got the lspconfig extension installed and this provides a utility function for the root_dir function. Since project.json looks like a suitable substitution in Nx workspaces, I've added this to my lsp config:

local util = require('lspconfig.util')

lsp.configure('angularls', {
    root_dir = util.root_pattern('angular.json', 'project.json')
})

Now when I open a file in my Nx angular workspace, the LSP client is attached and I get all the expected functions. I hope this helps fellow Angular Nx devs who use Neovim!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.