mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-21 16:39:06 +02:00
## Description Angular templates didn't have a configured formatter. This PR configures prettier as a default formatter for angular templates. ## Checklist - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines.
71 lines
1.8 KiB
Lua
71 lines
1.8 KiB
Lua
return {
|
|
recommended = function()
|
|
return LazyVim.extras.wants({
|
|
root = {
|
|
"angular.json",
|
|
"nx.json", --support for nx workspace
|
|
},
|
|
})
|
|
end,
|
|
|
|
{
|
|
"nvim-treesitter",
|
|
opts = function(_, opts)
|
|
if type(opts.ensure_installed) == "table" then
|
|
vim.list_extend(opts.ensure_installed, { "angular", "scss" })
|
|
end
|
|
vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, {
|
|
pattern = { "*.component.html", "*.container.html" },
|
|
callback = function()
|
|
vim.treesitter.start(nil, "angular")
|
|
end,
|
|
})
|
|
end,
|
|
},
|
|
|
|
-- angularls depends on typescript
|
|
{ import = "lazyvim.plugins.extras.lang.typescript" },
|
|
|
|
-- LSP Servers
|
|
{
|
|
"neovim/nvim-lspconfig",
|
|
opts = {
|
|
servers = {
|
|
angularls = {},
|
|
},
|
|
setup = {
|
|
angularls = function()
|
|
LazyVim.lsp.on_attach(function(client)
|
|
--HACK: disable angular renaming capability due to duplicate rename popping up
|
|
client.server_capabilities.renameProvider = false
|
|
end, "angularls")
|
|
end,
|
|
},
|
|
},
|
|
},
|
|
|
|
-- Configure tsserver plugin
|
|
{
|
|
"neovim/nvim-lspconfig",
|
|
opts = function(_, opts)
|
|
LazyVim.extend(opts.servers.vtsls, "settings.vtsls.tsserver.globalPlugins", {
|
|
{
|
|
name = "@angular/language-server",
|
|
location = LazyVim.get_pkg_path("angular-language-server", "/node_modules/@angular/language-server"),
|
|
enableForWorkspaceTypeScriptVersions = false,
|
|
},
|
|
})
|
|
end,
|
|
},
|
|
|
|
-- formatting
|
|
{
|
|
"conform.nvim",
|
|
opts = function(_, opts)
|
|
if LazyVim.has_extra("formatting.prettier") then
|
|
opts.formatters_by_ft = opts.formatters_by_ft or {}
|
|
opts.formatters_by_ft.htmlangular = { "prettier" }
|
|
end
|
|
end,
|
|
},
|
|
}
|