From 2de6b8b55b248eb1f9340b06fefbd9c158f43c6d Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Sat, 13 Jul 2024 18:41:08 +0300 Subject: Neovim: configured lualine, made custom LSP progress bar, removed fidget --- .config/nvim/lazy-lock.json | 5 +- .../nvim/lua/custom/plugins/TODO-statusline.lua | 12 -- .config/nvim/lua/custom/plugins/lsp.lua | 1 - .config/nvim/lua/custom/plugins/statusline.lua | 7 ++ .config/nvim/lua/custom/statusline.lua | 121 +++++++++++++++++++++ 5 files changed, 129 insertions(+), 17 deletions(-) delete mode 100644 .config/nvim/lua/custom/plugins/TODO-statusline.lua create mode 100644 .config/nvim/lua/custom/plugins/statusline.lua create mode 100644 .config/nvim/lua/custom/statusline.lua (limited to '.config') diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 0af83db..74c9ded 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -14,7 +14,6 @@ "darkstorm.nvim": { "branch": "master", "commit": "bab84a698e5a7bec92bd9d24acbd54554502e35e" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, "edgy.nvim": { "branch": "main", "commit": "1fe28978ab5671e9534fca40dca10280430ba727" }, - "fidget.nvim": { "branch": "main", "commit": "c12f8a58ee472ce5983c3a3f3aad0ff6c49a6a83" }, "ftFT.nvim": { "branch": "master", "commit": "f3e43c9584e14b27f04c27a95a9d9f0e58dfec02" }, "github-nvim-theme": { "branch": "main", "commit": "4f44a5c930372c85483d02700f332d34417e50b2" }, "gitsigns.nvim": { "branch": "main", "commit": "220446c8c86a280180d852efac60991eaf1a21d4" }, @@ -24,6 +23,7 @@ "lazy.nvim": { "branch": "main", "commit": "159036c5762a97246689299e61311fc88523a8fa" }, "lazydev.nvim": { "branch": "main", "commit": "cea5d0fb556cdc35122d9cae772e7e0ed65b4505" }, "leap.nvim": { "branch": "main", "commit": "c099aecaf858574909bd38cbadb8543c4dd16611" }, + "lsp-progress.nvim": { "branch": "main", "commit": "c5858bba2043cac5ad4113fe1263366125b1b314" }, "lsp_lines.nvim": { "branch": "main", "commit": "7d9e2748b61bff6ebba6e30adbc7173ccf21c055" }, "lsp_signature.nvim": { "branch": "master", "commit": "a38da0a61c172bb59e34befc12efe48359884793" }, "lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, @@ -43,12 +43,9 @@ "nvim": { "branch": "main", "commit": "2d3419c2aead379b7d1854d32458f20ffaa58562" }, "nvim-autopairs": { "branch": "master", "commit": "78a4507bb9ffc9b00f11ae0ac48243d00cb9194d" }, "nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" }, - "nvim-dap": { "branch": "master", "commit": "6f79b822997f2e8a789c6034e147d42bc6706770" }, - "nvim-dap-ui": { "branch": "master", "commit": "b7267003ba4dd860350be86f75b9d9ea287cedca" }, "nvim-lightbulb": { "branch": "master", "commit": "8f00b89dd1b1dbde16872bee5fbcee2e58c9b8e9" }, "nvim-lspconfig": { "branch": "master", "commit": "cf97d2485fc3f6d4df1b79a3ea183e24c272215e" }, "nvim-neoclip.lua": { "branch": "main", "commit": "709c97fabec9da7d04f7d2f5e207423af8c02871" }, - "nvim-nio": { "branch": "master", "commit": "7969e0a8ffabdf210edd7978ec954a47a737bbcc" }, "nvim-spectre": { "branch": "master", "commit": "9a28f926d3371b7ef02243cbbb653a0478d06e31" }, "nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" }, "nvim-treesitter": { "branch": "master", "commit": "c1ad655b6a0c83ab48e55240f367e2bc0c15af31" }, diff --git a/.config/nvim/lua/custom/plugins/TODO-statusline.lua b/.config/nvim/lua/custom/plugins/TODO-statusline.lua deleted file mode 100644 index 99dd11f..0000000 --- a/.config/nvim/lua/custom/plugins/TODO-statusline.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - 'nvim-lualine/lualine.nvim', - config = function() - -- TODO: Configure this to make the status line fully customizable - require('lualine').setup({ - options = { - theme = 'tokyonight', - }, - sections = { lualine_c = { require('auto-session.lib').current_session_name } }, - }) - end, -} diff --git a/.config/nvim/lua/custom/plugins/lsp.lua b/.config/nvim/lua/custom/plugins/lsp.lua index f64fd09..94ba58b 100644 --- a/.config/nvim/lua/custom/plugins/lsp.lua +++ b/.config/nvim/lua/custom/plugins/lsp.lua @@ -25,7 +25,6 @@ return { 'ray-x/lsp_signature.nvim', event = 'VeryLazy', }, - { 'j-hui/fidget.nvim', opts = { notification = { window = { winblend = 0 } } } }, -- AUtoformatting -- 'stevear/conform.nvim', diff --git a/.config/nvim/lua/custom/plugins/statusline.lua b/.config/nvim/lua/custom/plugins/statusline.lua new file mode 100644 index 0000000..775fadb --- /dev/null +++ b/.config/nvim/lua/custom/plugins/statusline.lua @@ -0,0 +1,7 @@ +return { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons', 'linrongbin16/lsp-progress.nvim' }, + config = function() + require("custom.statusline") + end, +} diff --git a/.config/nvim/lua/custom/statusline.lua b/.config/nvim/lua/custom/statusline.lua new file mode 100644 index 0000000..8b607d3 --- /dev/null +++ b/.config/nvim/lua/custom/statusline.lua @@ -0,0 +1,121 @@ +local lualine = require('lualine') +local lsp_progress = require('lsp-progress') + +local progress_filled = '█' +local progress_empty = '░' +local function progress_bar(percentage, width) + -- Ensure i is an integer between 0 and width (inclusive) + local i = math.max(0, math.min(math.floor(width * percentage), width)) + return string.rep(progress_filled, i) .. string.rep(progress_empty, width - i) +end + +local progress_bar_width = 10 +lsp_progress.setup({ + format = function(client_messages) -- global + local sign = ' LSP' + if #client_messages > 0 then + return sign .. ' ' .. table.concat(client_messages, ' ') + end + if #require('lsp-progress.api').lsp_clients() > 0 then + return sign + end + return '' + end, + client_format = function(_, _, series_messages) -- per lsp + return #series_messages > 0 and table.concat(series_messages, ', ') or nil + end, + series_format = function(title, message, percentage, done) -- per progress + local builder = {} + local has_title = false + local has_message = false + if type(title) == 'string' and string.len(title) > 0 then + table.insert(builder, title .. ':') + has_title = true + end + if percentage then + table.insert(builder, string.format('%.0f%%', percentage)) + table.insert(builder, 1, progress_bar(percentage / 100, progress_bar_width)) + end + if type(message) == 'string' and string.len(message) > 0 then + table.insert(builder, string.format('(%s)', message)) + has_message = true + end + if done and (has_title or has_message) then + table.insert(builder, ' ') + end + return table.concat(builder, ' ') + end, +}) + +lualine.setup({ + options = { + globalstatus = true, + theme = 'auto', + }, + sections = { + lualine_a = { { 'mode', icon = '' } }, + lualine_b = { + require('auto-session.lib').current_session_name, + { 'branch', icon = '' }, + { + 'diagnostics', + symbols = { + error = '󰅙 ', + warn = '󰀦 ', + info = '󰋼 ', + hint = '󰌵 ', + }, + }, + }, + lualine_c = { + function() + return lsp_progress.progress() + end, + -- { + -- 'lsp_progress', + -- -- separators = { spinner = { pre = '⟨', post = '⟩' } }, + -- -- display_components = { 'lsp_client_name', 'spinner', { 'title', 'percentage', 'message' } }, + -- display_components = { 'spinner', { 'title', 'percentage', 'message' } }, + -- -- spinner_symbols = { -- 20 wide + -- -- '░░░░░░░░░░░░░░░░░░░░', + -- -- '█░░░░░░░░░░░░░░░░░░░', + -- -- '██░░░░░░░░░░░░░░░░░░', + -- -- '███░░░░░░░░░░░░░░░░░', + -- -- '████░░░░░░░░░░░░░░░░', + -- -- '█████░░░░░░░░░░░░░░░', + -- -- '██████░░░░░░░░░░░░░░', + -- -- '███████░░░░░░░░░░░░░', + -- -- '████████░░░░░░░░░░░░', + -- -- '█████████░░░░░░░░░░░', + -- -- '██████████░░░░░░░░░░', + -- -- '███████████░░░░░░░░░', + -- -- '████████████░░░░░░░░', + -- -- '█████████████░░░░░░░', + -- -- '██████████████░░░░░░', + -- -- '███████████████░░░░░', + -- -- '████████████████░░░░', + -- -- '█████████████████░░░', + -- -- '██████████████████░░', + -- -- '███████████████████░', + -- -- '████████████████████', + -- -- }, + -- }, + }, + lualine_x = { + 'searchcount', + 'encoding', + 'fileformat', + 'filetype', + }, + lualine_y = { 'progress' }, + lualine_z = { 'location' }, + }, + extensions = { 'oil', 'trouble' }, +}) + +-- Refresh lualine when lsp progress is updated +vim.api.nvim_create_autocmd('User', { + group = vim.api.nvim_create_augroup('lualine_augroup', { clear = true }), + pattern = 'LspProgressStatusUpdated', + callback = require('lualine').refresh, +}) -- cgit v1.3.1