https://github.com/chefe/ng.nvim
https://github.com/chefe/ng.nvim
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/chefe/ng.nvim
- Owner: chefe
- Created: 2024-07-07T08:48:52.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-10T18:26:25.000Z (about 1 year ago)
- Last Synced: 2025-05-07T06:57:01.060Z (about 1 year ago)
- Language: Lua
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ng.nvim
A plugin to bring additional functionality for [Angular][1] to neovim.
## Features
- Go to template for component under cursor
- Go to component(s) for template under cursor
- Display template type check block
- Check if a file is part of an angular project
- Setup [tree sitter grammer for angular][2]
- Support for refactorings
- Generate the command to start the angular language server
### Refactorings
- Switch component from external template to inline template
- Switch component from inline template to external template
## Installation
[Lazy][3]:
```lua
return {
{
'chefe/ng.nvim',
dependencies = { 'dlvandenberg/tree-sitter-angular' },
config = function()
require('ng').setup()
end,
},
}
```
## Usage
```lua
local opts = { noremap = true, silent = true }
vim.keymap.set('n', 'at', 'lua require("ng.lsp").goto_template_of_component(0)', opts)
vim.keymap.set('n', 'ac', 'lua require("ng.lsp").goto_components_of_template(0)', opts)
vim.keymap.set('v', 'ab', 'lua require("ng.lsp").show_template_tcb(0, "window")', opts)
vim.keymap.set('v', 'abt', 'lua require("ng.lsp").show_template_tcb(0, "tab")', opts)
vim.keymap.set('v', 'abv', 'lua require("ng.lsp").show_template_tcb(0, "vertical")', opts)
vim.keymap.set('v', 'abh', 'lua require("ng.lsp").show_template_tcb(0, "horizontal")', opts)
vim.keymap.set('n', 'arte', 'lua require("ng.refactor").switch_component_to_external_template(0)', opts)
vim.keymap.set('n', 'arti', 'lua require("ng.refactor").switch_component_to_inline_template(0)', opts)
require('ng.lsp').is_in_angular_project(0, function (result)
if result then
vim.print('Angular project detected')
else
vim.print('No angular project detected')
end
end)
require('lspconfig')['angularls'].setup({
cmd = require('ng.lsp').get_angular_server_cmd(vim.fn.getcwd()),
on_new_config = function(new_config, new_root_dir)
new_config.cmd = require('ng.lsp').get_angular_server_cmd(new_root_dir),
end,
})
```
## Credits
- [angular/vscode-ng-language-server][4]
- [joeveiga/ng.nvim][5]
[1]: https://angular.dev
[2]: https://github.com/dlvandenberg/tree-sitter-angular
[3]: https://lazy.folke.io
[4]: https://github.com/angular/vscode-ng-language-service
[5]: https://github.com/joeveiga/ng.nvim