diff --git a/laptop/config/plugins.lua b/laptop/config/plugins.lua index 5ba512e..397d54b 100644 --- a/laptop/config/plugins.lua +++ b/laptop/config/plugins.lua @@ -66,6 +66,7 @@ require("lazy").setup( "junegunn/fzf.vim", "karb94/neoscroll.nvim", "hiphish/rainbow-delimiters.nvim", + "linrongbin16/lsp-progress.nvim", }, { lockfile = vim.fn.stdpath("config") .. "/config/lazy-lock.json", diff --git a/laptop/plugin/lspconfig.lua b/laptop/plugin/lsp_config.lua similarity index 100% rename from laptop/plugin/lspconfig.lua rename to laptop/plugin/lsp_config.lua diff --git a/laptop/plugin/lsp_progress.lua b/laptop/plugin/lsp_progress.lua new file mode 100644 index 0000000..9a8926e --- /dev/null +++ b/laptop/plugin/lsp_progress.lua @@ -0,0 +1,50 @@ +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/laptop/plugin/lualine.lua b/laptop/plugin/lualine.lua index 7ee31c1..189368d 100644 --- a/laptop/plugin/lualine.lua +++ b/laptop/plugin/lualine.lua @@ -1,13 +1,29 @@ -require("lualine").setup{ +require("lualine").setup { options = { theme = 'moonfly', }, tabline = { - lualine_a = {'buffers'}, + lualine_a = { 'buffers' }, lualine_b = {}, lualine_c = {}, lualine_x = {}, - lualine_y = {'filename'}, - lualine_z = {'tabs'}, + lualine_y = { 'filename' }, + lualine_z = { 'tabs' }, + }, + sections = { + lualine_a = { 'mode' }, + lualine_b = { 'branch', 'diff', 'diagnostics' }, + lualine_c = { 'filename', require('lsp-progress').progress }, + lualine_x = { 'encoding', 'fileformat', 'filetype' }, + lualine_y = { 'progress' }, + lualine_z = { 'location' } }, } + +-- listen lsp-progress event and refresh lualine +vim.api.nvim_create_augroup("lualine_augroup", { clear = true }) +vim.api.nvim_create_autocmd("User", { + group = "lualine_augroup", + pattern = "LspProgressStatusUpdated", + callback = require("lualine").refresh, +}) diff --git a/server/plugin/lspconfig.lua b/server/plugin/lsp_config.lua similarity index 100% rename from server/plugin/lspconfig.lua rename to server/plugin/lsp_config.lua diff --git a/vps/plugin/lspconfig.lua b/vps/plugin/lsp_config.lua similarity index 100% rename from vps/plugin/lspconfig.lua rename to vps/plugin/lsp_config.lua