summaryrefslogtreecommitdiff
path: root/lua/lsp/utils.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/lsp/utils.lua')
-rw-r--r--lua/lsp/utils.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/lua/lsp/utils.lua b/lua/lsp/utils.lua
new file mode 100644
index 00000000..e28c6085
--- /dev/null
+++ b/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 lvim.lang[filetype] or not lvim.lang[filetype].lsp then
+ return nil
+ end
+
+ local clients = vim.lsp.get_active_clients()
+ for _, client in pairs(clients) do
+ if client.name == lvim.lang[filetype].lsp.provider then
+ return client
+ end
+ end
+ return nil
+end
+
+return M