From c9e48695c579cb0e2bf5f3b09a3e26bd068b3bcf Mon Sep 17 00:00:00 2001 From: Anton Date: Sat, 5 Jul 2025 09:33:28 +0200 Subject: [PATCH] feat(nvim): clean and trim config --- .config/nvim/after/ftplugin/markdown.lua | 2 + .config/nvim/lazy-lock.json | 13 +- .config/nvim/lua/BluePlum/lazy.lua | 32 +++++ .config/nvim/lua/plugins/additions.lua | 29 ----- .config/nvim/lua/plugins/deco.lua | 22 ++-- .config/nvim/lua/plugins/emacs.lua | 47 ------- .config/nvim/lua/plugins/fold.lua | 64 ---------- .config/nvim/lua/plugins/format.lua | 153 ++++++++++------------- .config/nvim/lua/plugins/lsp.lua | 27 ++-- .config/nvim/lua/plugins/nav.lua | 47 +++---- .config/nvim/lua/plugins/theme.lua | 66 +++++----- .config/nvim/lua/plugins/treesitter.lua | 27 ++-- 12 files changed, 182 insertions(+), 347 deletions(-) create mode 100644 .config/nvim/after/ftplugin/markdown.lua delete mode 100644 .config/nvim/lua/plugins/emacs.lua delete mode 100644 .config/nvim/lua/plugins/fold.lua diff --git a/.config/nvim/after/ftplugin/markdown.lua b/.config/nvim/after/ftplugin/markdown.lua new file mode 100644 index 0000000..ac51d87 --- /dev/null +++ b/.config/nvim/after/ftplugin/markdown.lua @@ -0,0 +1,2 @@ +vim.wo.wrap = false +vim.opt.expandtab = true diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 9b01736..a474c8a 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,28 +1,19 @@ { - "actions-preview.nvim": { "branch": "master", "commit": "36513ad213855d497b7dd3391a24d1d75d58e36f" }, "blink.cmp": { "branch": "main", "commit": "9bcb14b43852a6f2bfd5ac9ef29cb5cf09b1b39b" }, - "compile-mode.nvim": { "branch": "main", "commit": "8dff8d8472363e01499a4e8cc02f5f5595ce3922" }, "cord.nvim": { "branch": "master", "commit": "a4484bb25e343a375d95b250ffadbdcbfbfdf2ac" }, - "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "flash.nvim": { "branch": "develop", "commit": "045457978f3fb7df03efa2023dbc8a5f6e9179bd" }, "formatter.nvim": { "branch": "master", "commit": "b9d7f853da1197b83b8edb4cc4952f7ad3a42e41" }, - "gruber-darker.nvim": { "branch": "main", "commit": "a2dda61d9c1225e16951a51d6b89795b0ac35cd6" }, - "inc-rename.nvim": { "branch": "main", "commit": "a3e31af13844534c66041ce92f29af7745883875" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "markview.nvim": { "branch": "main", "commit": "d5d37102d24c3d5d032b01263855081b6850509b" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" }, "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, "mini.icons": { "branch": "main", "commit": "94848dad1589a199f876539bd79befb0c5e3abf0" }, - "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, - "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, - "nvim-ufo": { "branch": "main", "commit": "4c64d89c2bf174d95d4ac91cc959a9e43e2f318c" }, - "nvim-web-devicons": { "branch": "master", "commit": "19d6211c78169e78bab372b585b6fb17ad974e82" }, + "nvim-treesitter": { "branch": "main", "commit": "dafb3cb3cb066774526c1103f3d1d6b34578800b" }, "oil.nvim": { "branch": "master", "commit": "bbad9a76b2617ce1221d49619e4e4b659b3c61fc" }, "oxocarbon.nvim": { "branch": "main", "commit": "acdfdd5d319c36170b5ad2a120283bec2f450081" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "smear-cursor.nvim": { "branch": "main", "commit": "4a0f7ac265b4ed1ce4d0af2afc13072763bfa691" }, "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, - "vim-fugitive": { "branch": "master", "commit": "593f831d6f6d779cbabb70a4d1e6b1b1936a88af" }, - "vim-grepper": { "branch": "master", "commit": "acaaf32edaa11d82fb972d2af36b949ec3042928" } + "vim-fugitive": { "branch": "master", "commit": "593f831d6f6d779cbabb70a4d1e6b1b1936a88af" } } diff --git a/.config/nvim/lua/BluePlum/lazy.lua b/.config/nvim/lua/BluePlum/lazy.lua index 2ab2251..da16cf6 100644 --- a/.config/nvim/lua/BluePlum/lazy.lua +++ b/.config/nvim/lua/BluePlum/lazy.lua @@ -29,4 +29,36 @@ function M.bootstrap() return require('lazy') end +M.icons = 'echasnovski/mini.icons' +M.icons_require = function() + return require('mini.icons') +end + +--- @enum PlenaryModule +local _ = { + async = 'async', + async_lib = 'async_lib', + job = 'job', + path = 'path', + scandir = 'scandir', + context_manager = 'context_manager', + test_harness = 'test_harness', + filetype = 'filetype', + strings = 'strings', +} + +--- @param module PlenaryModule +M.plenary_require = function(module) + return require('plenary.' .. module) +end +M.plenary = 'nvim-lua/plenary.nvim' + +--- @enum +M.event = { + BufEnter = 'BufEnter', + BufWinEnter = 'BufWinEnter', + BufWritePost = 'BufWritePost', + VeryLazy = 'VeryLazy', +} + return M diff --git a/.config/nvim/lua/plugins/additions.lua b/.config/nvim/lua/plugins/additions.lua index 08951a5..05222a9 100644 --- a/.config/nvim/lua/plugins/additions.lua +++ b/.config/nvim/lua/plugins/additions.lua @@ -1,28 +1,4 @@ return { - { - 'smjonas/inc-rename.nvim', - keys = { { - 'cn', - ':IncRename ', - } }, - config = function() - require('inc_rename').setup({}) - end, - }, - { - 'aznhe21/actions-preview.nvim', - keys = { { - 'ca', - function() - require('actions-preview').code_actions() - end, - } }, - opts = {}, - -- config = function() - -- require('actions-preview').setup({}) - -- vim.keymap.set('n', 'ca', require('actions-preview').code_actions) - -- end, - }, { 'vyfor/cord.nvim', event = 'VeryLazy', @@ -33,9 +9,4 @@ return { 'tpope/vim-fugitive', cmd = { 'Git' }, }, - { - 'mhinz/vim-grepper', - cmd = { 'GrepperRg' }, - opts = {}, - }, } diff --git a/.config/nvim/lua/plugins/deco.lua b/.config/nvim/lua/plugins/deco.lua index f7483de..0ffe3de 100644 --- a/.config/nvim/lua/plugins/deco.lua +++ b/.config/nvim/lua/plugins/deco.lua @@ -1,22 +1,22 @@ +local common = require('BluePlum.lazy') + return { - { 'nvim-tree/nvim-web-devicons' }, - { 'stevearc/dressing.nvim', opts = {} }, + { common.icons, opts = {} }, { 'folke/todo-comments.nvim', dependencies = { 'nvim-lua/plenary.nvim' }, - config = function() - require('todo-comments').setup() - end, + opts = {}, + event = common.event.BufWinEnter, }, - { 'norcalli/nvim-colorizer.lua', opts = {} }, { 'OXY2DEV/markview.nvim', - dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, + dependencies = { 'nvim-treesitter/nvim-treesitter', common.icons }, ft = 'markdown', - config = function() - require('markview') - vim.api.nvim_set_hl(0, 'MarkviewLayer', { fg = '#2a2a2a', bg = '#373737' }) - end, + opts = { + preview = { + icon_provider = 'mini', + }, + }, }, { 'sphamba/smear-cursor.nvim', diff --git a/.config/nvim/lua/plugins/emacs.lua b/.config/nvim/lua/plugins/emacs.lua deleted file mode 100644 index 44b2dfe..0000000 --- a/.config/nvim/lua/plugins/emacs.lua +++ /dev/null @@ -1,47 +0,0 @@ -return { - { - 'ej-shafran/compile-mode.nvim', - enabled = false, - dependencies = { - 'nvim-lua/plenary.nvim', - 'm00qek/baleia.nvim', - }, - config = function() - vim.api.nvim_set_hl(0, 'CompileModeInfo', { link = 'DiagnosticInfo' }) - vim.api.nvim_set_hl(0, 'CompileModeWarning', { link = 'DiagnosticWarning' }) - vim.api.nvim_set_hl(0, 'CompileModeError', { link = 'DiagnosticError' }) - - vim.api.nvim_set_hl(0, 'CompileModeCommandOutput', { link = 'Statement' }) - vim.api.nvim_set_hl(0, 'CompileModeMessage', { link = 'SpellCap' }) - vim.api.nvim_set_hl(0, 'CompileModeMessageRow', { link = 'CursorLineNr' }) - vim.api.nvim_set_hl(0, 'CompileModeMessageCol', { link = 'CursorLineNr' }) - - vim.g.compile_mode = { - baleia_setup = true, - } - end, - }, - -- { - -- dir = '~/dev/s-ido', - -- name = 's-ido', - -- lazy = false, - -- dev = true, - -- opts = {}, - -- keys = { - -- { - -- '', - -- function() - -- require('s-ido.commandline').complete() - -- end, - -- mode = 'c', - -- }, - -- }, - -- }, - -- { - -- dir = '~/dev/s-nav', - -- name = 's-nav', - -- lazy = false, - -- dev = true, - -- opts = {}, - -- }, -} diff --git a/.config/nvim/lua/plugins/fold.lua b/.config/nvim/lua/plugins/fold.lua deleted file mode 100644 index 2e0727c..0000000 --- a/.config/nvim/lua/plugins/fold.lua +++ /dev/null @@ -1,64 +0,0 @@ -return { - { - 'kevinhwang91/nvim-ufo', - dependencies = { - { - 'kevinhwang91/promise-async', - }, - }, - enabled = false, - config = function() - -- Implement custom marker provider. - local CustomMarkerProvider = {} - - function CustomMarkerProvider.getFolds(bufnr) - local buf = require('ufo.bufmanager'):get(bufnr) - if not buf then - return - end - - local openRegex = '#region' - local closeRegex = '#endregion' - - local summaryRegx = openRegex .. '%s*(.*)' - - local ranges = {} - local stack = {} - local lines = buf:lines(1, -1) - - for lnum, line in ipairs(lines) do - -- Check for start marker - if line:match(openRegex) then - table.insert(stack, lnum) - -- Check for end marker - elseif line:match(closeRegex) then - local startLnum = table.remove(stack) - if startLnum then - local summary = lines[startLnum]:match(summaryRegx) - table.insert(ranges, require('ufo.model.foldingrange').new(startLnum - 1, lnum - 1, summary)) - end - end - end - - return ranges - end - - local function customizeSelector(bufnr) - local ranges = CustomMarkerProvider.getFolds(bufnr) - local maybe_additional_ranges = require('ufo').getFolds(bufnr, 'treesitter') - if next(maybe_additional_ranges) ~= nil then - ranges = vim.list_extend(ranges, maybe_additional_ranges) - else - ranges = vim.list_extend(ranges, require('ufo').getFolds(bufnr, 'indent')) - end - return ranges - end - - require('ufo').setup({ - provider_selector = function(bufnr, filetype, buftype) - return customizeSelector - end, - }) - end, - }, -} diff --git a/.config/nvim/lua/plugins/format.lua b/.config/nvim/lua/plugins/format.lua index 86601c0..41115a7 100644 --- a/.config/nvim/lua/plugins/format.lua +++ b/.config/nvim/lua/plugins/format.lua @@ -1,97 +1,74 @@ +local common = require('BluePlum.lazy') + +---@param exe string +---@param args { [number]: string, path: boolean? } +local function formatter(exe, args) + return { + function() + local argv = {} + + for _, val in ipairs(args) do + table.insert(argv, val) + end + + if not args.path == false then + table.insert(argv, vim.fn.shellescape(vim.api.nvim_buf_get_name(0))) + end + + return { + exe = exe, + args = argv, + stdin = true, + } + end, + } +end + +local prettier = formatter('prettier', { + '--config-precedence prefer-file', + '--single-quote', + '--use-tabs', + '--trailing-comma es5', + '--bracket-same-line', + '--stdin-filepath', +}) + return { { 'mhartington/formatter.nvim', - event = 'BufWritePost', - config = function() - local util = require('formatter.util') + event = common.event.BufWritePost, + opts = { + filetype = { + javascript = prettier, + typescript = prettier, + markdown = prettier, + css = prettier, + json = prettier, + html = prettier, + scss = prettier, + rust = formatter('rustfmt', { path = false }), + lua = formatter('stylua', { + '--indent-type Tabs', + '--line-endings Unix', + '--quote-style AutoPreferSingle', + '--column-width' .. ' ' .. vim.o.columns, + '-', + }), - local function prettier() - return { - exe = 'prettier', - args = { - '--config-precedence', - 'prefer-file', - '--single-quote', - '--use-tabs', - '--trailing-comma', - 'es5', - '--bracket-same-line', - '--insert-pragma', - '--stdin-filepath', - vim.fn.shellescape(vim.api.nvim_buf_get_name(0)), - }, - stdin = true, - } - end - - require('formatter').setup({ - filetype = { - javascript = { - prettier, - }, - typescript = { - prettier, - }, - markdown = { - prettier, - }, - css = { - prettier, - }, - json = { - prettier, - }, - html = { - prettier, - }, - scss = { - prettier, - }, - rust = { - function() - return { - exe = 'rustfmt', - args = {}, - stdin = false, - } - end, - }, - - lua = { - function() - return { - exe = 'stylua', - args = { - '--indent-type', - 'Tabs', - '--line-endings', - 'Unix', - '--quote-style', - 'AutoPreferSingle', - '--column-width', - vim.api.nvim_command_output('echo &columns'), - '-', - }, - stdin = true, - } - end, - }, - ['*'] = { - function() - if vim.lsp.buf.formatting then - vim.lsp.buf.format() - end - end, - }, + ['*'] = { + function() + if vim.lsp.buf.formatting then + vim.lsp.buf.format() + end + end, }, - }) + }, + }, + config = function(lazy) + require('formatter').setup(lazy.opts) - local augroup = vim.api.nvim_create_augroup - local autocmd = vim.api.nvim_create_autocmd - augroup('__formatter__', { - clear = true, - }) - autocmd('BufWritePost', { + vim.api.nvim_create_augroup('__formatter__', { clear = true }) + vim.api.nvim_create_autocmd(common.event.BufWritePost, { group = '__formatter__', command = ':FormatWriteLock', }) diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua index 6171475..0d24112 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua @@ -1,14 +1,4 @@ -local blink_methods = { - icon = function(ctx) - local icon, _, _ = require('mini.icons').get('lsp', ctx.kind) - return icon - end, - highlight = function(ctx) - local _, hi, _ = require('mini.icons').get('lsp', ctx.kind) - vim.print(hi) - return hi - end, -} +local common = require('BluePlum.lazy') return { -- Mason @@ -20,10 +10,10 @@ return { ensure_installed = { 'lua_ls', 'rust_analyzer' }, }, config = function(lazy) - local mlspconfig = require('mason-lspconfig') + local mason_lspconfig = require('mason-lspconfig') - mlspconfig.setup(lazy.opts) - mlspconfig.setup_handlers({ + mason_lspconfig.setup(lazy.opts) + mason_lspconfig.setup_handlers({ vim.lsp.enable, }) end, @@ -34,9 +24,7 @@ return { { 'Saghen/blink.cmp', - dependencies = { - 'echasnovski/mini.icons', - }, + dependencies = { common.icons }, version = '1.*', build = 'cargo build --release', opts = { @@ -67,7 +55,10 @@ return { columns = { { 'kind_icon' }, { 'label', 'label_description', gap = 1 }, { 'kind' } }, components = { kind_icon = { - text = blink_methods.icon, + text = function(ctx) + local icon, _, _ = common.icons_require().get('lsp', ctx.kind) + return icon + end, }, kind = { text = function(ctx) diff --git a/.config/nvim/lua/plugins/nav.lua b/.config/nvim/lua/plugins/nav.lua index f718673..0967a05 100644 --- a/.config/nvim/lua/plugins/nav.lua +++ b/.config/nvim/lua/plugins/nav.lua @@ -1,31 +1,27 @@ +local common = require('BluePlum.lazy') +local telescope = { + find_files = function() + require('telescope.builtin').find_files({ show_hidden = true }) + end, + live_grep = function() + require('telescope.builtin').live_grep() + end, + buffers = function() + require('telescope.builtin').buffers() + end, +} + return { - -- Telescope { 'nvim-telescope/telescope.nvim', - dependencies = { 'nvim-lua/plenary.nvim' }, + dependencies = { common.plenary }, keys = { - { - 'ff', - function() - require('telescope.builtin').find_files({ show_hidden = true }) - end, - }, - { - 'fs', - function() - require('telescope.builtin').live_grep() - end, - }, - { - 'bb', - function() - require('telescope.builtin').buffers() - end, - }, + { 'ff', telescope.find_files }, + { 'fs', telescope.live_grep }, + { 'bb', telescope.buffers }, }, }, - -- Oil { 'stevearc/oil.nvim', opts = { @@ -36,18 +32,13 @@ return { }, lazy = false, keys = { - { - 'ex', - function() - vim.cmd('Oil') - end, - }, + { 'ex', vim.cmd.Oil }, }, }, { 'Kaiser-Yang/flash.nvim', branch = 'develop', - event = 'VeryLazy', + event = common.event.VeryLazy, opts = { modes = { char = { diff --git a/.config/nvim/lua/plugins/theme.lua b/.config/nvim/lua/plugins/theme.lua index ec99214..eae34be 100644 --- a/.config/nvim/lua/plugins/theme.lua +++ b/.config/nvim/lua/plugins/theme.lua @@ -1,47 +1,41 @@ return { - { - 'blazkowolf/gruber-darker.nvim', - priority = 999, - config = function() - vim.cmd.colorscheme('gruber-darker') - end, - enabled = false, - }, { 'nyoom-engineering/oxocarbon.nvim', priority = 999, config = function() vim.cmd.colorscheme('oxocarbon') - local function hi(c, link) - vim.api.nvim_set_hl(0, 'BlinkCmpKind' .. c, { link = link }) - end + local groups = { + Text = 'Identifier', + Method = '@function.builtin', + Function = 'Function', + Constructor = '@character', + Field = '@property', + Variable = '@label', + Class = 'Todo', + Interface = 'Type', + Module = 'Macro', + Property = '@property', + Unit = 'Type', + Value = 'Number', + Enum = 'String', + Keyword = 'Identifier', + Snippet = 'Identifier', + Color = 'Identifier', + File = 'Identifier', + Folder = 'identifier', + Reference = 'Identifier', + EnumMember = 'String', + Constant = '@constant.builtin', + Struct = 'Type', + Event = '@constant', + Operator = 'Structure', + TypeParameter = 'Type', + } - hi('Text', 'Identifier') - hi('Method', '@function.builtin') - hi('Function', 'Function') - hi('Constructor', '@character') - hi('Field', '@property') - hi('Variable', '@label') - hi('Class', 'Todo') - hi('Interface', 'Type') - hi('Module', 'Macro') - hi('Property', '@property') - hi('Unit', 'Type') - hi('Value', 'Number') - hi('Enum', 'String') - hi('Keyword', 'Identifier') - hi('Snippet', 'Identifier') - hi('Color', 'Identifier') - hi('File', 'Identifier') - hi('Folder', 'identifier') - hi('Reference', 'Identifier') - hi('EnumMember', 'String') - hi('Constant', '@constant.builtin') - hi('Struct', 'Type') - hi('Event', '@constant') - hi('Operator', 'Structure') - hi('TypeParameter', 'Type') + for key, value in pairs(groups) do + vim.api.nvim_set_hl(0, 'BlinkCmpKind' .. key, { link = value }) + end vim.api.nvim_set_hl(0, 'BlinkCmpMenuSelection', { link = 'IncSearch' }) end, diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua index c16d672..170e53f 100644 --- a/.config/nvim/lua/plugins/treesitter.lua +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -1,22 +1,19 @@ +local common = require('BluePlum.lazy') + return { - -- Highlighting { 'nvim-treesitter/nvim-treesitter', - -- enabled = false, - event = 'VeryLazy', - config = function() - vim.cmd('TSUpdate') - require('nvim-treesitter.configs').setup({ - ensure_installed = { 'lua', 'markdown', 'typescript', 'javascript', 'rust', 'json', 'toml' }, + branch = 'main', + event = common.event.VeryLazy, + build = ':TSUpdate', + opts = { + ensure_installed = { 'lua', 'markdown', 'typescript', 'javascript', 'rust', 'json', 'toml' }, - highlight = { - enable = true, - }, + highlight = { + enable = true, + }, - auto_install = true, - - -- additional_vim_regex_highlighting = true, - }) - end, + auto_install = true, + }, }, }