inital commit
This commit is contained in:
50
lua/plugins/vue.lua
Normal file
50
lua/plugins/vue.lua
Normal file
@@ -0,0 +1,50 @@
|
||||
local lsp_conficts, _ = pcall(vim.api.nvim_get_autocmds, { group = "LspAttach_conflicts" })
|
||||
if not lsp_conficts then
|
||||
vim.api.nvim_create_augroup("LspAttach_conflicts", {})
|
||||
end
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = "LspAttach_conflicts",
|
||||
desc = "prevent tsserver and volar competing",
|
||||
callback = function(args)
|
||||
if not (args.data and args.data.client_id) then
|
||||
return
|
||||
end
|
||||
local active_clients = vim.lsp.get_active_clients()
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
-- prevent tsserver and volar competing
|
||||
-- if client.name == "volar" or require("lspconfig").util.root_pattern("nuxt.config.ts")(vim.fn.getcwd()) then
|
||||
-- OR
|
||||
if client.name == "volar" then
|
||||
for _, client_ in pairs(active_clients) do
|
||||
-- stop tsserver if volar 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 volar is already active
|
||||
if client_.name == "volar" then
|
||||
client.stop()
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
return {
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = {
|
||||
servers = {
|
||||
volar = {
|
||||
filetypes = {
|
||||
"javascript",
|
||||
"typescript",
|
||||
"vue",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{},
|
||||
}
|
||||
Reference in New Issue
Block a user