Closed gegoune closed 1 year ago
If you use lspconfig, remove ts/js filetypes from config of tsserver, something like:
local configs = require 'lspconfig.configs'
configs.tsserver.filetypes = {} -- set it to empty fts here
lspconfig doesn't support conditionally attaching server except by filetypes currently. If you'd like to, create autocmd for vim.lsp.start_client
and vim.lsp.buf_attach_client
manually.
BTW, the issue is not relevant to this plugin at all; you'd better move this to lspconfig.
Thanks, I got it to work by manipulating root_dir
as follows:
server = {
root_dir = function(fname)
if util.root_pattern('vite.config.ts')(fname) then
return nil
end
return util.root_pattern 'tsconfig.json'(fname)
or util.root_pattern('package.json', 'jsconfig.json', '.git')(fname)
end,
}
After quick test it seems not to be attaching to default filetypes if it sees vite.config.ts
file. I will close this issue now, but please let me know if you think this isn't correct solution.
Technically this approach is 100% reliable because a vite.config.ts
doesn't necessarily represent a Vue project. But if this works for your case, then just stick with it. Actually rootDir
is something should be abandoned and not future-proof with LSP changes, any hack on it should be applied with care.
Hi there, since there is no discussions enabled I am reluctantly opening this issue asking for some set up help. I am trying to wrap my head around takeover mode for Volar. My understanding is that if I enable Volar by setting filetypes accordingly it will also act as a Typescript LSP. In which case I should disable Typescript LSP itself, but am not sure how to do that. Can I somehow specify that if Volar is attached to buffer typescript.nvim won't attach ts to it as well?
Any guidance appreciated.