Skip to content

Commit

Permalink
fix: on_attach called multiple times with `separate_diagnostic_serv…
Browse files Browse the repository at this point in the history
…er` (#213)
  • Loading branch information
pmizio authored Jan 10, 2024
1 parent 13d9dda commit df64c37
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lua/typescript-tools/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,26 @@ function M.setup(config)
}
end

-- INFO: some nasty ifology but it need to be placed somewhere
-- I prefer it here than in huge file tsserver.lua
-- Rationale: `on_attach` is called based on response from `configure` request and because we
-- have two servers nvim get also two responses
local on_attach_called = false
local config_on_attach = config.on_attach

local function on_attach(...)
if on_attach_called then
return
end

on_attach_called = true
config_on_attach(...)
end

if config.on_attach then
config.on_attach = on_attach
end

lspconfig[plugin_config.plugin_name].setup(config)
end

Expand Down

0 comments on commit df64c37

Please sign in to comment.