소스 검색

fix(lualine): use get_active_clients instead of deprecated function (#4136)

* fix(lualine): use `get_active_clients` instead of deprecated function

`vim.lsp.get_active_clients()` accepts a table to filter returned
clients by id, bufnr and name. In this case when want to get clients for
current buffer, if bufnr is not given then it defaults to current
buffer, so need to pass anything here.

See `help vim.lsp.buf_get_clients()`

* refactor(lualine): simplify LSP component

`vim.lsp.get_active_clients` always returns a table, if that table is
empty, there's no clients attached, hence return appropriate message. No
need to use `next()`

Remove all the complicated logic with the `msg` parameter, no argument
is passed in any of the places that component is used, no need to have it.

* fix: only get clients attached to current buffer

---------

Co-authored-by: LostNeophyte <lostneophyte@tuta.io>
Rafael Madriz 2 년 전
부모
커밋
55f048aaae
1개의 변경된 파일5개의 추가작업 그리고 9개의 파일을 삭제
  1. 5 9
      lua/lvim/core/lualine/components.lua

+ 5 - 9
lua/lvim/core/lualine/components.lua

@@ -92,16 +92,12 @@ return {
     cond = conditions.hide_in_width,
   },
   lsp = {
-    function(msg)
-      msg = msg or "LS Inactive"
-      local buf_clients = vim.lsp.buf_get_clients()
-      if next(buf_clients) == nil then
-        -- TODO: clean up this if statement
-        if type(msg) == "boolean" or #msg == 0 then
-          return "LS Inactive"
-        end
-        return msg
+    function()
+      local buf_clients = vim.lsp.get_active_clients { bufnr = 0 }
+      if #buf_clients == 0 then
+        return "LSP Inactive"
       end
+
       local buf_ft = vim.bo.filetype
       local buf_client_names = {}
       local copilot_active = false