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

tsserver is deprecated, use ts_ls instead. Feature will be removed in lspconfig 0.2.0 #88

Closed
danz-km opened this issue Sep 5, 2024 · 3 comments

Comments

@danz-km
Copy link

danz-km commented Sep 5, 2024

So, I tried to change tsserver to ts_ls in the mason.lua file, but I got this message when I try to run nvim: [mason-lspconfig.nvim] Server "ts_ls" is not a valid entry in ensure_installed. Make su
re to only provide lspconfig server names.

@nitishlobo
Copy link

nitishlobo commented Sep 6, 2024

Here's the change you need to make:
Go to the following path:
~/.config/nvim/lua/josean/plugins/lsp/lspconfig.lua

And then modify the original code which looks like this:

mason_lspconfig.setup_handlers({
  -- default handler for installed servers
  function(server_name)
    lspconfig[server_name].setup({
      capabilities = capabilities,
    })
  end,
...

To this:

mason_lspconfig.setup_handlers({
  -- default handler for installed servers
  function(server_name)
    -- https://github.com/neovim/nvim-lspconfig/pull/3232#issuecomment-2331025714
    if server_name == "tsserver" then
      server_name = "ts_ls"
    end
    local capabilities = require("cmp_nvim_lsp").default_capabilities()
    require("lspconfig")[server_name].setup({
      capabilities = capabilities,
    })

    lspconfig[server_name].setup({
      capabilities = capabilities,
    })
  end,
...

And then open nvim and do the following:
:Lazy reload mason.nvim mason-lspconfig.nvim mason-tool-installer.nvim

Credits:
I got the code from here: neovim/nvim-lspconfig#3232 (comment)

@danz-km
Copy link
Author

danz-km commented Sep 6, 2024

Here's the change you need to make: Go to the following path: ~/.config/nvim/lua/josean/plugins/lsp/lspconfig.lua

And then modify the original code which looks like this:

mason_lspconfig.setup_handlers({
  -- default handler for installed servers
  function(server_name)
    lspconfig[server_name].setup({
      capabilities = capabilities,
    })
  end,
...

To this:

mason_lspconfig.setup_handlers({
  -- default handler for installed servers
  function(server_name)
    -- https://github.com/neovim/nvim-lspconfig/pull/3232#issuecomment-2331025714
    if server_name == "tsserver" then
      server_name = "ts_ls"
    end
    local capabilities = require("cmp_nvim_lsp").default_capabilities()
    require("lspconfig")[server_name].setup({
      capabilities = capabilities,
    })

    lspconfig[server_name].setup({
      capabilities = capabilities,
    })
  end,
...

And then open nvim and do the following: :Lazy reload mason.nvim mason-lspconfig.nvim mason-tool-installer.nvim

Credits: I got the code from here: neovim/nvim-lspconfig#3232 (comment)

Thank you so much man, it works!

@devstefancho
Copy link

For those who come later, the remapping from mason-lspconfig to ts_ls is now complete.

https://github.com/williamboman/mason-lspconfig.nvim/blob/25c11854aa25558ee6c03432edfa0df0217324be/doc/mason-lspconfig-mapping.txt#L203

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