diff options
Diffstat (limited to '.config/nvim/lua/lsp/utils.lua')
-rw-r--r-- | .config/nvim/lua/lsp/utils.lua | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/.config/nvim/lua/lsp/utils.lua b/.config/nvim/lua/lsp/utils.lua deleted file mode 100644 index afc3eba..0000000 --- a/.config/nvim/lua/lsp/utils.lua +++ /dev/null @@ -1,67 +0,0 @@ -local M = {} - -local tbl = require "utils.table" - -function M.is_client_active(name) - local clients = vim.lsp.get_active_clients() - return tbl.find_first(clients, function(client) - return client.name == name - end) -end - -function M.get_active_clients_by_ft(filetype) - local matches = {} - local clients = vim.lsp.get_active_clients() - for _, client in pairs(clients) do - local supported_filetypes = client.config.filetypes or {} - if client.name ~= "null-ls" and vim.tbl_contains(supported_filetypes, filetype) then - table.insert(matches, client) - end - end - return matches -end - -function M.get_client_capabilities(client_id) - if not client_id then - local buf_clients = vim.lsp.buf_get_clients() - for _, buf_client in ipairs(buf_clients) do - if buf_client.name ~= "null-ls" then - client_id = buf_client.id - break - end - end - end - if not client_id then - error "Unable to determine client_id" - return - end - - local client = vim.lsp.get_client_by_id(tonumber(client_id)) - - local enabled_caps = {} - for capability, status in pairs(client.resolved_capabilities) do - if status == true then - table.insert(enabled_caps, capability) - end - end - - return enabled_caps -end - -function M.get_supported_filetypes(server_name) - -- temporary workaround: https://github.com/neovim/nvim-lspconfig/pull/1358 - if server_name == "dockerls" then - return { "dockerfile" } - end - local lsp_installer_servers = require "nvim-lsp-installer.servers" - local server_available, requested_server = lsp_installer_servers.get_server( - server_name - ) - if not server_available then - return {} - end - - return requested_server:get_supported_filetypes() -end - -return M |