astrocommunity icon indicating copy to clipboard operation
astrocommunity copied to clipboard

error of Angular LSP

Open wert2all opened this issue 4 months ago • 4 comments

Checklist

  • [x] I have searched through the AstroNvim documentation
  • [x] I have searched through the existing issues of this project
  • [x] I have searched the existing issues of plugins related to this issue
  • [x] I can replicate the bug with the minimal repro.lua provided below

Neovim version (nvim -v)

0.11.3

Operating system/version

arch btw

Terminal/GUI

kitty

Describe the bug

Angular LSP is broken after some updates. It throws an error after open any component:

  Warn  03:36:52 notify.warn Client angularls quit with exit code 1 and signal 0. Check log for errors: ~/.local/state/nvim/lsp.log

and ~/.local/state/nvim/lsp.log

ackages/angular-language-server/node_modules/@angular/language-server/index.js:219086\n      throw new Error(`Failed to resolve '${packageName}' with minimum version '${minVersion}' from ` + JSON.stringify(probeLocations, null, 2));\n      ^\n\nError: Failed to resolve '@angular/language-service' with minimum version '15.0' from ...........

Steps to Reproduce

  1. install angular pack
  2. open ant angular component

-- fail

Expected behavior

I investigate this issue and found a same behavior on r/neovim:

  • https://www.reddit.com/r/neovim/comments/18ywqvp/angular_lsp_configuration_errors/

For fixing an issue should set up correct cmd option of angular LSP.

local install_path = vim.fn.stdpath "data" .. "/mason/packages/angular-language-server/node_modules"
local angular_cmd = {
  "ngserver",
  "--stdio",
  "--tsProbeLocations",
  install_path,
  "--ngProbeLocations",
  install_path .. "/@angular/language-server/node_modules",
}
return {
  "AstroNvim/astrolsp",
  opts = {
    config = {
      angularls = {
        cmd = angular_cmd,
        on_new_config = function(new_config, _) new_config.cmd = angular_cmd end,
      },
    },
  },
}

I could create a PR, but I have no clue how to do it correctly.

Screenshots

No response

Additional Context

No response

Minimal configuration

-- save as repro.lua
-- run with nvim -u repro.lua
-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "runtime", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  -- stylua: ignore
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
end
vim.opt.rtp:prepend(vim.env.LAZY or lazypath)

-- install plugins
local plugins = {
  { "AstroNvim/AstroNvim", import = "astronvim.plugins" },
  { "AstroNvim/astrocommunity" },

  -- add any other plugins/customizations here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

-- add anything else here (autocommands, vim.filetype, etc.)

wert2all avatar Aug 02 '25 00:08 wert2all

This seems like a bug/breaking change upstream tbf.

Uzaaft avatar Aug 02 '25 10:08 Uzaaft

If we do implement the fix proposed, I wonder how that would behave with newer versions of angular.

Uzaaft avatar Aug 02 '25 10:08 Uzaaft

If we do implement the fix proposed, I wonder how that would behave with newer versions of angular.

The Reddit post was created 2 years ago, and I have no idea why I only encountered the issue a month ago. However, I used that fix for NvChad a few months ago (for Angular 19 or something), and it worked. Now I'm using Angular 20, and it's still working for me.

wert2all avatar Aug 02 '25 11:08 wert2all

Could it be this issue? https://github.com/neovim/nvim-lspconfig/issues/3859

Failed to resolve '@angular/language-service' with minimum version '15.0' from

Seems similar to that bug report of version not being detected.

azdanov avatar Aug 02 '25 17:08 azdanov