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

Incorrect LSP detection #89

Open
le4ker opened this issue Dec 24, 2023 · 7 comments
Open

Incorrect LSP detection #89

le4ker opened this issue Dec 24, 2023 · 7 comments

Comments

@le4ker
Copy link

le4ker commented Dec 24, 2023

Thank you for Dotfyle, it's great!

One potential bug is that it can't detect all language servers, at least in my config.
For example here it detects the following language servers:

  • tflint
  • html
  • clangd
  • marksman
  • gopls
  • graphql
  • pyright

And it's missing the following ones:

  • bash-language-server
  • terraform-ls
  • tsserver
  • lua_ls
  • yamlls

Even though they seem to be included in the known language servers.

Also it detects html and graphql as a language servers even though I haven't set any such LSPs.
That maybe an issue with the known language servers, since I can't find an LSP named html or graphql in Mason 😅

@le4ker
Copy link
Author

le4ker commented Dec 24, 2023

Opened a PR in case the html and graphql must be removed.

@le4ker
Copy link
Author

le4ker commented Dec 24, 2023

Seems like it might be parsing the mason.lua file but not the lspconfig.lua?
Because all the missing LSPs are in my lspconfig, but they have a different name in the Mason config 😄

@le4ker le4ker changed the title Not all Language Servers detected Incorrect LSP detection Dec 24, 2023
@codicocodes
Copy link
Owner

html and graphql are taken from here: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md not from mason

@le4ker
Copy link
Author

le4ker commented Dec 28, 2023

@codicocodes thank you, I closed my PR. Why does dotfyle detect those LSPs though in my case? Also why aren't the rest LSPs detected, even though they are defined in the known language servers?

@codicocodes
Copy link
Owner

Detection is looking for the string 'html' or 'graphql' in your config, this works for most language servers pretty well, but for html could easily have false positives. Here is your HTML setup btw, so it is not a false positive I believe: https://github.com/le4ker/nvim-config/blob/v2.0/lua/custom/configs/lspconfig.lua#L40-L43 The graphql one could be a false positive.

Not sure about why some are not detected though, it looks like that could very well be a bug.

@le4ker
Copy link
Author

le4ker commented Jan 1, 2024

Yeah I added the html LSP a couple of days ago, but it was a false positive like graphql before that.

I noticed as well that in the code it just greps for the strings, so it's strange indeed that it can't detect some LSPs 🤔

@iainsimmons
Copy link

Part of the issue here is that there's two different names used for some language servers, and Mason's ensure_installed takes a different format than the ones in the known language servers.

See https://github.com/iainsimmons/nvim-config/blob/main/lua/plugins/lsp.lua#L182-L202

Also, you might get some false positives if the LSP name is matched in a code comment, such as for those using the linting setup from kickstart.nvim.

Or if the filename matches the name of the language server (as was the case for astro, html and svelte in my config) and is used elsewhere (e.g. for my emmet_ls config).

My first pass with Dotfyle generated the following:

  • astro
  • glint
  • html
  • lemminx
  • marksman
  • svelte
  • tflint

Some of which are the ones that don't use a different format for the language server name.

Here are some that are different (Mason / LSP Config):

  • "astro-language-server" / "astro"
  • "emmet-ls" / "emmet_ls"
  • "eslint-lsp" / "eslint"
  • "html-lsp" / "html"
  • "htmx-lsp" / "htmx"
  • "json-lsp" / "jsonls"
  • "lua-language-server" / "lua_ls"
  • "svelte-language-server" / "svelte"
  • "tailwindcss-language-server" / "tailwindcss"
  • "typescript-language-server" / "tsserver"
  • "yaml-language-server" / "yamlls"

So you almost need to match all the Mason strings too.

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

No branches or pull requests

3 participants