Angular language server extra functionality for Neovim LSP
ng.nvim
Angular language server client for Neovim LSP. This extension adds extra commands exposed by vscode-ng-language-server, such as:
- [x] Go to template for component under cursor
- [x] Go to component(s) for template
- [x] Display template typecheck block
Getting started
Required dependencies
This extension WILL NOT config an angular language server (not yet, at least). If you use nvim-lspconfig you can follow these steps.
Installation
Using packer.nvim
use { 'joeveiga/ng.nvim'}
Usage
local opts = { noremap = true, silent = true }
local ng = require("ng");
vim.keymap.set("n", "<leader>at", ng.gototemplatefor_component, opts)
vim.keymap.set("n", "<leader>ac", ng.gotocomponentwithtemplatefile, opts)
vim.keymap.set("n", "<leader>aT", ng.gettemplatetcb, opts)
By default, both gotocomponentwithtemplatefile and gototemplatefor_component will open the buffer in the same window where the command was executed, regardless of whether the target location is already open in a different window. If you want to jump to the existing window, you can pass the { reuse_window = true } option to the function:
-- ...
vim.keymap.set("n", "<leader>at", function()
ng.gototemplateforcomponent({ reusewindow = true })
end, opts)
Here is an example of the difference in behavior:
FAQ
How can I restart the angular language service?
VSCode provides a Angular: Restart Angular Language Server command to restart the service. Unfortunately ng.nvim does not manage the lifecycle of the server at the moment. However, you can use nvim-lspconfig to accomplish this with the :LspRestart command.

Can I access the angular server logs?
I don't plan to support VSCode's Angular: Open Language Server Log command at the moment (at least not the functionality to automatically enable logging). PRs are welcome though ;). If you want to do this via lspconfig, you can add it to your angularls config cmd like so:
local cmd = {
"ngserver",
"--stdio",
"--tsProbeLocations",
"<typescript_path>",
"--ngProbeLocations",
"<angularlanguageservice_path>",
-- THESE ARE THE RELEVANT OPTIONS
"--logFile",
"<pathtologs>/nglangsvc.log",
"--logVerbosity",
"verbose" -- terse|normal|verbose|requestTime
}
lspconfig.angularls.setup({ cmd = cmd, capabilities = capabilities, onnewconfig = function(newconfig, newroot_dir) new_config.cmd = cmd end })
-- ... -- you can then add a mapping to open the file vim.keymap.set("n", "<leader>al", '<cmd>view <pathtologs>/nglangsvc.log<cr>', opts)