typescript-tools.nvim icon indicating copy to clipboard operation
typescript-tools.nvim copied to clipboard

Diagnostics are added twice

Open kmoschcau opened this issue 8 months ago • 8 comments

Diagnostics coming from tsserver are added twice. Directly using ts_ls only adds them once. I can reproduce this with just this config:

require("typescript-tools").setup {}

:version output:

NVIM v0.12.0-dev-60+g8a40213eb3
Build type: RelWithDebInfo
LuaJIT 2.1.1741730670

kmoschcau avatar Apr 01 '25 07:04 kmoschcau

Make sure you don't have typescript-language-server (ts_ls) installed in Mason.

In features section they say: 🔨 Supports tsserver installed from Mason but I don't know what they mean by this.

iFarmGolems avatar Apr 28 '25 11:04 iFarmGolems

I have ts_ls installed, but I have set up my config in a way, that only one of denols, typescript-tools or ts_ls is even enabled. Either via setup() or vim.lsp.enable(). So either it should not interfere or typescript-tools finds the Mason installed ts_ls and starts that in addition to whatever it uses itself. That would be really weird.

kmoschcau avatar Apr 28 '25 15:04 kmoschcau

You can solve this problem using vim.lsp.enable("ts_ls", false). This is not an issue with ts-tools.nvim. I don't know why, even if ts_ls is downloaded, it gets enabled without require("lspconfig").ts_ls.setup(). I am a neovim beginner and I don't understand what's happening. But I solved the problem using vim.lsp.enable("ts_ls", false), although I think this is not an elegant solution. I would rather like someone to tell me why ts_ls gets loaded automatically.

Norhua avatar May 10 '25 11:05 Norhua

I now understand the reason for the problem. It is that the 2.0 version of mason-lspconfig has a feature to automatically enable installed servers. You can now solve the problem with the following settings. (https://github.com/mason-org/mason-lspconfig.nvim?tab=readme-ov-file#automatically-enable-installed-servers)

require("mason-lspconfig").setup {
    automatic_enable = false
}

Norhua avatar May 10 '25 15:05 Norhua

I don't use mason-lspconfig anymore since Mason version 2. There's no need to.

kmoschcau avatar May 10 '25 15:05 kmoschcau

@Norhua thank you—this solved it for me!

@kmoschcau could you elaborate? I read the changelog for Mason v2.0.0 but didn't see anything relevant to mason-lspconfig.

net avatar May 14 '25 18:05 net

@net I only used mason-lspconfig for installing servers automatically, based on which servers I had configured in nvim-lspconfig. Mason removed this automatic installation functionality with v2.0.0. Mason now only offers automatically enabling servers that were installed via Mason. But since I already enable servers on my own, I don't need that functionality. Ergo I don't need mason-lspconfig anymore.

kmoschcau avatar May 15 '25 06:05 kmoschcau

~~The problem seems to be gone for all of a sudden. I can't reproduce it anymore. I don't remember changing anything in my config, that I would say relates to this. So either some update in typescript-tools or in the underlying ts_ls solved it.~~

False alarm, it is still happening.

kmoschcau avatar Jun 26 '25 12:06 kmoschcau