From 6076347f7be4f1c0b85edb6e9b384cc7f024e464 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Fri, 10 Oct 2025 23:30:46 +0545 Subject: [PATCH] refactor(editor): consolidate mini.nvim plugins and remove unused editor plugins --- lazy-lock.json | 11 +-- lua/plugins/editor.lua | 172 ++++++++++++------------------------- lua/plugins/languages.lua | 9 +- lua/plugins/mini.lua | 120 ++++++++++++++++++++++++++ lua/plugins/statusline.lua | 32 ------- lua/plugins/utility.lua | 34 ++++---- 6 files changed, 198 insertions(+), 180 deletions(-) create mode 100644 lua/plugins/mini.lua delete mode 100644 lua/plugins/statusline.lua diff --git a/lazy-lock.json b/lazy-lock.json index 9313ef5..c1c34a0 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,16 +1,14 @@ { - "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, "LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" }, "Navigator.nvim": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" }, "better-escape.nvim": { "branch": "master", "commit": "19a38aab94961016430905ebec30d272a01e9742" }, "blink.cmp": { "branch": "main", "commit": "327fff91fe6af358e990be7be1ec8b78037d2138" }, - "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, "conform.nvim": { "branch": "master", "commit": "9d859cbfbde7a1bd1770e7c97aef30ec5a237a71" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, "gitsigns.nvim": { "branch": "main", "commit": "1ee5c1fd068c81f9dd06483e639c2aa4587dc197" }, "gruvbox.nvim": { "branch": "main", "commit": "5e0a460d8e0f7f669c158dedd5f9ae2bcac31437" }, "harpoon": { "branch": "harpoon2", "commit": "ed1f853847ffd04b2b61c314865665e1dadf22c7" }, - "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, + "lazy.nvim": { "branch": "main", "commit": "59334064f8604ca073791c25dcc5c9698865406e" }, "lazygit.nvim": { "branch": "main", "commit": "2305deed25bc61b866d5d39189e9105a45cf1cfb" }, "lspsaga.nvim": { "branch": "main", "commit": "8efe00d6aed9db6449969f889170f1a7e43101a1" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, @@ -20,12 +18,8 @@ "mason-nvim-lint": { "branch": "main", "commit": "767b8ccdddaa977bec8987fd7507b9865a279235" }, "mason.nvim": { "branch": "main", "commit": "ad7146aa61dcaeb54fa900144d768f040090bff0" }, "mdx.nvim": { "branch": "main", "commit": "464a74be368dce212cff02f6305845dc7f209ab3" }, - "mini.ai": { "branch": "main", "commit": "e139eb1101beb0250fea322f8c07a42f0f175688" }, - "mini.bracketed": { "branch": "main", "commit": "0ea3cb6478e5fdeca33b53fd08683eb2e622f6ce" }, "mini.files": { "branch": "main", "commit": "49c855977e9f4821d1ed8179ed44fe098b93ea2a" }, - "mini.icons": { "branch": "main", "commit": "284798619aed9f4c1ac1b9417b9a5e3b4b85ef3a" }, - "mini.indentscope": { "branch": "main", "commit": "e9fa0714fc753e1e737940577904e553ee340903" }, - "mini.surround": { "branch": "main", "commit": "5aab42fcdcf31fa010f012771eda5631c077840a" }, + "mini.nvim": { "branch": "main", "commit": "57c16115a2af4af2e575942b469129ca4fcd9dbf" }, "neogen": { "branch": "main", "commit": "d7f9461727751fb07f82011051338a9aba07581d" }, "neoscroll.nvim": { "branch": "master", "commit": "f957373912e88579e26fdaea4735450ff2ef5c9c" }, "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, @@ -38,7 +32,6 @@ "nvim-ufo": { "branch": "main", "commit": "d31e2a9fd572a25a4d5011776677223a8ccb7e35" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, "promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" }, - "slimline.nvim": { "branch": "main", "commit": "37d197329b0a65af820e794a007553aa7ef387b5" }, "snacks.nvim": { "branch": "main", "commit": "bfe8c26dbd83f7c4fbc222787552e29b4eccfcc0" }, "tiny-code-action.nvim": { "branch": "main", "commit": "9b7359aca74875880a4f83034ded67325e47ef9b" }, "tiny-inline-diagnostic.nvim": { "branch": "main", "commit": "6d8dc61a9c4077d9ec62a9c8998506dcd2a5b6af" }, diff --git a/lua/plugins/editor.lua b/lua/plugins/editor.lua index 2dfce6e..75b3ff3 100644 --- a/lua/plugins/editor.lua +++ b/lua/plugins/editor.lua @@ -1,64 +1,4 @@ return { - -- surround actions - { - 'nvim-mini/mini.surround', - version = '*', - config = function() - require('mini.surround').setup() - end, - }, - - -- indent guides - { - 'nvim-mini/mini.indentscope', - event = 'VeryLazy', - config = function() - require('mini.indentscope').setup({ - draw = { - delay = 50, - animation = require('mini.indentscope').gen_animation.linear({ - ease = 'out', - duration = 15, - }), - }, - options = { - border = 'top', - try_as_border = true, - indent_at_cursor = false, - }, - }) - - -- disable for certain filetypes - vim.api.nvim_create_autocmd('BufEnter', { - pattern = '*', - callback = function(args) - if vim.bo[args.buf].buftype ~= '' then - vim.b[args.buf].miniindentscope_disable = true - end - end, - }) - end, - }, - - -- Go forward/backward with square brackets - { - 'echasnovski/mini.bracketed', - event = { 'BufReadPost', 'BufNewFile' }, - config = function() - require('mini.bracketed').setup() - end, - }, - - -- textobjects - { - 'nvim-mini/mini.ai', - version = '*', - config = function() - require('mini.ai').setup({ - silent = true, - }) - end, - }, -- Dimming the highlights of unused functions, variables, parameters, and more. { @@ -85,62 +25,62 @@ return { end, }, - { - 'numToStr/Comment.nvim', - version = false, - dependencies = { - 'JoosepAlviste/nvim-ts-context-commentstring', - }, - config = function() - require('Comment').setup({ - pre_hook = require('ts_context_commentstring.integrations.comment_nvim').create_pre_hook(), - mappings = { - basic = true, - extra = true, - }, - }) - end, - keys = { - { - 'gcc', - mode = 'n', - desc = 'Toggle comment line', - }, - { - 'gc', - mode = { 'n', 'o' }, - desc = 'Toggle comment linewise', - }, - { - 'gc', - mode = 'x', - desc = 'Toggle comment linewise (visual)', - }, - { - 'gbc', - mode = 'n', - desc = 'Toggle comment block', - }, - { - 'gb', - mode = { 'n', 'o' }, - desc = 'Toggle comment blockwise', - }, - { - 'gb', - mode = 'x', - desc = 'Toggle comment blockwise (visual)', - }, - { '/', "lua require('Comment.api').toggle.linewise.current()", desc = 'Toggle comment' }, - { - '/', - "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", - desc = 'Toggle comment', - mode = 'v', - }, - }, - opts = {}, - }, + -- { + -- 'numToStr/Comment.nvim', + -- version = false, + -- dependencies = { + -- 'JoosepAlviste/nvim-ts-context-commentstring', + -- }, + -- config = function() + -- require('Comment').setup({ + -- pre_hook = require('ts_context_commentstring.integrations.comment_nvim').create_pre_hook(), + -- mappings = { + -- basic = true, + -- extra = true, + -- }, + -- }) + -- end, + -- keys = { + -- { + -- 'gcc', + -- mode = 'n', + -- desc = 'Toggle comment line', + -- }, + -- { + -- 'gc', + -- mode = { 'n', 'o' }, + -- desc = 'Toggle comment linewise', + -- }, + -- { + -- 'gc', + -- mode = 'x', + -- desc = 'Toggle comment linewise (visual)', + -- }, + -- { + -- 'gbc', + -- mode = 'n', + -- desc = 'Toggle comment block', + -- }, + -- { + -- 'gb', + -- mode = { 'n', 'o' }, + -- desc = 'Toggle comment blockwise', + -- }, + -- { + -- 'gb', + -- mode = 'x', + -- desc = 'Toggle comment blockwise (visual)', + -- }, + -- { '/', "lua require('Comment.api').toggle.linewise.current()", desc = 'Toggle comment' }, + -- { + -- '/', + -- "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", + -- desc = 'Toggle comment', + -- mode = 'v', + -- }, + -- }, + -- opts = {}, + -- }, -- Todo Comments { diff --git a/lua/plugins/languages.lua b/lua/plugins/languages.lua index 368bf71..b4b752d 100644 --- a/lua/plugins/languages.lua +++ b/lua/plugins/languages.lua @@ -87,10 +87,10 @@ return { -- auto pairs { 'windwp/nvim-autopairs', + enabled = false, event = 'InsertEnter', config = function() local npairs = require('nvim-autopairs') - local Rule = require('nvim-autopairs.rule') npairs.setup({ check_ts = true, @@ -99,13 +99,6 @@ return { map_cr = true, map_bs = true, }) - - npairs.add_rules({ - Rule(' ', ' '):with_pair(function(opts) - local pair = opts.line:sub(opts.col - 1, opts.col) - return vim.tbl_contains({ '()', '[]', '{}', '""', "''", '``' }, pair) - end), - }) end, }, diff --git a/lua/plugins/mini.lua b/lua/plugins/mini.lua new file mode 100644 index 0000000..778668d --- /dev/null +++ b/lua/plugins/mini.lua @@ -0,0 +1,120 @@ +return { + 'echasnovski/mini.nvim', + config = function() + require('mini.ai').setup() + require('mini.surround').setup() + require('mini.pairs').setup() + require('mini.icons').setup() + require('mini.bracketed').setup() + require('mini.tabline').setup() + require('mini.indentscope').setup({ + draw = { + delay = 50, + animation = require('mini.indentscope').gen_animation.linear({ ease = 'out', duration = 15 }), + }, + options = { border = 'top', try_as_border = true, indent_at_cursor = false }, + }) + + vim.api.nvim_create_autocmd('BufEnter', { + pattern = '*', + callback = function(args) + if vim.bo[args.buf].buftype ~= '' then + vim.b[args.buf].miniindentscope_disable = true + end + end, + }) + + require('mini.comment').setup({ + options = { + custom_commentstring = function() + return require('ts_context_commentstring').calculate_commentstring() or vim.bo.commentstring + end, + }, + }) + + require('mini.statusline').setup({ + use_icons = true, + content = { + active = function() + 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 = 80 }) + local diagnostics = MiniStatusline.section_diagnostics({ trunc_width = 60 }) + local lsp = MiniStatusline.section_lsp({ trunc_width = 40 }) + local filename = MiniStatusline.section_filename({ trunc_width = 140 }) + + local function section_filetype(args) + if + MiniStatusline.is_truncated(args.trunc_width) + or vim.bo.filetype == '' + or vim.bo.buftype ~= '' + then + return '' + end + local ok, icons = pcall(require, 'mini.icons') + local icon = ok and select(1, icons.get('filetype', vim.bo.filetype)) or '' + return string.format('%s %s│', icon, vim.bo.filetype) + end + + local function section_lsp_clients(args) + if MiniStatusline.is_truncated(args.trunc_width) then + return '' + end + local clients = vim.lsp.get_clients({ bufnr = 0 }) + if not clients or #clients == 0 then + return '' + end + local names = vim.tbl_map(function(c) + return c.name + end, clients) + return string.format(' %s', table.concat(names, ', ')) + end + + local function section_searchcount(args) + if vim.v.hlsearch == 0 then + return '' + end + local ok, s = pcall(vim.fn.searchcount, { recompute = true }) + if not ok or s.current == nil or s.total == 0 then + return '' + end + local icon = MiniStatusline.is_truncated(args.trunc_width) and '' or ' ' + if s.incomplete == 1 then + return icon .. '?/?│' + end + local fmt = '>%d' + local cur = s.current > s.maxcount and fmt:format(s.maxcount) or s.current + local tot = s.total > s.maxcount and fmt:format(s.maxcount) or s.total + return ('%s%s/%s│'):format(icon, cur, tot) + end + + local function section_location(args) + return MiniStatusline.is_truncated(args.trunc_width) and '%-2l│%-2v' + or '󰉸 %-2l│󱥖 %-2v' + end + + local filetype = section_filetype({ trunc_width = 70 }) + local searchcount = section_searchcount({ trunc_width = 80 }) + local loc = section_location({ trunc_width = 120 }) + local lsp_clients = section_lsp_clients({ trunc_width = 60 }) + + return MiniStatusline.combine_groups({ + { hl = mode_hl, strings = { mode:upper() } }, + { hl = 'MiniStatuslineDevinfo', strings = { git, diff, diagnostics, lsp } }, + '%<', + { hl = 'MiniStatuslineFilename', strings = { filename } }, + '%=', + { hl = 'MiniStatuslineDevinfo', strings = { lsp_clients } }, + { hl = mode_hl, strings = { filetype, searchcount, loc } }, + }) + end, + + inactive = function() + return MiniStatusline.combine_groups({ + { hl = 'MiniStatuslineInactive', strings = { vim.fn.expand('%:t') } }, + }) + end, + }, + }) + end, +} diff --git a/lua/plugins/statusline.lua b/lua/plugins/statusline.lua deleted file mode 100644 index 0a29e5a..0000000 --- a/lua/plugins/statusline.lua +++ /dev/null @@ -1,32 +0,0 @@ -return { - { - 'sschleemilch/slimline.nvim', - opts = { - style = 'bg', - bold = true, - spaces = { - components = '', - left = '', - right = '', - }, - sep = { - hide = { - first = true, - last = true, - }, - left = '', - right = '', - }, - }, - }, - { - 'akinsho/bufferline.nvim', - opts = { - options = { - show_close_icon = false, - show_buffer_close_icons = false, - }, - }, - vim.api.nvim_set_hl(0, 'BufferLineFill', { bg = 'None' }), - }, -} diff --git a/lua/plugins/utility.lua b/lua/plugins/utility.lua index d5bac0a..090f0bb 100644 --- a/lua/plugins/utility.lua +++ b/lua/plugins/utility.lua @@ -1,11 +1,15 @@ return { - { - 'nvim-mini/mini.icons', - lazy = true, - opts = {}, + 'JoosepAlviste/nvim-ts-context-commentstring', + opts = { enable_autocmd = false }, + ft = { + 'javascript', + 'typescript', + 'javascriptreact', + 'typescriptreact', + }, + keys = { { 'gc', mode = { 'n', 'x' } }, { 'gbc', mode = { 'n', 'x' } } }, }, - --harpoon { 'ThePrimeagen/harpoon', @@ -92,7 +96,7 @@ return { shell = vim.o.shell, float_opts = { border = 'curved', -- 'single', 'double', 'shadow', etc. - winblend = 0, -- Set to 0 for full transparency + winblend = 0, -- Set to 0 for full transparency highlights = { border = 'Normal', background = 'Normal', @@ -123,16 +127,16 @@ return { picker_integration = true, keymaps = { prefix = 'u', -- Main prefix for uv commands - commands = true, -- Show uv commands menu (x) - run_file = true, -- Run current file (xr) + commands = true, -- Show uv commands menu (x) + run_file = true, -- Run current file (xr) run_selection = true, -- Run selected code (xs) - run_function = true, -- Run function (xf) - venv = true, -- Environment management (xe) - init = true, -- Initialize uv project (xi) - add = true, -- Add a package (xa) - remove = true, -- Remove a package (xd) - sync = true, -- Sync packages (xc) - sync_all = true, -- Sync all packages, extras and groups (xC) + run_function = true, -- Run function (xf) + venv = true, -- Environment management (xe) + init = true, -- Initialize uv project (xi) + add = true, -- Add a package (xa) + remove = true, -- Remove a package (xd) + sync = true, -- Sync packages (xc) + sync_all = true, -- Sync all packages, extras and groups (xC) }, }, },