-- detach denols if tsgo or tsserver is running. If no buffer is attached to denols, stop the client require("core.plugin").on_attach(function(client, bufnr) local node_servers = { "tsgo", "tsserver" } if not vim.iter({ node_servers, "denols" }):flatten(math.huge):any(function(s) return client.name == s end) then return end ---@type vim.lsp.Client[] local nodeLSPs = vim.iter({ "tsgo", "tsserver" }) :map(function(cn) return vim.lsp.get_clients({ name = cn, bufnr = bufnr }) end) :flatten() :totable() local denoLSPs = vim.lsp.get_clients({ name = "denols", bufnr = bufnr }) if #nodeLSPs > 0 and #denoLSPs > 0 then vim.lsp.stop_client(vim.iter(denoLSPs) :map(function(c) return c.id end) :totable()) -- vim.diagnostic.enable(true) end end) ---@type vim.lsp.Config return { single_file_support = true, workspace_required = false, settings = { deno = { lint = true, unstable = true, }, }, }