From 6b6ec87c90ecf16af682d04406149508a380a858 Mon Sep 17 00:00:00 2001 From: Michael Chalupiak Date: Sun, 3 May 2026 18:11:21 -0400 Subject: [PATCH] small overhaul of nvim --- .gitignore | 1 + config/.config/nvim/lua/config/keymap.lua | 38 +++- config/.config/nvim/lua/config/lsp.lua | 57 ++---- config/.config/nvim/lua/config/set.lua | 1 + config/.config/nvim/lua/plugins/lsp.lua | 9 - .../.config/nvim/lua/plugins/treesitter.lua | 67 ++----- config/.config/nvim/lua/plugins/ui.lua | 28 +-- config/.config/nvim/lua/plugins/util.lua | 187 ++++++++---------- 8 files changed, 160 insertions(+), 228 deletions(-) diff --git a/.gitignore b/.gitignore index b8e1e54..5650edb 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ config/.config/kak/plugins/* config/.config/mutt/chalupmc@rose-hulman config/.config/mutt/mikecchalupiak@outlook config/.config/mutt/spamreciver1@outlook +config/.config/nvim/lazy-lock.json config/.config/qt5ct/colors/* config/.config/qutebrowser/autoconfig.yml config/.config/qutebrowser/rosepine/* diff --git a/config/.config/nvim/lua/config/keymap.lua b/config/.config/nvim/lua/config/keymap.lua index ec504b5..04713e4 100644 --- a/config/.config/nvim/lua/config/keymap.lua +++ b/config/.config/nvim/lua/config/keymap.lua @@ -4,12 +4,44 @@ local setnx = function(key, command, desc) end setnx('ff', Snacks.picker.files, 'Find files') +setnx('fF', function() Snacks.picker.files({ dirs = { '.' }}) end, 'Find files in current dir') setnx('f/', Snacks.picker.grep_word, 'Search current word') setnx('fg', Snacks.picker.grep, 'Search in files') setnx('fr', Snacks.picker.recent, 'Find recent files') setnx('b', Snacks.picker.buffers, 'List buffers') setnx('h', Snacks.picker.help, 'Search help') -setnx('X', require'hex'.toggle, 'Toggle hex editor') +setnx('P', 'Markview splitToggle', 'Open markview preview') +setnx('z', Snacks.zen.zen, 'Toggle snacks zen mode') + +local setto = function(key, command, desc) + set({ 'x', 'o' }, key, command, { desc = desc }) +end +local setton = function(key, command, desc) + set({ 'n', 'x', 'o' }, key, command, { desc = desc }) +end +local select_to = function(query) + return function () + require'nvim-treesitter-textobjects.select'.select_textobject(query, "textobjects") + end +end +local move_next_start = function(query) + return function () + require'nvim-treesitter-textobjects.move'.goto_next_start(query, "textobjects") + end +end +local move_prev_start = function(query) + return function () + require'nvim-treesitter-textobjects.move'.goto_previous_start(query, "textobjects") + end +end + +setto('if', select_to("@function.inner"), 'Select inside function') +setto('af', select_to("@function.outer"), 'Select around function') +setto('ia', select_to("@parameter.inner"), 'Select inside parameter') +setto('aa', select_to("@parameter.outer"), 'Select around parameter') +setton(']p', move_next_start("@parameter.inner"), 'Goto next parameter') +setton('[p', move_prev_start("@parameter.inner"), 'Goto previous parameter') + setnx('m', Snacks.picker.marks, 'Search marks') setnx('q', Snacks.picker.qflist, 'Search quickfix list') setnx('l', Snacks.picker.loclist, 'Search location list') @@ -48,8 +80,8 @@ setnx('`', '\'', 'Goto mark without column') setnx('x', 'bd!', 'Close Current Buffer') setnx('grr', Snacks.picker.lsp_references, 'Search lsp references') --- setnx('grI', tele.lsp_incoming_calls, 'Find incoming function calls') --- setnx('grO', tele.lsp_outgoing_calls, 'Find outgoing function calls') +setnx('grI', Snacks.picker.lsp_incoming_calls, 'Find incoming function calls') +setnx('grO', Snacks.picker.lsp_outgoing_calls, 'Find outgoing function calls') setnx('grd', Snacks.picker.diagnostics, 'Show LSP diagnostics') setnx('grD', (function() local diag = true diff --git a/config/.config/nvim/lua/config/lsp.lua b/config/.config/nvim/lua/config/lsp.lua index e284bae..e911d7a 100644 --- a/config/.config/nvim/lua/config/lsp.lua +++ b/config/.config/nvim/lua/config/lsp.lua @@ -8,41 +8,22 @@ vim.api.nvim_create_autocmd('LspAttach', { end }) --- vim.lsp.config('rust-analyzer', { --- settings = { --- ["rust-analyzer"] = { --- inlayHints = { --- bindingModeHints = { --- enable = false, --- }, --- chainingHints = { --- enable = true, --- }, --- closingBraceHints = { --- enable = true, --- minLines = 25, --- }, --- closureReturnTypeHints = { --- enable = "never", --- }, --- lifetimeElisionHints = { --- enable = "never", --- useParameterNames = false, --- }, --- maxLength = 25, --- parameterHints = { --- enable = true, --- }, --- reborrowHints = { --- enable = "never", --- }, --- renderColons = true, --- typeHints = { --- enable = true, --- hideClosureInitialization = false, --- hideNamedConstructor = false, --- }, --- }, --- } --- } --- }) +vim.lsp.config('lua_ls', { + settings = { + Lua = { + workspace = { + library = vim.api.nvim_get_runtime_file("", true), + maxPreload = 100000, + preloadFileSize = 100000, + } + } + } +}) + +vim.lsp.config('tinymist', { + settings = { + exportPdf = "onType", + }, +}) + +vim.diagnostic.config({ update_in_insert = true, float = true, virtual_lines = true}) diff --git a/config/.config/nvim/lua/config/set.lua b/config/.config/nvim/lua/config/set.lua index b4390be..99f67cd 100644 --- a/config/.config/nvim/lua/config/set.lua +++ b/config/.config/nvim/lua/config/set.lua @@ -14,6 +14,7 @@ vim.opt.winborder = 'none' vim.opt.smartindent = true +vim.opt.foldlevel = 9999 -- vim.opt.spell = true vim.opt.spelllang = 'en_us' diff --git a/config/.config/nvim/lua/plugins/lsp.lua b/config/.config/nvim/lua/plugins/lsp.lua index 4a1a089..acae229 100644 --- a/config/.config/nvim/lua/plugins/lsp.lua +++ b/config/.config/nvim/lua/plugins/lsp.lua @@ -21,15 +21,6 @@ return { }, }, - -- { - -- "MysticalDevil/inlay-hints.nvim", - -- event = "LspAttach", - -- dependencies = { "neovim/nvim-lspconfig" }, - -- config = function() - -- require("inlay-hints").setup() - -- end - -- }, - -- { 'saghen/blink.cmp', -- optional: provides snippets for the snippet source diff --git a/config/.config/nvim/lua/plugins/treesitter.lua b/config/.config/nvim/lua/plugins/treesitter.lua index 5d5da80..e351ee8 100644 --- a/config/.config/nvim/lua/plugins/treesitter.lua +++ b/config/.config/nvim/lua/plugins/treesitter.lua @@ -1,66 +1,39 @@ return { { - 'nvim-treesitter/nvim-treesitter', - -- branch = 'main', + 'neovim-treesitter/nvim-treesitter', + dependencies = { 'neovim-treesitter/treesitter-parser-registry' }, + branch = 'main', version = false, lazy = false, build = ':TSUpdate', config = function() - require'nvim-treesitter.configs'.setup { - textobjects = { - select = { - enable = true, - lookahead = true, - keymaps = { - ["af"] = "@function.outer", - ["if"] = "@function.inner", - } - }, - move = { - enable = true, - set_jumps = false, - goto_next_start = { - [']a'] = '@parameter.inner', - }, - goto_previous_start = { - ['[a'] = '@parameter.inner', - } - }, - }, - auto_install = true, - highlight = { - enable = true, - }, - } + local langs = require'nvim-treesitter'.get_installed('parsers') + vim.api.nvim_create_autocmd('FileType', { + pattern = langs, + callback = function() + vim.treesitter.start() -- highlighting + vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()' -- folds + vim.wo.foldmethod = 'expr' + vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" -- indentation + end, + }) end }, { 'nvim-treesitter/nvim-treesitter-textobjects', + branch = 'main', + opts = { + select = { + lookahead = true, + } + } }, - -- { - -- 'folke/twilight.nvim', - -- dependencies = { - -- 'nvim-treesitter/nvim-treesitter', - -- }, - -- cmd = { - -- 'Twilight', - -- 'TwilightEnable', - -- 'TwilightDisable', - -- }, - -- }, - - -- { - -- 'RRethy/vim-illuminate', - -- event = 'VeryLazy', - -- lazy = false, - -- }, - { '0oAstro/dim.lua', dependencies = { - 'nvim-treesitter/nvim-treesitter', + 'neovim-treesitter/nvim-treesitter', 'neovim/nvim-lspconfig' }, event = 'LspAttach', diff --git a/config/.config/nvim/lua/plugins/ui.lua b/config/.config/nvim/lua/plugins/ui.lua index 67c0cbe..de77385 100644 --- a/config/.config/nvim/lua/plugins/ui.lua +++ b/config/.config/nvim/lua/plugins/ui.lua @@ -5,30 +5,12 @@ return { event = 'VeryLazy', }, - -- { - -- 'lukas-reineke/indent-blankline.nvim', - -- event = 'VeryLazy', - -- config = function() - -- require'ibl'.setup{ scope = { enabled = false } } - -- end - -- }, - { 'nvim-tree/nvim-web-devicons', -- event = 'VeryLazy', lazy = true, }, - -- { - -- 'goolord/alpha-nvim', - -- dependencies = { - -- 'nvim-tree/nvim-web-devicons', - -- }, - -- config = function() - -- require('alpha').setup(require'alpha.themes.startify'.config) - -- end - -- }, - { 'lewis6991/gitsigns.nvim', event = 'VeryLazy', @@ -37,9 +19,9 @@ return { } }, - { - 'Bekaboo/dropbar.nvim', - }, + -- { + -- 'Bekaboo/dropbar.nvim', + -- }, { 'nvim-lualine/lualine.nvim', @@ -52,8 +34,8 @@ return { for i, server in pairs(vim.lsp.get_clients({ bufnr = 0 })) do table.insert(names, server.name) end - return " [" .. table.concat(names, " ") .. "]" - -- return "[" .. table.concat(names, " ") .. "]" + -- return " [" .. table.concat(names, " ") .. "]" + return "[" .. table.concat(names, " ") .. "]" end require('lualine').setup { options = { diff --git a/config/.config/nvim/lua/plugins/util.lua b/config/.config/nvim/lua/plugins/util.lua index 59c14b5..da2e3e1 100644 --- a/config/.config/nvim/lua/plugins/util.lua +++ b/config/.config/nvim/lua/plugins/util.lua @@ -1,21 +1,4 @@ return { - - { - 'nvim-lua/plenary.nvim', - -- event = 'VeryLazy', - lazy = true, - }, - - { - 'RaafatTurki/hex.nvim', - config = true, - cmd = { - 'HexDump', - 'HexAssemble', - 'HexToggle', - }, - }, - { "sindrets/diffview.nvim", event = 'VeryLazy', @@ -33,7 +16,6 @@ return { "NeogitOrg/neogit", lazy = true, dependencies = { - "nvim-lua/plenary.nvim", -- required "sindrets/diffview.nvim", -- optional - Diff integration -- Only one of these is needed. @@ -44,6 +26,14 @@ return { }, }, + { + "OXY2DEV/markview.nvim", + lazy = false, + + -- Completion for `blink.cmp` + dependencies = { "saghen/blink.cmp" }, + }, + { 'vieitesss/command.nvim', lazy = false, @@ -51,12 +41,6 @@ return { opts = {}, }, - - { - 'glacambre/firenvim', - build = ":call firenvim#install(0)" - }, - { 'brenoprata10/nvim-highlight-colors', event = 'VeryLazy', @@ -92,7 +76,29 @@ return { -- or leave it empty to use the default settings -- refer to the configuration section below bigfile = { enabled = true }, - -- dashboard = { enabled = true }, + dashboard = { + enabled = true, + presets = { + }, + formats = { + key = function(item) + return { { "[", hl = "special" }, { item.key, hl = "key" }, { "]", hl = "special" } } + end, + }, + sections = { + -- { section = "terminal", cmd = "fortune -s | cowsay", hl = "header", padding = 1, indent = 8 }, + { section = "header" }, + { section = "startup" }, + { title = "MRU", padding = 1 }, + { section = "recent_files", limit = 8, padding = 1 }, + { title = "MRU ", file = vim.fn.fnamemodify(".", ":~"), padding = 1 }, + { section = "recent_files", cwd = true, limit = 8, padding = 1 }, + { title = "Sessions", padding = 1 }, + { section = "projects", padding = 1 }, + { title = "Bookmarks", padding = 1 }, + { section = "keys" }, + }, + }, dim = { enabled = true }, -- explorer = { enabled = true }, -- git = { enabled = false }, @@ -113,92 +119,57 @@ return { }, notifier = { enabled = true }, -- quickfile = { enabled = true }, - -- scope = { enabled = true }, + scope = { enabled = true }, -- scroll = { enabled = true }, terminal = { enabled = false }, -- statuscolumn = { enabled = true }, - -- words = { enabled = true }, + words = { enabled = true }, + zen = { + enabled = true, + -- toggles = { + -- git_signs = true, + -- }, + win = { + backdrop = { + transparent = false, + blend = 99, + }, + }, + }, }, }, { - 'echasnovski/mini.nvim', - config = function() - require('mini.starter').setup() - -- require('mini.cursorword').setup() - local miniclue = require'mini.clue' - miniclue.setup{ - window = { - delay = 0, - config = { - width = 'auto', - }, - }, - triggers = { - -- Leader triggers - { mode = 'n', keys = '' }, - { mode = 'x', keys = '' }, - - -- Built-in completion - { mode = 'i', keys = '' }, - - -- `g` key - { mode = 'n', keys = 'g' }, - { mode = 'x', keys = 'g' }, - - -- Next - { mode = 'n', keys = '['}, - { mode = 'n', keys = ']'}, - { mode = 'x', keys = '['}, - { mode = 'x', keys = ']'}, - - -- Marks - { mode = 'n', keys = "'" }, - { mode = 'n', keys = '`' }, - { mode = 'x', keys = "'" }, - { mode = 'x', keys = '`' }, - - -- Registers - { mode = 'n', keys = '"' }, - { mode = 'x', keys = '"' }, - { mode = 'i', keys = '' }, - { mode = 'c', keys = '' }, - - -- Window commands - { mode = 'n', keys = '' }, - - -- `z` key - { mode = 'n', keys = 'z' }, - { mode = 'x', keys = 'z' }, - - -- Localleader - { mode = 'n', keys = ''}, - { mode = 'x', keys = ''}, - }, - - clues = { - -- Enhance this by adding descriptions for mapping groups - miniclue.gen_clues.builtin_completion(), - miniclue.gen_clues.g(), - miniclue.gen_clues.marks(), - miniclue.gen_clues.registers(), - miniclue.gen_clues.windows(), - miniclue.gen_clues.z(), - - { mode = 'n', keys = 'f', desc = '+Find' }, - { mode = 'x', keys = 'f', desc = '+Find' }, - - { mode = 'n', keys = 'o', desc = '+Open' }, - { mode = 'x', keys = 'o', desc = '+Open' }, - - { mode = 'n', keys = 'g', desc = '+Git' }, - { mode = 'x', keys = 'g', desc = '+Git' }, - - { mode = 'n', keys = 'c', desc = '+Compile' }, - { mode = 'x', keys = 'c', desc = '+Compile' }, - }, - } - end + "folke/which-key.nvim", + event = "VeryLazy", + opts = { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + preset = 'helix', + sort = { "order", "alphanum", "local", "mod" }, + win = { + border = 'none', + }, + icons = { + rules = false, + }, + spec = { + { 'f', group = 'Find' }, + { 'o', group = 'Open' }, + { 'g', group = 'Git' }, + { 'c', group = 'Compile' }, + }, + }, + keys = { + { + "?", + function() + require("which-key").show({ global = false }) + end, + desc = "Buffer Local Keymaps (which-key)", + }, + }, }, { @@ -302,19 +273,19 @@ return { -- Add cursor at next argument treesitter set({'n', 'x'}, ']A', function() if vim.v.count < 1 then - mc.addCursor(']a') + mc.addCursor(']p') else for _=1, vim.v.count - 1 do - mc.addCursor(']a') + mc.addCursor(']p') end end end, { desc = 'Create multicursor on next argument'}) set({'n', 'x'}, '[A', function() if vim.v.count < 1 then - mc.addCursor('[a') + mc.addCursor('[p') else for _=1, vim.v.count - 1 do - mc.addCursor('[a') + mc.addCursor('[p') end end end, { desc = 'Create multicursor on previous argument'})