1
0
Fork 1

Configure Angular

This commit is contained in:
Snoweuph 2024-12-18 20:35:52 +01:00
parent 44c9268d67
commit bdadba7103
Signed by: snoweuph
GPG key ID: BEFC41DA223CEC55
3 changed files with 52 additions and 18 deletions

View file

@ -45,4 +45,9 @@ command -v stylelint &>/dev/null || volta install stylelint
command -v prettierd &>/dev/null || volta install @fsouza/prettierd
# Angular
command -v ng &>/dev/null || volta install @angular/cli
command -v ng &>/dev/null || volta install @angular/cli
command -v ngserver &>/dev/null || {
volta install @angular/language-server
volta install @angular/language-service
volta install typescript
}

View file

@ -182,4 +182,18 @@ K.CODE = {
},
}
--[[ Angular ]]
K.ANGULAR = {
TEMPLATE = {
mode = 'n',
shortcut = '<Leader>at',
description = 'Go to Angular Template',
},
COMPONENT = {
mode = 'n',
shortcut = '<Leader>ac',
description = 'Go to Angular Component',
},
}
return K

View file

@ -1,5 +1,6 @@
local T = require('toolchain')
local M = {}
local K = require('core.keymap')
function M.setup()
T.add_highlighter_autoinstalls('angular')
@ -18,33 +19,47 @@ function M.setup()
T.add_lsp_autoinstalls('angularls')
T.add_lsps(function(lspconfig, capabilities)
local config = { capabilities = capabilities }
lspconfig.html.setup(config)
lspconfig.emmet_ls.setup(config)
lspconfig.cssls.setup(config)
lspconfig.tailwindcss.setup(config)
lspconfig.ts_ls.setup(config)
lspconfig.eslint.setup(config)
local cmd = {
vim.env.VOLTA_HOME .. '/bin/ngserver',
'--stdio',
'--tsProbeLocations',
vim.env.VOLTA_HOME,
'--ngProbeLocations',
vim.env.VOLTA_HOME,
}
lspconfig.angularls.setup({
capabilities = capabilities,
cmd = cmd,
on_new_config = function(new_config, _new_root_dir)
new_config.cmd = cmd
end,
})
end)
T.add_plugins({
'joeveiga/ng.nvim',
config = function()
local opts = { noremap = true, silent = true }
local ng = require('ng')
vim.keymap.set(
'n',
'<leader>at',
ng.goto_template_for_component,
opts
K.ANGULAR.COMPONENT.mode,
K.ANGULAR.COMPONENT.shortcut,
ng.goto_component_with_template_file,
{
noremap = true,
silent = true,
desc = K.ANGULAR.COMPONENT.description,
}
)
vim.keymap.set(
'n',
'<leader>ac',
ng.goto_component_with_template_file,
opts
K.ANGULAR.TEMPLATE.mode,
K.ANGULAR.TEMPLATE.shortcut,
ng.goto_template_for_component,
{
noremap = true,
silent = true,
desc = K.ANGULAR.TEMPLATE.description,
}
)
vim.keymap.set('n', '<leader>aT', ng.get_template_tcb, opts)
end,
})
end