config/.config/nvim/lua/lazyvim/plugins/lsp/misc.lua

54 lines
1.3 KiB
Lua

local M = {}
function M.disable_deno_formatting(client)
if client.name == "denols" then
require("null-ls").disable({ "prettier" })
end
end
function M.resolve_tsserver_deno(client)
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
end
function M.disable_others_when_zk(client)
local active_clients = vim.lsp.get_active_clients()
if client.name == "zk" then
for _, client_ in pairs(active_clients) do
-- stop ltex if zk is already active
if client_.name == "ltex" then
client_.stop()
end
end
elseif client.name == "ltex" then
for _, client_ in pairs(active_clients) do
-- prevent ltex from starting if zk is already active
if client_.name == "zk" then
client.stop()
end
end
end
end
function M.on_attach(client, bufnr)
M.disable_deno_formatting(client)
M.resolve_tsserver_deno(client)
M.disable_others_when_zk(client)
end
return M