typescript-tools.nvim
typescript-tools.nvim copied to clipboard
duplicated diagnostic
good day.. My diagnostics are duplicated when using the typescript-tools.nvim (typescript installed globally via npm) and my configs are just as is on how I installed it using Lazy
is that meant to be? Is there a workaround for it?
Thank you in advance.
@gmmoose20 It shouldn't be like that, besides nvim deduplicate same diagnostics from one server. It looks like you have second one which is running for example standard tsserver from lspconfig. Did you disabled lspcnfig one? Please run :LspInfo to verify you don't have attached any other typescript server.
this is my :LspInfo
as for my lspconfig:
tsserver = { enabled = false }
Is there a way to disable it? may be I just didn't do the right way 😅
If it isn't listed in :LspInfo this mean it is correctly disabled. Followup question, you have it duplicated always and every diagnostic message is duplicated or is it accideutialy - happens from time to time?
If it is from time to time it can be connected with https://github.com/pmizio/typescript-tools.nvim/issues/202 this. Stale one message is stale for some reason, which I don't know yet, and you get duplication. In this case you may try to clear diagnostic using :lua vim.diagnostic.reset(). You may also give a shoot this https://github.com/pmizio/typescript-tools.nvim/pull/223 branch and let me know if it helps.
If it is permanent probably it isn't connected to case described previously, so I need more info:
- nvim version
- typescript version
- ideally project to reproduce
nvim -v: NVIM v0.9.5
tsc -v: 5.3.3
I only get the duplicate diagnostic with typescript-tools.nvim but when I remove it and just use the plain extras.typescript from Lazyvim it works just fine.
Weird, I'll install LazyVim distro and check it with your configuration. @gmmoose20 can you post how you configure my plugin?
here.. under plugins/lsp.lua
{
"pmizio/typescript-tools.nvim",
dependencies = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" },
opts = {
on_attach = on_attach,
settings = {
tsserver_file_preferences = {
includeCompletionsForModuleExports = true,
-- inlay hints
includeInlayParameterNameHints = "literals",
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayVariableTypeHintsWhenTypeMatchesName = false,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
},
tsserver_format_options = {
allowIncompleteCompletions = false,
allowRenameOfImportPath = false,
},
},
},
},
I have my typescript installed via npm globally.
@gmmoose20 ok so i installed lazyvim to check it and fill my understanding of situation, you have both lazyvim's setting { import = "lazyvim.plugins.extras.lang.typescript" }, and my plugin in the same time and then you get duplicated diagnostic? Then you eg. comment out lazyvim's setting and still have duplicated diagnostic yes?
If both are true my best bet is delete typsecript-language-server from :Mason. When it is installed mason-lspconfig still bootstrap it and probably becouse of this you get this duplications. To do this go to :Mason then press X(capital letter) on typescript-language-server relaunch nvim and let me know it helps.
unfortunately still the same, I did try reinstalling fresh lazyvim and only added typescript-tools and still the same it still duplicates the diagnostics.
one thing I notice too is that its saying tsserver.... in diagnostic line but when I'm using just the typescript plugin from lazyvim import it just says typescript... and also when I don't disable tsserver from lspconfig and just have them both, it shows tsserver... and tyescript... so I'll have three the same diagnostics. That's when I knew that it's something in typescript-tools plugin.
@gmmoose20 Can you make some minimal repo with config which presents error? I cannot reproduce it, tried to install lazyvim by cloning it into my .config/nvim then I just created plugins/lsp.lua then from this file I returned your config posted here and typesciript-tools working correctly no duplications. You can try to follow what I did maybe this show us something. I'm pretty sure it is something in your configuration, because you tell me about 3 different "variables": lazyvim's { import = "..." } thingy, lsp-config(I'm not sure you use it separately) and typescript-tools.
We add lspconfig configuration to typescript-tools under the hood when calling setup so it is possible to some code yours/lazyvim's call it twice.
I don't really know why in mine its getting duplicates.
This is a fresh install Lazyvim.
my config at /plugins/lsp.lua:
this what happens when I install typescript globally with :MasonInstall typescript-server-language
as you can see I have three with the same output, when I remove
typescript-tools plugin I don't get any duplicates.
oh, I just noticed you are on windows maybe this is some clue i need to check this
may be its something to do with the
cmd ?
may be its something to do with the
cmd?
I manage to fix my issue with this config:
I don't get duplicates now. So I think its about that cmd: on windows..
hope this helps on debugging the plugin for windows users. :)
For anyone using mason-lspconfig, mason-lspconfig automatically sets up all LSPs installed with Mason. To work around this, you can configure a setup handler that will return early if server_name == 'tsserver'. See the mason-lspconfig docs for more info.
I had a similar issue where both typescript-tools and tsserver were launched. Many things were "doubled" such as go to definition adding two tag stack entries (had to Ctrl+t twice to get back), LSP renaming asked the name of the new symbol twice,...
See above for the fix that worked for me - I am not sure I understand what is going on, but hopefully it's helpful.
Same issue for me:
LspInfo:
I have latest MacOS and NeoVim. The plugin was install via Mason.
The workaround from @net seems to work
Here is an example of how to configure the workaround from @net mentioned above if using lazy.nvim.
Don't forget to uninstall tsserver from Mason as well (by running :Mason and hitting X on tsserver)
{
"williamboman/mason-lspconfig.nvim",
opts = {
handlers = {
function(server_name)
if server_name == "tsserver" then
return
end
end,
},
},
}
When I skip loading tsserver with mason, I don't have all the syntax highlighting
{
"williamboman/mason-lspconfig.nvim",
opts = {
handlers = {
function(server_name)
if server_name == "tsserver" then
return
end
end,
},
},
}
This is my syntax highlighting with tsserver skipped (only typescript-tools attached)
And this is syntax highlighting with both tsserver and typescript-tools attached
Skipping the tsserver disables a lot of the syntax features, and the code gets harder to read
With LazyVim, the culprit for my case was LazyExtra lang.typescript. So I disable it for now
I'm still getting duplicated diagnostic, how to properly disable `tsserver?
@mbalazy Make sure that you aren't calling setup() for typescript-tools or tsserver in another location in your config (for example in your setup for nvim-lspconfig). This typically happens when the user calls setup(), and then typescript-tools also calls setup() internally, so you end up with 2 instances.
for Lunarvim users:
- delete
typescript-language-serverfrom:Mason - add
lvim.lsp.installer.setup.automatic_installation.exclude = { 'tsserver' }into yourconfig.lua
may be its something to do with the