From 977990584331307dd5e71ebbbbd6b45b9c961996 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Sun, 15 Aug 2021 13:54:15 +0200 Subject: Updates to nvim lsp --- .config/nvim/lua/lsp/utils.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .config/nvim/lua/lsp/utils.lua (limited to '.config/nvim/lua/lsp/utils.lua') diff --git a/.config/nvim/lua/lsp/utils.lua b/.config/nvim/lua/lsp/utils.lua new file mode 100644 index 0000000..af265de --- /dev/null +++ b/.config/nvim/lua/lsp/utils.lua @@ -0,0 +1,27 @@ +local M = {} + +function M.is_client_active(name) + local clients = vim.lsp.get_active_clients() + for _, client in pairs(clients) do + if client.name == name then + return true + end + end + return false +end + +function M.get_active_client_by_ft(filetype) + if not options.lang[filetype] or not options.lang[filetype].lsp then + return nil + end + + local clients = vim.lsp.get_active_clients() + for _, client in pairs(clients) do + if client.name == options.lang[filetype].lsp.provider then + return client + end + end + return nil +end + +return M -- cgit v1.2.3-70-g09d2