From f08f8844cbfce8da74bd4233cbee049e774ea0a3 Mon Sep 17 00:00:00 2001 From: Andrew Miller <88940946+Milldrew@users.noreply.github.com> Date: Fri, 25 Apr 2025 21:59:24 -0600 Subject: [PATCH] docs: Add docs for CoC plugin with neovim (#61005) When docs were moved from aio to adev, the directions for the CoC plugin were mistakenly dropped. This brings back the documentation from prior versions: https://v17.angular.io/guide/language-service#neovim PR Close #61005 --- adev/src/content/tools/language-service.md | 39 ++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/adev/src/content/tools/language-service.md b/adev/src/content/tools/language-service.md index 5b99eb5b298..6c022c21e6a 100644 --- a/adev/src/content/tools/language-service.md +++ b/adev/src/content/tools/language-service.md @@ -131,7 +131,42 @@ Either directly install the "Eclipse IDE for Web and JavaScript developers" pack ### Neovim -Angular language service can be used with Neovim by using the [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) plugin. +#### Conquer of Completion with Node.js + +The Angular Language Service uses the tsserver, which doesn't follow the LSP specifications exactly. Therefore if you are using neovim or vim with JavaScript or TypeScript or Angular you may find that [Conquer of Completion](https://github.com/neoclide/coc.nvim) (COC) has the fullest implementation of the Angular Language Service and the tsserver. This is because COC ports the VSCode implementation of the tsserver which accommodates the tsserver's implementation. + +1. [Setup coc.nvim](https://github.com/neoclide/coc.nvim) + +2. Configure the Angular Language Service + + Once installed run the `CocConfig` vim command line command to open the config file `coc-settings.json` and add the angular property. + + Make sure to substitute the correct paths to your global `node_modules` such that they go to directories which contain `tsserver` and the `ngserver` respectively. + + + { + "languageserver": { + "angular": { + "command": "ngserver", + "args": [ + "--stdio", + "--tsProbeLocations", + "/usr/local/lib/node_modules/typescript/lib/CHANGE/THIS/TO/YOUR/GLOBAL/NODE_MODULES", + "--ngProbeLocations", + "/usr/local/lib/node_modules/@angular/language-server/bin/CHANGE/THIS/TO/YOUR/GLOBAL/NODE_MODULES" + ], + "filetypes": ["ts", "typescript", "html"], + "trace.server.verbosity": "verbose" + } + } + } + + +HELPFUL: `/usr/local/lib/node_modules/typescript/lib` and `/usr/local/lib/node_modules/@angular/language-server/bin` above should point to the location of your global node modules, which may be different. + + +#### Built In Neovim LSP +Angular Language Service can be used with Neovim by using the [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) plugin. 1. [Install nvim-lspconfig](https://github.com/neovim/nvim-lspconfig?tab=readme-ov-file#install) @@ -155,4 +190,4 @@ The Angular Language Services then looks at `data.---` within its context, asks ## More information * For more in-depth information on the implementation, see the [Angular Language Service source](https://github.com/angular/angular/blob/main/packages/language-service/src) -* For more on the design considerations and intentions, see [design documentation here](https://github.com/angular/vscode-ng-language-service/wiki/Design) \ No newline at end of file +* For more on the design considerations and intentions, see [design documentation here](https://github.com/angular/vscode-ng-language-service/wiki/Design)