Diagnostics are added twice
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
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.
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.
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.
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
}
I don't use mason-lspconfig anymore since Mason version 2. There's no need to.
@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 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.
~~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.