summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorsteven-na <noreply.github@stvnc.dev>2026-06-01 23:48:47 -0700
committersteven-na <noreply.github@stvnc.dev>2026-06-01 23:48:47 -0700
commit77f8963a603824f3f67ebadfe085b10b9026f378 (patch)
tree90a6164ab55cfb9357af968ee4a2807a20c65a37 /arch
parent50949088826979a289850fd809d5e87a6b341527 (diff)
Update nvim conf
Diffstat (limited to 'arch')
-rw-r--r--arch/lightvim/.config/lightvim/lua/plugins.lua133
1 files changed, 116 insertions, 17 deletions
diff --git a/arch/lightvim/.config/lightvim/lua/plugins.lua b/arch/lightvim/.config/lightvim/lua/plugins.lua
index b6af099..d9b563b 100644
--- a/arch/lightvim/.config/lightvim/lua/plugins.lua
+++ b/arch/lightvim/.config/lightvim/lua/plugins.lua
@@ -98,16 +98,60 @@ return {
},
{
"jake-stewart/multicursor.nvim",
- branch = "1.0",
event = "VeryLazy",
config = function()
local mc = require("multicursor-nvim")
mc.setup()
- vim.keymap.set({ "n", "v" }, "<C-S-Right>", function() mc.lineAddCursor(1) end, { desc = "Add cursor down" })
- vim.keymap.set({ "n", "v" }, "<C-S-Left>", function() mc.lineAddCursor(-1) end, { desc = "Add cursor up" })
- vim.keymap.set({ "n", "v" }, "<leader>mA", mc.matchAllAddCursors, { desc = "Cursors for all matches" })
- vim.keymap.set({ "n", "v" }, "<leader>mn", function() mc.matchAddCursor(1) end, { desc = "Add cursor next match" })
- vim.keymap.set("n", "<esc>", function()
+ local set = vim.keymap.set
+ local nv = { "n", "v" }
+
+ -- 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
@@ -119,23 +163,78 @@ return {
end,
},
- -- === Treesitter ===
+ -- === Treesitter (main branch, nvim 0.11+ API) ===
{
"nvim-treesitter/nvim-treesitter",
+ branch = "main",
+ lazy = false,
build = ":TSUpdate",
- event = { "BufReadPre", "BufNewFile" },
- opts = {
- ensure_installed = {
+ dependencies = {
+ { "nvim-treesitter/nvim-treesitter-textobjects", branch = "main" },
+ },
+ 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",
- },
- highlight = { enable = true },
- indent = { enable = true },
- auto_install = false,
- },
- config = function(_, opts)
- require("nvim-treesitter").setup(opts)
+ }
+ 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,
+ })
+
+ -- Textobjects ---------------------------------------------------
+ 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,
},