From 987bd2207f7f2f7f72f65b0e7e811ec04c03aa32 Mon Sep 17 00:00:00 2001 From: Radvil <36059968+radvil@users.noreply.github.com> Date: Wed, 5 Jun 2024 01:03:16 +0800 Subject: [PATCH] feat(extras): Add extra for angular lspconfig (#2806) * feat(extras): Add extra for angular lspconfig Since treesitter has better support for angular parser recently that works for the legacy and the latest version of it, I am happy to suggest this extra configuration that works for well for me without any issue. And since lack of references about how to config the angular lsp inside of neovim out there, this will work fine as a starting point. * feat(extras): Added `angularls` lsp configuration * feat(extras.lang): update `angularls` configuration --------- Co-authored-by: Radvil --- lua/lazyvim/plugins/extras/lang/angular.lua | 56 +++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/lang/angular.lua diff --git a/lua/lazyvim/plugins/extras/lang/angular.lua b/lua/lazyvim/plugins/extras/lang/angular.lua new file mode 100644 index 00000000..ce8a62e4 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/angular.lua @@ -0,0 +1,56 @@ +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 + 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) + if client.name == "angularls" then + --HACK: disable angular renaming capability due to duplicate rename popping up + client.server_capabilities.renameProvider = false + end + end) + 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, + }, +}