aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/servers/angularls/init.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2021-07-04 19:37:29 +0200
committerGitHub <noreply@github.com>2021-07-04 19:37:29 +0200
commitafe108bda0fceb3ed4f56f8b708b4004c4557656 (patch)
tree673ff7214f2862be7f867866875b5ebda742126f /lua/nvim-lsp-installer/servers/angularls/init.lua
parentrust_analyzer: upgrade to 2021-06-28 (diff)
downloadmason-afe108bda0fceb3ed4f56f8b708b4004c4557656.tar
mason-afe108bda0fceb3ed4f56f8b708b4004c4557656.tar.gz
mason-afe108bda0fceb3ed4f56f8b708b4004c4557656.tar.bz2
mason-afe108bda0fceb3ed4f56f8b708b4004c4557656.tar.lz
mason-afe108bda0fceb3ed4f56f8b708b4004c4557656.tar.xz
mason-afe108bda0fceb3ed4f56f8b708b4004c4557656.tar.zst
mason-afe108bda0fceb3ed4f56f8b708b4004c4557656.zip
add angularls (#27)
Diffstat (limited to 'lua/nvim-lsp-installer/servers/angularls/init.lua')
-rw-r--r--lua/nvim-lsp-installer/servers/angularls/init.lua48
1 files changed, 48 insertions, 0 deletions
diff --git a/lua/nvim-lsp-installer/servers/angularls/init.lua b/lua/nvim-lsp-installer/servers/angularls/init.lua
new file mode 100644
index 00000000..bdc69452
--- /dev/null
+++ b/lua/nvim-lsp-installer/servers/angularls/init.lua
@@ -0,0 +1,48 @@
+local util = require("lspconfig/util")
+local server = require("nvim-lsp-installer.server")
+local path = require("nvim-lsp-installer.path")
+local npm = require("nvim-lsp-installer.installers.npm")
+
+-- Angular requires a node_modules directory to probe for @angular/language-service and typescript
+-- in order to use your projects configured versions.
+-- This defaults to the vim cwd, but will get overwritten by the resolved root of the file.
+local function get_probe_dir(root_dir)
+ local project_root = util.find_node_modules_ancestor(root_dir)
+
+ return project_root and (project_root .. "/node_modules") or ""
+end
+
+local default_probe_dir = get_probe_dir(vim.fn.getcwd())
+
+local root_dir = server.get_server_root_path("css")
+
+local executable_path = path.concat { root_dir, "node_modules", ".bin", "ngserver" }
+
+return server.Server:new {
+ name = "angularls",
+ root_dir = root_dir,
+ installer = npm.packages { "@angular/language-server" },
+ default_options = {
+ cmd = {
+ executable_path,
+ "--stdio",
+ "--tsProbeLocations",
+ default_probe_dir,
+ "--ngProbeLocations",
+ default_probe_dir,
+ },
+ on_new_config = function(new_config, new_root_dir)
+ local new_probe_dir = get_probe_dir(new_root_dir)
+
+ -- We need to check our probe directories because they may have changed.
+ new_config.cmd = {
+ executable_path,
+ "--stdio",
+ "--tsProbeLocations",
+ new_probe_dir,
+ "--ngProbeLocations",
+ new_probe_dir,
+ }
+ end,
+ },
+}