Recently I started using Deno for some personal projects, and when I installed the Deno lsp client on neovim, it clashed with tsserver as it has no idea what Deno types are and some other annoying diagnostics.
The official documentation instructs you to specify the
root_dir param in the
server:setup(options), but I thought that was a lot of hassle as it would not work for when you don't have a Deno project, but have no
My solution was to use a programmatic way to have fine grained control over when to start which. Basically when
tsserver wants to start, it checks if
denols is in the active clients (which you can get using
vim.lsp.get_active_clients()) and not continue setup, and
denols does the same check to see if
tsserver is attached to a file that belongs to it and kills it.
here's the full snippet:
local active_clients = vim.lsp.get_active_clients() if client.name == 'denols' then for _, client_ in pairs(active_clients) do -- stop tsserver if denols is already active if client_.name == 'tsserver' then client_.stop() end end elseif client.name == 'tsserver' then for _, client_ in pairs(active_clients) do -- prevent tsserver from starting if denols is already active if client_.name == 'denols' then client.stop() end end end
I hope it saves you some time.