diff options
Diffstat (limited to 'arch/bigvim/.config')
| -rw-r--r-- | arch/bigvim/.config/bigvim/lazy-lock.json | 9 | ||||
| -rw-r--r-- | arch/bigvim/.config/bigvim/lua/keymaps.lua | 8 | ||||
| -rw-r--r-- | arch/bigvim/.config/bigvim/lua/plugins/actions_preview.lua | 11 | ||||
| -rw-r--r-- | arch/bigvim/.config/bigvim/lua/plugins/editor.lua | 46 | ||||
| -rw-r--r-- | arch/bigvim/.config/bigvim/lua/plugins/linting.lua | 34 | ||||
| -rw-r--r-- | arch/bigvim/.config/bigvim/lua/plugins/lsp.lua | 1 | ||||
| -rw-r--r-- | arch/bigvim/.config/bigvim/lua/plugins/mason.lua | 5 | ||||
| -rw-r--r-- | arch/bigvim/.config/bigvim/lua/plugins/multicursor.lua | 84 | ||||
| -rw-r--r-- | arch/bigvim/.config/bigvim/lua/plugins/treesitter.lua | 91 | ||||
| -rw-r--r-- | arch/bigvim/.config/bigvim/lua/plugins/whichkey.lua | 1 |
10 files changed, 230 insertions, 60 deletions
diff --git a/arch/bigvim/.config/bigvim/lazy-lock.json b/arch/bigvim/.config/bigvim/lazy-lock.json index fdd24c3..e2cdb07 100644 --- a/arch/bigvim/.config/bigvim/lazy-lock.json +++ b/arch/bigvim/.config/bigvim/lazy-lock.json @@ -1,5 +1,6 @@ { "LuaSnip": { "branch": "master", "commit": "a62e1083a3cfe8b6b206e7d3d33a51091df25357" }, + "actions-preview.nvim": { "branch": "master", "commit": "0ac9c2aa3cfc8c885321c0862b50b6b1c3392405" }, "blink.cmp": { "branch": "main", "commit": "78336bc89ee5365633bcf754d93df01678b5c08f" }, "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, "conform.nvim": { "branch": "master", "commit": "dca1a190aa85f9065979ef35802fb77131911106" }, @@ -7,19 +8,19 @@ "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, "fzf-lua": { "branch": "main", "commit": "b437bafc981a180d609bb4092c56ce8999f7a2c4" }, "gitsigns.nvim": { "branch": "main", "commit": "6d808f99bd63303646794406e270bd553ad7792e" }, - "hardtime.nvim": { "branch": "main", "commit": "b4e431934af1fe224a3a801f632c008278cb7628" }, - "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" }, "lazydev.nvim": { "branch": "main", "commit": "ff2cbcba459b637ec3fd165a2be59b7bbaeedf0d" }, "leap.nvim": { "branch": "main", "commit": "156c71aabb68d520c6269db4103c8e5580e3ea67" }, "lualine.nvim": { "branch": "master", "commit": "131a558e13f9f28b15cd235557150ccb23f89286" }, - "mini.animate": { "branch": "main", "commit": "0365de8b69331c25d0d0d7573407a7dc7719e578" }, + "mason.nvim": { "branch": "main", "commit": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d" }, "mini.base16": { "branch": "main", "commit": "800f107b27a00978b0dadd672d6da21a5b12fa9a" }, - "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "multicursor.nvim": { "branch": "main", "commit": "704b99f10a72cc05d370cfeb294ff83412a8ab55" }, "nvim-autopairs": { "branch": "master", "commit": "59bce2eef357189c3305e25bc6dd2d138c1683f5" }, "nvim-lint": { "branch": "master", "commit": "eab58b48eb11d7745c11c505e0f3057165902461" }, "nvim-lspconfig": { "branch": "master", "commit": "31026a13eefb20681124706a79fc1df6bf11ab27" }, "nvim-surround": { "branch": "main", "commit": "61319d4bd1c5e336e197defa15bd104c51f0fb29" }, "nvim-treesitter": { "branch": "main", "commit": "4916d6592ede8c07973490d9322f187e07dfefac" }, + "nvim-treesitter-textobjects": { "branch": "main", "commit": "851e865342e5a4cb1ae23d31caf6e991e1c99f1e" }, "nvim-ufo": { "branch": "main", "commit": "ab3eb124062422d276fae49e0dd63b3ad1062cfc" }, "nvim-web-devicons": { "branch": "master", "commit": "4fc505ac7bd7692824a142e96e5f529c133862f8" }, "oil.nvim": { "branch": "master", "commit": "0fcc83805ad11cf714a949c98c605ed717e0b83e" }, diff --git a/arch/bigvim/.config/bigvim/lua/keymaps.lua b/arch/bigvim/.config/bigvim/lua/keymaps.lua index 2a38a95..a6779b0 100644 --- a/arch/bigvim/.config/bigvim/lua/keymaps.lua +++ b/arch/bigvim/.config/bigvim/lua/keymaps.lua @@ -31,10 +31,10 @@ map("n", "<leader>se", "<C-w>=", { desc = "Equal splits" }) map("n", "<leader>sx", "<cmd>close<CR>", { desc = "Close split" }) -- Move lines -map("n", "<A-Down>", "<cmd>m .+1<CR>==", { desc = "Move line down" }) -map("n", "<A-Up>", "<cmd>m .-2<CR>==", { desc = "Move line up" }) -map("v", "<A-Down>", ":m '>+1<CR>gv=gv", { desc = "Move selection down" }) -map("v", "<A-Up>", ":m '<-2<CR>gv=gv", { desc = "Move selection up" }) +map("n", "<C-S-Down>", "<cmd>m .+1<CR>==", { desc = "Move line down" }) +map("n", "<C-S-Up>", "<cmd>m .-2<CR>==", { desc = "Move line up" }) +map("v", "<C-S-Down>", ":m '>+1<CR>gv=gv", { desc = "Move selection down" }) +map("v", "<C-S-Up>", ":m '<-2<CR>gv=gv", { desc = "Move selection up" }) -- Stay in visual after indent map("v", "<", "<gv") diff --git a/arch/bigvim/.config/bigvim/lua/plugins/actions_preview.lua b/arch/bigvim/.config/bigvim/lua/plugins/actions_preview.lua new file mode 100644 index 0000000..1ee3abc --- /dev/null +++ b/arch/bigvim/.config/bigvim/lua/plugins/actions_preview.lua @@ -0,0 +1,11 @@ +return { + "aznhe21/actions-preview.nvim", + keys = { + { + "<leader>ca", + function() require("actions-preview").code_actions() end, + mode = { "n", "v" }, + desc = "Code action", + }, + }, +} diff --git a/arch/bigvim/.config/bigvim/lua/plugins/editor.lua b/arch/bigvim/.config/bigvim/lua/plugins/editor.lua index a6ec0e0..8e1a3c5 100644 --- a/arch/bigvim/.config/bigvim/lua/plugins/editor.lua +++ b/arch/bigvim/.config/bigvim/lua/plugins/editor.lua @@ -7,29 +7,6 @@ return { { "S", "<Plug>(leap-from-window)", mode = { "n", "o" }, desc = "Leap from window" }, }, }, - -- Enforce good vim habits - { - "m4xshen/hardtime.nvim", - event = "VeryLazy", - dependencies = { "MunifTanjim/nui.nvim" }, - opts = { - max_count = 4, - -- Remove arrows from disabled (completely blocked) and add to - -- restricted (blocked after max_count, same as hjkl) - disabled_keys = { - ["<Up>"] = {}, - ["<Down>"] = {}, - ["<Left>"] = {}, - ["<Right>"] = {}, - }, - restricted_keys = { - ["<Up>"] = { "n", "x" }, - ["<Down>"] = { "n", "x" }, - ["<Left>"] = { "n", "x" }, - ["<Right>"] = { "n", "x" }, - }, - }, - }, -- Auto-close brackets/quotes { "windwp/nvim-autopairs", @@ -63,11 +40,30 @@ return { end, }, }, - -- Surround text objects: ys, ds, cs + -- Surround text objects (gz* keymaps) { "kylechui/nvim-surround", version = "*", event = "VeryLazy", - opts = {}, + init = function() + vim.g.nvim_surround_no_insert_mappings = true + vim.g.nvim_surround_no_normal_mappings = true + vim.g.nvim_surround_no_visual_mappings = true + end, + config = function() + require("nvim-surround").setup({}) + local map = vim.keymap.set + map("i", "<C-g>z", "<Plug>(nvim-surround-insert)", { desc = "Surround (insert)" }) + map("i", "<C-g>Z", "<Plug>(nvim-surround-insert-line)", { desc = "Surround line (insert)" }) + map("n", "gza", "<Plug>(nvim-surround-normal)", { desc = "Add surround" }) + map("n", "gzaa", "<Plug>(nvim-surround-normal-cur)", { desc = "Add surround (curline)" }) + map("n", "gzA", "<Plug>(nvim-surround-normal-line)", { desc = "Add surround (linewise)" }) + map("n", "gzAA", "<Plug>(nvim-surround-normal-cur-line)", { desc = "Add surround line (cur)" }) + map("n", "gzd", "<Plug>(nvim-surround-delete)", { desc = "Delete surround" }) + map("n", "gzc", "<Plug>(nvim-surround-change)", { desc = "Change surround" }) + map("n", "gzC", "<Plug>(nvim-surround-change-line)", { desc = "Change surround (linewise)" }) + map("x", "gz", "<Plug>(nvim-surround-visual)", { desc = "Surround selection" }) + map("x", "gZ", "<Plug>(nvim-surround-visual-line)", { desc = "Surround selection (linewise)" }) + end, }, } diff --git a/arch/bigvim/.config/bigvim/lua/plugins/linting.lua b/arch/bigvim/.config/bigvim/lua/plugins/linting.lua index bbbeaa7..a53af9f 100644 --- a/arch/bigvim/.config/bigvim/lua/plugins/linting.lua +++ b/arch/bigvim/.config/bigvim/lua/plugins/linting.lua @@ -2,8 +2,40 @@ return { "mfussenegger/nvim-lint", event = { "BufReadPost", "BufWritePost", "InsertLeave" }, config = function() + -- local cppcheck = require("lint").linters.cppcheck + -- + -- -- Let nvim-lint append the current file normally. + -- cppcheck.append_fname = true + -- + -- cppcheck.args = { + -- "--enable=warning,style,performance,information", + -- function() + -- -- Detect language from the actual file extension, not + -- -- vim.bo.filetype -- Neovim's heuristic for ambiguous .h + -- -- files often resolves to "cpp" regardless of content. + -- local bufname = vim.api.nvim_buf_get_name(0) + -- local ext = bufname:match("%.([^.]+)$") or "" + -- local cpp_exts = { cpp = true, cc = true, cxx = true, hpp = true, hh = true, hxx = true } + -- if cpp_exts[ext] then + -- return "--language=c++" + -- end + -- return "--language=c" + -- end, + -- "--inline-suppr", + -- "--quiet", + -- "--suppress=missingIncludeSystem", + -- "--suppress=unmatchedSuppression", + -- "--suppress=checkersReport", + -- function() + -- if vim.fn.isdirectory("build") == 1 then + -- return "--cppcheck-build-dir=build" + -- end + -- end, + -- "--template={file}:{line}:{column}: [{id}] {severity}: {message}", + -- } + require("lint").linters_by_ft = { - c = { "cppcheck" }, + -- c = { "cppcheck" }, cpp = { "cppcheck" }, python = { "ruff" }, } diff --git a/arch/bigvim/.config/bigvim/lua/plugins/lsp.lua b/arch/bigvim/.config/bigvim/lua/plugins/lsp.lua index 76566d1..b933650 100644 --- a/arch/bigvim/.config/bigvim/lua/plugins/lsp.lua +++ b/arch/bigvim/.config/bigvim/lua/plugins/lsp.lua @@ -68,7 +68,6 @@ return { map("gI", vim.lsp.buf.implementation, "Goto implementation") map("K", vim.lsp.buf.hover, "Hover docs") map("<leader>rn", vim.lsp.buf.rename, "Rename") - map("<leader>ca", vim.lsp.buf.code_action, "Code action") map("[d", vim.diagnostic.goto_prev, "Prev diagnostic") map("]d", vim.diagnostic.goto_next, "Next diagnostic") map("<leader>e", vim.diagnostic.open_float, "Show diagnostic") diff --git a/arch/bigvim/.config/bigvim/lua/plugins/mason.lua b/arch/bigvim/.config/bigvim/lua/plugins/mason.lua new file mode 100644 index 0000000..10fafd9 --- /dev/null +++ b/arch/bigvim/.config/bigvim/lua/plugins/mason.lua @@ -0,0 +1,5 @@ +return { + "williamboman/mason.nvim", + cmd = { "Mason", "MasonInstall", "MasonUninstall", "MasonUpdate", "MasonLog" }, + opts = {}, +} diff --git a/arch/bigvim/.config/bigvim/lua/plugins/multicursor.lua b/arch/bigvim/.config/bigvim/lua/plugins/multicursor.lua new file mode 100644 index 0000000..2ee4954 --- /dev/null +++ b/arch/bigvim/.config/bigvim/lua/plugins/multicursor.lua @@ -0,0 +1,84 @@ +return { + "jake-stewart/multicursor.nvim", + event = "VeryLazy", + config = function() + local mc = require("multicursor-nvim") + mc.setup() + local nv = { "n", "v" } + + -- Bind everything via a function so we can re-apply per-buffer + -- (oil buffers set their own buffer-local maps that would otherwise + -- shadow these globals). + local function bind(buf) + local opts_base = buf and { buffer = buf } or {} + local function set(mode, lhs, rhs, opts) + local o = vim.tbl_extend("force", opts_base, opts or {}) + vim.keymap.set(mode, lhs, rhs, o) + end + + -- Adding cursors (Alt+Shift+arrow — Ctrl+Shift+arrow is move-line) + set(nv, "<M-S-Down>", function() mc.lineAddCursor(1) end, { desc = "Add cursor down" }) + set(nv, "<M-S-Up>", function() mc.lineAddCursor(-1) end, { desc = "Add cursor up" }) + + -- Skipping (advance without dropping a cursor) + set(nv, "<leader>m<Down>", function() mc.lineSkipCursor(1) end, { desc = "Skip line down" }) + set(nv, "<leader>m<Up>", function() mc.lineSkipCursor(-1) end, { desc = "Skip line up" }) + + -- Match-based add / skip + set(nv, "<leader>mn", function() mc.matchAddCursor(1) end, { desc = "Add cursor: next match" }) + set(nv, "<leader>mp", function() mc.matchAddCursor(-1) end, { desc = "Add cursor: prev match" }) + set(nv, "<leader>ms", function() mc.matchSkipCursor(1) end, { desc = "Skip match, advance" }) + set(nv, "<leader>mA", mc.matchAllAddCursors, { desc = "Cursors for all matches" }) + + -- Repeat keys: ;/, add or skip when cursors active; default f/F/t/T otherwise + set("n", ";", function() + if mc.hasCursors() then mc.matchAddCursor(1) else vim.cmd("normal! ;") end + end, { desc = "Repeat f/F/t/T · next-match cursor when active" }) + set("n", ",", function() + if mc.hasCursors() then mc.matchSkipCursor(1) else vim.cmd("normal! ,") end + end, { desc = "Reverse f/F/t/T · skip-match when active" }) + + -- Manual toggle / delete + set(nv, "<leader>mt", mc.toggleCursor, { desc = "Toggle cursor here" }) + set(nv, "<leader>mx", mc.deleteCursor, { desc = "Delete cursor under main" }) + + -- Rotate / jump main focus through cursor list (arrows) + set(nv, "<leader>m<Right>", mc.nextCursor, { desc = "Rotate to next cursor" }) + set(nv, "<leader>m<Left>", mc.prevCursor, { desc = "Rotate to prev cursor" }) + set(nv, "<leader>mF", mc.firstCursor, { desc = "Jump to first cursor" }) + set(nv, "<leader>mL", mc.lastCursor, { desc = "Jump to last cursor" }) + + -- Bulk ops + set(nv, "<leader>m=", mc.alignCursors, { desc = "Align cursors" }) + set(nv, "<leader>mu", mc.restoreCursors, { desc = "Restore last cursors" }) + set(nv, "<leader>md", function() + if mc.cursorsEnabled() then mc.disableCursors() else mc.enableCursors() end + end, { desc = "Freeze/unfreeze cursors" }) + set(nv, "<leader>m.", function() mc.transposeCursors(1) end, { desc = "Transpose forward" }) + set(nv, "<leader>m,", function() mc.transposeCursors(-1) end, { desc = "Transpose back" }) + + -- Pattern-based (visual mode — needs a selection) + set("x", "<leader>m/", mc.matchCursors, { desc = "Cursors at regex matches" }) + set("x", "<leader>mS", mc.splitCursors, { desc = "Split selection by pattern" }) + + -- Esc: re-enable / clear / nohlsearch + set("n", "<esc>", function() + if not mc.cursorsEnabled() then + mc.enableCursors() + elseif mc.hasCursors() then + mc.clearCursors() + else + vim.cmd("nohlsearch") + end + end) + end + + bind(nil) + + -- Re-bind buffer-local for oil so its keymaps don't shadow ours. + vim.api.nvim_create_autocmd("FileType", { + pattern = "oil", + callback = function(args) bind(args.buf) end, + }) + end, +} diff --git a/arch/bigvim/.config/bigvim/lua/plugins/treesitter.lua b/arch/bigvim/.config/bigvim/lua/plugins/treesitter.lua index 348eaba..97dfa42 100644 --- a/arch/bigvim/.config/bigvim/lua/plugins/treesitter.lua +++ b/arch/bigvim/.config/bigvim/lua/plugins/treesitter.lua @@ -1,31 +1,72 @@ return { "nvim-treesitter/nvim-treesitter", + branch = "main", + lazy = false, build = ":TSUpdate", - event = { "BufReadPre", "BufNewFile" }, - opts = { - ensure_installed = { - "c", - "cpp", - "python", - "lua", - "haskell", - "vim", - "vimdoc", - "query", - "bash", - "markdown", - "markdown_inline", - "json", - "toml", - "yaml", - "odin", - }, - highlight = { enable = true }, - indent = { enable = true }, - auto_install = false, + dependencies = { + { "nvim-treesitter/nvim-treesitter-textobjects", branch = "main" }, }, - config = function(_, opts) - -- new API, configs module is gone - require("nvim-treesitter").setup(opts) + config = function() + require("nvim-treesitter").setup({}) + + local parsers = { + "c", "cpp", "python", "lua", "haskell", "rust", "odin", + "vim", "vimdoc", "query", "bash", "diff", + "markdown", "markdown_inline", "json", "toml", "yaml", + } + require("nvim-treesitter").install(parsers) + + vim.api.nvim_create_autocmd("FileType", { + callback = function(args) + local lang = vim.treesitter.language.get_lang(vim.bo[args.buf].filetype) + if lang and vim.treesitter.language.add(lang) then + pcall(vim.treesitter.start, args.buf, lang) + vim.bo[args.buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + end + end, + }) + + local ok_to, to = pcall(require, "nvim-treesitter-textobjects") + if not ok_to then return end + to.setup({ + select = { lookahead = true }, + move = { set_jumps = true }, + }) + local sel = require("nvim-treesitter-textobjects.select") + local move = require("nvim-treesitter-textobjects.move") + local swap = require("nvim-treesitter-textobjects.swap") + local map = vim.keymap.set + + local objs = { + { "af", "@function.outer", "around function" }, + { "if", "@function.inner", "inside function" }, + { "ac", "@class.outer", "around class" }, + { "ic", "@class.inner", "inside class" }, + { "aa", "@parameter.outer", "around argument" }, + { "ia", "@parameter.inner", "inside argument" }, + { "ab", "@block.outer", "around block" }, + { "ib", "@block.inner", "inside block" }, + { "ai", "@conditional.outer", "around conditional" }, + { "ii", "@conditional.inner", "inside conditional" }, + { "al", "@loop.outer", "around loop" }, + { "il", "@loop.inner", "inside loop" }, + } + for _, o in ipairs(objs) do + local lhs, q, d = o[1], o[2], o[3] + map({ "x", "o" }, lhs, function() sel.select_textobject(q, "textobjects") end, { desc = d }) + end + + local nmo = { "n", "x", "o" } + map(nmo, "]m", function() move.goto_next_start("@function.outer", "textobjects") end, { desc = "next func start" }) + map(nmo, "[m", function() move.goto_previous_start("@function.outer", "textobjects") end, { desc = "prev func start" }) + map(nmo, "]M", function() move.goto_next_end("@function.outer", "textobjects") end, { desc = "next func end" }) + map(nmo, "[M", function() move.goto_previous_end("@function.outer", "textobjects") end, { desc = "prev func end" }) + map(nmo, "]]", function() move.goto_next_start("@class.outer", "textobjects") end, { desc = "next class start" }) + map(nmo, "[[", function() move.goto_previous_start("@class.outer", "textobjects") end, { desc = "prev class start" }) + map(nmo, "][", function() move.goto_next_end("@class.outer", "textobjects") end, { desc = "next class end" }) + map(nmo, "[]", function() move.goto_previous_end("@class.outer", "textobjects") end, { desc = "prev class end" }) + + map("n", "<leader>a", function() swap.swap_next("@parameter.inner") end, { desc = "Swap arg with next" }) + map("n", "<leader>A", function() swap.swap_previous("@parameter.inner") end, { desc = "Swap arg with prev" }) end, } diff --git a/arch/bigvim/.config/bigvim/lua/plugins/whichkey.lua b/arch/bigvim/.config/bigvim/lua/plugins/whichkey.lua index 97e8b19..e9afa04 100644 --- a/arch/bigvim/.config/bigvim/lua/plugins/whichkey.lua +++ b/arch/bigvim/.config/bigvim/lua/plugins/whichkey.lua @@ -10,6 +10,7 @@ return { { "<leader>s", group = "split" }, { "<leader>r", group = "refactor" }, { "<leader>c", group = "code" }, + { "<leader>m", group = "multicursor" }, { "<leader>cF", desc = "Toggle autoformat" }, { "<leader>cf", desc = "Format buffer" }, { "<leader>e", desc = "File explorer" }, |