diff options
| author | Tulio Brunoro <brunoro.tulio@gmail.com> | 2025-01-28 13:25:27 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-28 08:25:27 -0800 |
| commit | 9962e25a23f0e992116b99a9a6400947d5a7177b (patch) | |
| tree | 5ae54da6f053b40e2d62f9ab234257a4eb8e2ab5 /lua | |
| parent | revert: "refactor!: make available_servers function private" #3589 (diff) | |
| download | nvim-lspconfig-9962e25a23f0e992116b99a9a6400947d5a7177b.tar nvim-lspconfig-9962e25a23f0e992116b99a9a6400947d5a7177b.tar.gz nvim-lspconfig-9962e25a23f0e992116b99a9a6400947d5a7177b.tar.bz2 nvim-lspconfig-9962e25a23f0e992116b99a9a6400947d5a7177b.tar.lz nvim-lspconfig-9962e25a23f0e992116b99a9a6400947d5a7177b.tar.xz nvim-lspconfig-9962e25a23f0e992116b99a9a6400947d5a7177b.tar.zst nvim-lspconfig-9962e25a23f0e992116b99a9a6400947d5a7177b.zip | |
fix(angularls): pass --angularCoreVersion for backwards compatibility #3592
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/configs/angularls.lua | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lua/lspconfig/configs/angularls.lua b/lua/lspconfig/configs/angularls.lua index 91b076a1..45b756b4 100644 --- a/lua/lspconfig/configs/angularls.lua +++ b/lua/lspconfig/configs/angularls.lua @@ -9,7 +9,27 @@ local function get_probe_dir(root_dir) return project_root and (project_root .. '/node_modules') or '' end +local function get_angular_core_version(root_dir) + local project_root = vim.fs.dirname(vim.fs.find('node_modules', { path = root_dir, upward = true })[1]) + + local package_json = project_root .. '/package.json' + if not vim.loop.fs_stat(package_json) then + return '' + end + + local contents = io.open(package_json):read '*a' + local json = vim.json.decode(contents) + if not json.dependencies then + return '' + end + + local angular_core_version = json.dependencies['@angular/core'] + + return angular_core_version +end + local default_probe_dir = get_probe_dir(vim.fn.getcwd()) +local default_angular_core_version = get_angular_core_version(vim.fn.getcwd()) return { default_config = { @@ -20,6 +40,8 @@ return { default_probe_dir, '--ngProbeLocations', default_probe_dir, + '--angularCoreVersion', + default_angular_core_version, }, filetypes = { 'typescript', 'html', 'typescriptreact', 'typescript.tsx', 'htmlangular' }, -- Check for angular.json since that is the root of the project. @@ -29,6 +51,7 @@ return { }, on_new_config = function(new_config, new_root_dir) local new_probe_dir = get_probe_dir(new_root_dir) + local angular_core_version = get_angular_core_version(new_root_dir) -- We need to check our probe directories because they may have changed. new_config.cmd = { @@ -38,6 +61,8 @@ return { new_probe_dir, '--ngProbeLocations', new_probe_dir, + '--angularCoreVersion', + angular_core_version, } end, docs = { |
