瀏覽代碼

feat: resolve null-ls tag in galaxyline (#1138)

kylo252 4 年之前
父節點
當前提交
c07b0c4731
共有 1 個文件被更改,包括 13 次插入24 次删除
  1. 13 24
      lua/core/galaxyline.lua

+ 13 - 24
lua/core/galaxyline.lua

@@ -200,39 +200,28 @@ table.insert(gls.right, {
   },
 })
 
-local get_lsp_client = function(msg)
+local function get_attached_provider_name(msg)
   msg = msg or "LSP Inactive"
-  local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
-  local clients = vim.lsp.get_active_clients()
-  if next(clients) == nil then
+
+  local buf_ft = vim.bo.filetype
+  local buf_clients = vim.lsp.buf_get_clients()
+  if next(buf_clients) == nil then
     return msg
   end
-  local lsps = ""
-  for _, client in ipairs(clients) do
-    local filetypes = client.config.filetypes
-    if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
-      -- print(client.name)
-      if lsps == "" then
-        -- print("first", lsps)
-        lsps = client.name
-      else
-        if not string.find(lsps, client.name) then
-          lsps = lsps .. ", " .. client.name
-        end
-        -- print("more", lsps)
-      end
+  local buf_client_names = {}
+  for _, client in pairs(buf_clients) do
+    if client.name == "null-ls" then
+      table.insert(buf_client_names, lvim.lang[buf_ft].linters[1])
+    else
+      table.insert(buf_client_names, client.name)
     end
   end
-  if lsps == "" then
-    return msg
-  else
-    return lsps
-  end
+  return table.concat(buf_client_names, ", ")
 end
 
 table.insert(gls.right, {
   ShowLspClient = {
-    provider = get_lsp_client,
+    provider = get_attached_provider_name,
     condition = function()
       local tbl = { ["dashboard"] = true, [" "] = true }
       if tbl[vim.bo.filetype] then