aboutsummaryrefslogtreecommitdiffstats
path: root/lsp/angularls.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2025-04-18 17:49:34 +0200
committerJustin M. Keyes <justinkz@gmail.com>2025-04-18 17:49:34 +0200
commite8963b5b0b48324b2da4e5cc0db8447dca3bd659 (patch)
treeb8da124635adc86c65ee1ef74c428978d9a6e5ec /lsp/angularls.lua
parentdocs: cleanup (diff)
downloadnvim-lspconfig-e8963b5b0b48324b2da4e5cc0db8447dca3bd659.tar
nvim-lspconfig-e8963b5b0b48324b2da4e5cc0db8447dca3bd659.tar.gz
nvim-lspconfig-e8963b5b0b48324b2da4e5cc0db8447dca3bd659.tar.bz2
nvim-lspconfig-e8963b5b0b48324b2da4e5cc0db8447dca3bd659.tar.lz
nvim-lspconfig-e8963b5b0b48324b2da4e5cc0db8447dca3bd659.tar.xz
nvim-lspconfig-e8963b5b0b48324b2da4e5cc0db8447dca3bd659.tar.zst
nvim-lspconfig-e8963b5b0b48324b2da4e5cc0db8447dca3bd659.zip
fix(angularls): cannot require() angularls.lua
The config makes too many assumptions and will just throw if those assumptions don't hold...
Diffstat (limited to 'lsp/angularls.lua')
-rw-r--r--lsp/angularls.lua6
1 files changed, 4 insertions, 2 deletions
diff --git a/lsp/angularls.lua b/lsp/angularls.lua
index dd02aa9a..dfb225aa 100644
--- a/lsp/angularls.lua
+++ b/lsp/angularls.lua
@@ -1,7 +1,8 @@
-- Angular requires a node_modules directory to probe for @angular/language-service and typescript
-- in order to use your projects configured versions.
local root_dir = vim.fn.getcwd()
-local project_root = vim.fs.dirname(vim.fs.find('node_modules', { path = root_dir, upward = true })[1])
+local node_modules_dir = vim.fs.find('node_modules', { path = root_dir, upward = true })[1]
+local project_root = node_modules_dir and vim.fs.dirname(node_modules_dir) or '?'
local function get_probe_dir()
return project_root and (project_root .. '/node_modules') or ''
@@ -40,7 +41,8 @@ local default_angular_core_version = get_angular_core_version()
-- - bin
-- - ngserver
-- - typescript
-local ngserver_path = vim.fs.dirname(vim.uv.fs_realpath(vim.fn.exepath('ngserver')))
+local ngserver_exe = vim.fn.exepath('ngserver')
+local ngserver_path = #(ngserver_exe or '') > 0 and vim.fs.dirname(vim.uv.fs_realpath(ngserver_exe)) or '?'
local extension_path = vim.fs.normalize(vim.fs.joinpath(ngserver_path, '../../../'))
-- angularls will get module by `require.resolve(PROBE_PATH, MODULE_NAME)` of nodejs