diff --git a/config/plugins/qol.nix b/config/plugins/qol.nix index 157e514..15bfdc5 100644 --- a/config/plugins/qol.nix +++ b/config/plugins/qol.nix @@ -3,7 +3,6 @@ { extraPackages = with pkgs; [ ripgrep - yazi fd ]; @@ -25,34 +24,24 @@ barbecue.enable = true; lualine = { enable = true; - sections = { - lualine_a = [ "branch" ]; - lualine_b = [ "diff" ]; - lualine_c = [ - # { - # __unkeyed-1 = { - # __raw = '' - # function() - # local bufnr = vim.api.nvim_get_current_buf() - # - # local clients = vim.lsp.buf_get_clients(bufnr) - # if next(clients) == nil then - # return "" - # end - # - # local c = {} - # for _, client in pairs(clients) do - # table.insert(c, client.name) - # end - # return '\u{f085} ' .. table.concat(c, '|') - # end - # ''; - # icon = ""; - # }; - # } - ]; + settings = { + sections = { + lualine_a = [ "branch" ]; + lualine_b = [ "diff" ]; + lualine_c = [ + { + __unkeyed-1 = { + __raw = '' + function() + return require('lsp-progress').progress() + end, + ''; + }; + } + ]; + }; + options.globalstatus = true; }; - globalstatus = true; }; crates-nvim.enable = true; # git stuff @@ -71,5 +60,9 @@ name = "render-markdown.nvim"; src = inputs.render-markdown; }) + (pkgs.vimUtils.buildVimPlugin { + name = "lsp-progress.nvim"; + src = inputs.lsp-progress; + }) ]; } diff --git a/config/plugins/setup.nix b/config/plugins/setup.nix index 8c3da18..497cfd7 100644 --- a/config/plugins/setup.nix +++ b/config/plugins/setup.nix @@ -3,6 +3,57 @@ extraConfigLua = '' require("telescope").load_extension("yank_history") require("telescope").load_extension("ht") - vim.diagnostic.config({ virtual_lines = false }); + vim.diagnostic.config({ virtual_lines = false }) + + require("lsp-progress").setup({ + client_format = function(client_name, spinner, series_messages) + if #series_messages == 0 then + return nil + end + return { + name = client_name, + body = spinner .. " " .. table.concat(series_messages, ", "), + } + end, + format = function(client_messages) + --- @param name string + --- @param msg string? + --- @return string + local function stringify(name, msg) + return msg and string.format("%s %s", name, msg) or name + end + + local sign = "" -- nf-fa-gear \uf013 + local lsp_clients = vim.lsp.get_active_clients() + local messages_map = {} + for _, climsg in ipairs(client_messages) do + messages_map[climsg.name] = climsg.body + end + + if #lsp_clients > 0 then + table.sort(lsp_clients, function(a, b) + return a.name < b.name + end) + local builder = {} + for _, cli in ipairs(lsp_clients) do + if + type(cli) == "table" + and type(cli.name) == "string" + and string.len(cli.name) > 0 + then + if messages_map[cli.name] then + table.insert(builder, stringify(cli.name, messages_map[cli.name])) + else + table.insert(builder, stringify(cli.name)) + end + end + end + if #builder > 0 then + return sign .. " " .. table.concat(builder, ", ") + end + end + return "" + end, + }) ''; } diff --git a/flake.lock b/flake.lock index fc46c88..d341da7 100644 --- a/flake.lock +++ b/flake.lock @@ -181,6 +181,22 @@ "type": "github" } }, + "lsp-progress": { + "flake": false, + "locked": { + "lastModified": 1721008335, + "narHash": "sha256-OafRT5AnxRTOh7MYofRFjti0+pobKQihymZs/kr5w0A=", + "owner": "linrongbin16", + "repo": "lsp-progress.nvim", + "rev": "d5f4d28efe75ce636bfbe271eb45f39689765aab", + "type": "github" + }, + "original": { + "owner": "linrongbin16", + "repo": "lsp-progress.nvim", + "type": "github" + } + }, "nix-darwin": { "inputs": { "nixpkgs": [ @@ -300,6 +316,7 @@ "inputs": { "flake-parts": "flake-parts", "haskell-tools": "haskell-tools", + "lsp-progress": "lsp-progress", "nixpkgs": "nixpkgs", "nixvim": "nixvim", "render-markdown": "render-markdown", diff --git a/flake.nix b/flake.nix index 08b81c1..a6dc1e1 100644 --- a/flake.nix +++ b/flake.nix @@ -19,6 +19,10 @@ url = "github:mrcjkb/haskell-tools.nvim"; flake = false; }; + lsp-progress = { + url = "github:linrongbin16/lsp-progress.nvim"; + flake = false; + }; }; outputs =