diff --git a/nvim/.config/nvim/after/plugin/statusline.lua b/nvim/.config/nvim/after/plugin/statusline.lua index 441d054..5768754 100644 --- a/nvim/.config/nvim/after/plugin/statusline.lua +++ b/nvim/.config/nvim/after/plugin/statusline.lua @@ -1,8 +1,10 @@ local fn = vim.fn local api = vim.api -local gstatus = { ahead = 0, behind = 0 } -local update_gstatus = function() +local lsp_status = "" +local gstatus = { ahead = 0, behind = 0 } + +local update_status = function() local Job = require 'plenary.job' Job:new({ command = 'git', @@ -20,16 +22,19 @@ local update_gstatus = function() gstatus = { ahead = ahead, behind = behind } end, }):start() + + if vim.lsp.status then + lsp_status = vim.lsp.status() + end end if _G.Gstatus_timer == nil then _G.Gstatus_timer = vim.uv.new_timer() + _G.Gstatus_timer:start(0, 1000, vim.schedule_wrap(update_status)) else _G.Gstatus_timer:stop() end -_G.Gstatus_timer:start(0, 2000, vim.schedule_wrap(update_gstatus)) - local M = {} local colors = { @@ -70,10 +75,12 @@ highlight("DiagnosticsH", colors.orange , colors.bg) highlight("Location" , colors.yellow , colors.bg) highlight("Progress" , colors.magenta, colors.bg) highlight("WinbarFile" , colors.magenta, colors.bg) +highlight("LspProgress" , colors.orange , colors.bg) M.trunc_width = setmetatable({ - git_status = 60, filename = 140, + git_status = 60, + lsp_status = 80, }, { __index = function() return 80 @@ -204,12 +211,26 @@ M.git_ahead_behind_status = function() or "" end +M.get_lsp_status = function(self) + local trunc_width = self.trunc_width.lsp_status + if self:is_truncated(trunc_width) then + return "" + end + + if vim.lsp.status then + return string.format(" %s%s", '%#LspProgress#', string.sub(lsp_status, 1, trunc_width)) + end + + return "" +end + M.set_active = function(self) return table.concat { self:get_filename(), self:get_git_status(), self:git_ahead_behind_status(), "%=", + self:get_lsp_status(), self:diagnostic_status(), self:get_line_col(), self:progress(), diff --git a/nvim/.config/nvim/lua/lsp.lua b/nvim/.config/nvim/lua/lsp.lua index 6d03ca0..122cb29 100644 --- a/nvim/.config/nvim/lua/lsp.lua +++ b/nvim/.config/nvim/lua/lsp.lua @@ -233,3 +233,8 @@ vim.api.nvim_create_autocmd("LspDetach", { client_custom_cleanup(client) end, }) + +vim.api.nvim_create_autocmd("LspProgress", { + group = lsp_augroup_id, + command = "redrawstatus" +})