Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

angularls with root_dir setup does not work in combination with mason-lspconfig #437

Open
nicolaric-akenza opened this issue Jul 16, 2024 · 0 comments

Comments

@nicolaric-akenza
Copy link

Problem description

i now spent hours trying to set up my angularls with my Nx project. For this, a different value for the root_dir attribute needs to be set (angular.json not available, instead nx.json should be used).
i opened an issue for that on nvim-lspconfig repo (neovim/nvim-lspconfig#3237). it turns out, that the angularls is working correct, if i don't use williamboman/mason-lspconfig.nvim.

here is my setup:

return {
  {
    "williamboman/mason.nvim",
    lazy = false,
    config = function()
      require("mason").setup()
    end,
  },
  {
    "williamboman/mason-lspconfig.nvim",
    lazy = false,
    opts = {
      auto_install = true,
    },
  },
  { "tjdevries/vlog.nvim" },
  {
    "neovim/nvim-lspconfig",
    lazy = false,
    config = function()
      local lspconfig = require('lspconfig')
        lspconfig.angularls.setup {
          root_dir = function(fname)
            vim.notify('Root dir called', vim.log.levels.INFO)
            local util = require 'lspconfig.util'
            return util.root_pattern 'nx.json'(fname) or util.find_git_ancestor(fname)
          end,
      }
    end,
  },
}```



### Why do you think this is an issue with mason-lspconfig.nvim?

it works without this library, with it configured, it fails

### Neovim version (>= 0.7)

NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1713773202

### Operating system/version

Mac Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:59 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6030 arm64

### I've manually reviewed the Nvim LPS client log (`:LspLog`) to find potential errors

- [X] Yes

### I've recently downloaded the latest plugin version of mason.nvim, mason-lspconfig.nvim, and nvim-lspconfig

- [X] Yes

### Affected language servers

angularls

### Steps to reproduce

1. set up above lsp config
2. create new Nx angular project
3. go to html or ts file

### Actual behavior

LspInfo shows "root directory:    Not found." for angularls

### Expected behavior

root directory should be found

### LspInfo

```Text
Config: angularls
 	filetypes:         typescript, html, typescriptreact, typescript.tsx
 	root directory:    Not found.
 	cmd:               ngserver --stdio --tsProbeLocations /Users/user/.local/share/nvim/mason/packages/angular-language-server/node_modules,/Users/user/projects/akenza-ui/node_modules --ngProbeLocations /Users/user/.local/share/nvim/mason/packages/angular-language-server/node_modules/@angular/language-server/node_modules,/Users/user/projects/akenza-ui/node_modules
 	cmd is executable: true
 	autostart:         true
 	custom handlers:

LspLog

N/A

Healthcheck

N/A

Screenshots or recordings

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant