summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/lsp/utils.lua
blob: e024a0cfeb230e4466b751a4de3eb08f8acd964b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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, client
    end
  end
  return false
end

-- FIXME: this should return a list instead
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