From a5d63876d2903981263ab0f83cf218bc7cfcce00 Mon Sep 17 00:00:00 2001 From: Pratik Tripathy Date: Wed, 30 Jul 2025 22:19:30 +0530 Subject: [PATCH] feat(neovim): Replace `lualine` with `mini.statusline` & move all `mini.nvim` plugins to `utility-plugs` - Switched for easier configuration & reduction in number of plugins - `mini.nvim` now does way too many things to be in `code-generic` --- .../.config/nvim/lua/plugins/code-generic.lua | 68 ----------- common/.config/nvim/lua/plugins/ui.lua | 112 ------------------ .../nvim/lua/plugins/utility-plugs.lua | 107 +++++++++++++++++ common/.luarc.json | 3 +- 4 files changed, 109 insertions(+), 181 deletions(-) diff --git a/common/.config/nvim/lua/plugins/code-generic.lua b/common/.config/nvim/lua/plugins/code-generic.lua index cdf023c..5c96bae 100644 --- a/common/.config/nvim/lua/plugins/code-generic.lua +++ b/common/.config/nvim/lua/plugins/code-generic.lua @@ -9,74 +9,6 @@ return { end, }, - -- mini.nvim: Collection of various small independent plugins/modules - { - "echasnovski/mini.nvim", - version = false, - config = function() - -- gc - require("mini.comment").setup() - - require("mini.pairs").setup() - - -- mini.ai - -- va) - [v]isually select [a]round [)]paren - -- - a) would implicitly select around another ), based on some predefined logic - -- ci' - [c]hange [i]nside [']quote - -- via - [a]rguments - -- vif - [f]unction calls - -- va_ - select around "_" - -- va1 - select around two "1" - -- - -- explicit covering region: - -- vinq - select [i]nside [n]ext [q]uote - -- vilb - select inside last bracket - -- cina - change next function argument - -- cila - change last function argument - require("mini.ai").setup({ n_lines = 500 }) - - -- mini.surround - -- functionality similar to tpope's vim-surround - require("mini.surround").setup({ - mappings = { - add = "ys", -- add surrounding in normal and visual modes - delete = "ds", -- delete surrounding - find = "yf", -- find surrounding (to the right) - find_left = "yf", -- find surrounding (to the left) - highlight = "yh", -- highlight surrounding - replace = "cs", -- replace surrounding - update_n_lines = "", -- update `n_lines` - }, - silent = true, - }) - - -- configure mini.indentscope - if require("config.util").is_not_vscode() then - require("mini.indentscope").setup({ - delay = 100, - symbol = "│", - options = { try_as_border = true }, - }) - - vim.api.nvim_create_autocmd("FileType", { - pattern = { - "help", - "neo-tree", - "Trouble", - "trouble", - "lazy", - "mason", - "notify", - "toggleterm", - }, - callback = function() - vim.b.miniindentscope_disable = true - end, - }) - end - end, - }, - -- Finds and lists all of the TODO, HACK, BUG, etc comment { "folke/todo-comments.nvim", diff --git a/common/.config/nvim/lua/plugins/ui.lua b/common/.config/nvim/lua/plugins/ui.lua index 09da6a1..bda6796 100644 --- a/common/.config/nvim/lua/plugins/ui.lua +++ b/common/.config/nvim/lua/plugins/ui.lua @@ -193,118 +193,6 @@ return { }, }, - -- Set lualine as statusline - { - "nvim-lualine/lualine.nvim", - cond = require("config.util").is_not_vscode(), - init = function() - vim.g.lualine_laststatus = vim.o.laststatus - if vim.fn.argc(-1) > 0 then - -- set an empty statusline till lualine loads - vim.o.statusline = " " - else - -- hide the statusline on the starter page - vim.o.laststatus = 0 - end - end, - opts = function() - local lualine_require = require("lualine_require") - lualine_require.require = require - vim.o.laststatus = vim.g.lualine_laststatus - - local config = require("config.util") - - return { - options = { - theme = "auto", - icons_enabled = true, - globalstatus = true, - component_separators = "|", - section_separators = "", - }, - extensions = { "neo-tree", "lazy" }, - sections = { - lualine_a = { "mode" }, - lualine_b = { - "branch", - { - "diff", - symbols = { - added = config.icons.git.added, - modified = config.icons.git.modified, - removed = config.icons.git.removed, - }, - source = function() - local gitsigns = vim.b.gitsigns_status_dict - if gitsigns then - return { - added = gitsigns.added, - modified = gitsigns.changed, - removed = gitsigns.removed, - } - end - end, - }, - }, - lualine_c = { - { - "diagnostics", - symbols = { - error = config.icons.diagnostics.ERROR, - warn = config.icons.diagnostics.WARN, - info = config.icons.diagnostics.INFO, - hint = config.icons.diagnostics.HINT, - }, - }, - { - function() - return " " .. require("dap").status() - end, - cond = function() - return package.loaded["dap"] and require("dap").status() ~= "" - end, - color = config.fg("Debug"), - }, - }, - - lualine_x = { - { - function() - return require("noice").api.status.command.get() - end, - cond = function() - return package.loaded["noice"] and require("noice").api.status.command.has() - end, - color = config.fg("Statement"), - }, - { - function() - return require("noice").api.status.mode.get() - end, - cond = function() - return package.loaded["noice"] and require("noice").api.status.mode.has() - end, - color = config.fg("Constant"), - }, - }, - - lualine_y = { - { - "filename", - file_status = true, - path = 1, - }, - { "filetype", padding = { left = 1, right = 1 } }, - }, - lualine_z = { - { "progress", separator = " ", padding = { left = 1, right = 0 } }, - { "location", padding = { left = 0, right = 1 } }, - }, - }, - } - end, - }, - -- Indent guides for Neovim { "lukas-reineke/indent-blankline.nvim", diff --git a/common/.config/nvim/lua/plugins/utility-plugs.lua b/common/.config/nvim/lua/plugins/utility-plugs.lua index 4f3619f..f8c7853 100644 --- a/common/.config/nvim/lua/plugins/utility-plugs.lua +++ b/common/.config/nvim/lua/plugins/utility-plugs.lua @@ -1,4 +1,111 @@ return { + + -- mini.nvim: Collection of various small independent plugins/modules + { + "echasnovski/mini.nvim", + version = false, + config = function() + -- gc + require("mini.comment").setup() + + require("mini.pairs").setup() + + -- mini.ai + -- va) - [v]isually select [a]round [)]paren + -- - a) would implicitly select around another ), based on some predefined logic + -- ci' - [c]hange [i]nside [']quote + -- via - [a]rguments + -- vif - [f]unction calls + -- va_ - select around "_" + -- va1 - select around two "1" + -- + -- explicit covering region: + -- vinq - select [i]nside [n]ext [q]uote + -- vilb - select inside last bracket + -- cina - change next function argument + -- cila - change last function argument + require("mini.ai").setup({ n_lines = 500 }) + + -- mini.surround + -- functionality similar to tpope's vim-surround + require("mini.surround").setup({ + mappings = { + add = "ys", -- add surrounding in normal and visual modes + delete = "ds", -- delete surrounding + find = "yf", -- find surrounding (to the right) + find_left = "yf", -- find surrounding (to the left) + highlight = "yh", -- highlight surrounding + replace = "cs", -- replace surrounding + update_n_lines = "", -- update `n_lines` + }, + silent = true, + }) + + local statusline = require("mini.statusline") + statusline.setup({ + use_icons = vim.g.have_nerd_font, + content = { + active = function() + local config = require("config.util") + + local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 120 }) + local git = MiniStatusline.section_git({ trunc_width = 40 }) + local diff = MiniStatusline.section_diff({ + trunc_width = 75, + icon = config.icons.git.modified, + }) + local diagnostics = MiniStatusline.section_diagnostics({ + trunc_width = 75, + signs = config.icons.diagnostics, + }) + local lsp = MiniStatusline.section_lsp({ trunc_width = 75 }) + local filename = MiniStatusline.section_filename({ trunc_width = 140 }) + local fileinfo = MiniStatusline.section_fileinfo({ trunc_width = 40 }) + local search = MiniStatusline.section_searchcount({ trunc_width = 40 }) + local location = MiniStatusline.section_location({ trunc_width = 75 }) + + -- Mode | Branch, diff | Diagnostics | ... | FileType | FileName | Rows/Columns + return MiniStatusline.combine_groups({ + { hl = mode_hl, strings = { mode } }, + { hl = "MiniStatuslineDevinfo", strings = { git, diff } }, + { hl = mode, strings = { diagnostics } }, + "%<", -- Mark general truncate point + "%=", -- End left alignment + { hl = "MiniStatuslineFilename", strings = { filename } }, + { hl = "MiniStatuslineFileinfo", strings = { fileinfo } }, + { hl = mode_hl, strings = { search, location } }, + }) + end, + }, + }) + + -- configure mini.indentscope + if require("config.util").is_not_vscode() then + require("mini.indentscope").setup({ + delay = 100, + symbol = "│", + options = { try_as_border = true }, + }) + + vim.api.nvim_create_autocmd("FileType", { + pattern = { + "help", + "neo-tree", + "Trouble", + "trouble", + "lazy", + "mason", + "notify", + "toggleterm", + }, + callback = function() + vim.b.miniindentscope_disable = true + end, + }) + end + end, + }, + -- Various Quality of Life plugins into one { "folke/snacks.nvim", diff --git a/common/.luarc.json b/common/.luarc.json index 2d32f89..9efa30e 100644 --- a/common/.luarc.json +++ b/common/.luarc.json @@ -1,7 +1,8 @@ { "diagnostics.globals": [ "vim", - "Snacks" + "Snacks", + "MiniStatusline" ], "diagnostics.disable": [ "deprecated",