Smor
Smor•16mo ago

Nvim tsserver clash with denols

I have read the docs and added a root_dir in my lua lsp file but for some reason tsserver still lanches on my deno fresh project
2 Replies
Smor
SmorOP•16mo ago
["tsserver"] = function()
lspconfig.tsserver.setup({
on_attach = on_attach,
capabilities = capabilities,
single_file_support = false,
root_dir = lspconfig.util.root_pattern("package.json"),
init_options = {
lint = true,
},
})
end,

["denols"] = function()
lspconfig.denols.setup({
on_attach = on_attach,
capabilities = capabilities,
root_dir = lspconfig.util.root_pattern("deno.json"),
init_options = {
lint = true,
},
})
end,
["tsserver"] = function()
lspconfig.tsserver.setup({
on_attach = on_attach,
capabilities = capabilities,
single_file_support = false,
root_dir = lspconfig.util.root_pattern("package.json"),
init_options = {
lint = true,
},
})
end,

["denols"] = function()
lspconfig.denols.setup({
on_attach = on_attach,
capabilities = capabilities,
root_dir = lspconfig.util.root_pattern("deno.json"),
init_options = {
lint = true,
},
})
end,
Deno AI Helper
Deno AI Helper•16mo ago
According to the documentation, if you have both tsserver and denols as LSP clients, you may run into issues where both are attached to your current buffer. To resolve this, you need to set a unique root_dir for both tsserver and denols. Here is an example of such a configuration provided in the documentation:
nvim_lsp.denols.setup {
on_attach = on_attach,
root_dir = nvim_lsp.util.root_pattern("deno.json", "deno.jsonc"),
}

nvim_lsp.tsserver.setup {
on_attach = on_attach,
root_dir = nvim_lsp.util.root_pattern("package.json"),
single_file_support = false
}
nvim_lsp.denols.setup {
on_attach = on_attach,
root_dir = nvim_lsp.util.root_pattern("deno.json", "deno.jsonc"),
}

nvim_lsp.tsserver.setup {
on_attach = on_attach,
root_dir = nvim_lsp.util.root_pattern("package.json"),
single_file_support = false
}
In this configuration, denols is set to look for a deno.json or deno.jsonc file to determine the root directory, while tsserver is set to look for a package.json file. Also, single_file_support is set to false for tsserver to prevent it from running in single file mode. If you've already done this and are still experiencing issues, it might be helpful to double-check your configuration and ensure that the root_dir for tsserver and denols are indeed unique and correctly pointing to the respective files. If the issue persists, it might be a good idea to debug your configuration or ask for help in the Deno community. 🦕

Did you find this page helpful?