Compare commits

...
2 Commits
Author SHA1 Message Date
octagonal 352f3e8280 add telescope usage 2026-11-22 17:27:47 +01:00
octagonal 3680ad5fa8 old multicurors until release 2026-11-22 17:25:32 +01:00
6 changed files with 159 additions and 13 deletions
-1
View File
@@ -2,4 +2,3 @@ require("config")
require("plugins")
require("vim._core.ui2").enable()
+5 -2
View File
@@ -49,6 +49,9 @@ vim.opt.smartindent = true
-- Makes <Tab> insert 'shiftwidth' number of spaces at the start of a line
vim.opt.smarttab = true
-- Copy indent from current line when starting a new lin
vim.opt.autoindent = true
-- Incremental and highlight search
vim.opt.hlsearch = false
vim.opt.incsearch = true
@@ -76,8 +79,8 @@ vim.keymap.set("n", "<C-d>", "<C-d>zz")
vim.keymap.set("n", "<C-u>", "<C-u>zz")
-- Center when moving
vim.keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv")
-- vim.keymap.set("n", "n", "nzzzv")
-- vim.keymap.set("n", "N", "Nzzzv")
vim.filetype.add({
extension = {
+1
View File
@@ -1,4 +1,5 @@
require("plugins.colorscheme")
require("plugins.multicursors")
require("plugins.telescope")
require("plugins.treesitter")
require("plugins.lsp")
+137
View File
@@ -0,0 +1,137 @@
vim.pack.add({ { src = 'https://github.com/jake-stewart/multicursor.nvim', version = 'native' } })
--[[
local ns = vim.api.nvim_create_namespace('nvim.multicursor')
local function word_pat()
local w = vim.fn.expand('<cword>')
if w == '' then return end
return '\\V\\<' .. vim.fn.escape(w, '\\') .. '\\>'
end
-- Moving the main cursor would drag every cursor along in follow mode,
-- so switch it off for the move, then re-enable it.
local function without_follow(fn)
vim.cmd('normal! 2q=')
fn()
vim.schedule(function() vim.cmd('normal! 1q=') end)
end
-- Add a cursor on the current word, then jump to the next/previous match
local function add_match(dir)
return function()
local pat = word_pat()
if not pat then return end
without_follow(function()
vim.fn.searchpos(pat, 'bcW') -- go to start of the word
vim.api.nvim_mcursor(0, vim.api.nvim_win_get_cursor(0))
vim.fn.searchpos(pat, dir > 0 and 'w' or 'bw')
end)
end
end
-- Jump to the next/previous match and remove the cursor sitting there
local function remove_match(dir)
return function()
local pat = word_pat()
if not pat then return end
without_follow(function()
local pos = vim.fn.searchpos(pat, dir > 0 and 'w' or 'bw')
local r, c = pos[1] - 1, pos[2] - 1
for _, m in ipairs(vim.api.nvim_buf_get_extmarks(0, ns, { r, c }, { r, c }, {})) do
vim.api.nvim_buf_del_extmark(0, ns, m[1])
end
end)
end
end
vim.keymap.set({ 'n' }, '<C-j>', add_match(1), { desc = 'MC: add cursor, next match' })
vim.keymap.set({ 'n' }, '<C-k>', add_match(-1), { desc = 'MC: add cursor, prev match' })
vim.keymap.set({ 'n' }, '<C-S-j>', remove_match(1), { desc = 'MC: remove cursor, next match' })
vim.keymap.set({ 'n' }, '<C-S-k>', remove_match(-1), { desc = 'MC: remove cursor, prev match' })
]] --
local mc = require("multicursor-nvim")
mc.setup({native = false})
local set = vim.keymap.set
-- Add or skip cursor above/below the main cursor.
set({ "n", "x" }, "<C-M-k>", function()
mc.lineAddCursor(-1)
end)
set({ "n", "x" }, "<C-M-j>", function()
mc.lineAddCursor(1)
end)
set({ "n", "x" }, "<C-M-S-k>", function()
mc.lineSkipCursor(-1)
end)
set({ "n", "x" }, "<C-M-S-j>", function()
mc.lineSkipCursor(1)
end)
-- Add or skip adding a new cursor by matching word/selection
set({ "n", "x" }, "<C-j>", function()
mc.matchAddCursor(1)
end)
set({ "n", "x" }, "<C-S-j>", function()
mc.matchSkipCursor(1)
end)
set({ "n", "x" }, "<C-k>", function()
mc.matchAddCursor(-1)
end)
set({ "n", "x" }, "<C-S-k>", function()
mc.matchSkipCursor(-1)
end)
-- Add and remove cursors with control + left click.
set("n", "<c-leftmouse>", mc.handleMouse)
set("n", "<c-leftdrag>", mc.handleMouseDrag)
set("n", "<c-leftrelease>", mc.handleMouseRelease)
-- Disable and enable cursors.
set({ "n", "x" }, "<c-q>", mc.toggleCursor)
-- Mappings defined in a keymap layer only apply when there are
-- multiple cursors. This lets you have overlapping mappings.
mc.addKeymapLayer(function(layerSet)
-- Select a different cursor as the main one.
layerSet({ "n", "x" }, "<left>", mc.prevCursor)
layerSet({ "n", "x" }, "<right>", mc.nextCursor)
-- Delete the main cursor.
layerSet({ "n", "x" }, "<leader>x", mc.deleteCursor)
-- Enable and clear cursors using escape.
layerSet("n", "<esc>", function()
if not mc.cursorsEnabled() then
mc.enableCursors()
else
mc.clearCursors()
end
end)
end)
-- Customize how cursors look.
local hl = vim.api.nvim_set_hl
hl(0, "MultiCursorCursor", { reverse = true, fg = "#aaaaff" })
hl(0, "MultiCursorVisual", { link = "Visual" })
hl(0, "MultiCursorSign", { link = "SignColumn" })
hl(0, "MultiCursorMatchPreview", { link = "Search" })
hl(0, "MultiCursorDisabledCursor", { reverse = true })
hl(0, "MultiCursorDisabledVisual", { link = "Visual" })
hl(0, "MultiCursorDisabledSign", { link = "SignColumn" })
-- Autocmds to change main cursor color when multicursors is active
vim.api.nvim_create_autocmd("User", {
pattern = "MultiCursorStart",
callback = function()
vim.api.nvim_set_hl(0, "Cursor", { bg = "#000000", fg = "#ffffff" }) -- bright red
end,
})
vim.api.nvim_create_autocmd("User", {
pattern = "MultiCursorExit",
callback = function()
vim.api.nvim_set_hl(0, "Cursor", { link = "Cursor" }) -- restore default
end,
})
+1
View File
@@ -18,6 +18,7 @@ vim.keymap.set("n", "<leader>pf", builtin.find_files, {})
vim.keymap.set("n", "<leader>pb", builtin.buffers, {})
vim.keymap.set("n", "<leader>ps", builtin.live_grep, {})
vim.keymap.set("n", "<leader>pd", builtin.diagnostics, {})
vim.keymap.set("n", "<leader>pu", builtin.lsp_references, {})
-- fzf
require("telescope").load_extension("fzf")
+15 -10
View File
@@ -5,7 +5,7 @@
"src": "https://github.com/numToStr/Comment.nvim"
},
"blink.cmp": {
"rev": "8219b58f1c11a2fb1644d3c7116c509fa8348ec0",
"rev": "eece1c590dc575d489589c95499ec3acbf004e42",
"src": "https://github.com/saghen/blink.cmp"
},
"blink.lib": {
@@ -29,7 +29,7 @@
"src": "https://github.com/folke/flash.nvim"
},
"gitsigns.nvim": {
"rev": "070a5d7b985546cc57e1fc61e5bc507fecac6045",
"rev": "1e9d0fbfe7ff848bc402d2c2e2854fb4eff2dce7",
"src": "https://github.com/lewis6991/gitsigns.nvim"
},
"lsp_lines.nvim": {
@@ -40,6 +40,10 @@
"rev": "9c60ec2279d62487d942ce095e49006af28eed6e",
"src": "https://github.com/rktjmp/lush.nvim"
},
"mc-cavallo.nvim": {
"rev": "1f3b6a1919f0c4b4c6149baa8eb77dfb8659557c",
"src": "https://github.com/colomb8/mc-cavallo.nvim"
},
"melange-nvim": {
"rev": "ce42f6b629beeaa00591ba73a77d3eeac4cf28ce",
"src": "https://github.com/savq/melange-nvim"
@@ -49,20 +53,21 @@
"src": "https://github.com/xero/miasma.nvim"
},
"mini.comment": {
"rev": "27a29d6b949b9497f80a0a03421e89fed71d8c37",
"rev": "3aa39b795c6dc54dbeaf2863aa91215850c4c8e0",
"src": "https://github.com/nvim-mini/mini.comment"
},
"mini.icons": {
"rev": "f642e3ba8c12afbc8f32f6d77ef6597eac56786f",
"rev": "eab3e692d796d78ea6ffc978d8a380ff26fcf4e3",
"src": "https://github.com/nvim-mini/mini.icons"
},
"mini.surround": {
"rev": "33a2ebe5df8eb4751828fcba133e18ed0fbbdfab",
"rev": "5357f00aca51a3b43e7775901b1ad9699f8c2678",
"src": "https://github.com/nvim-mini/mini.surround"
},
"multicursor.nvim": {
"rev": "704b99f10a72cc05d370cfeb294ff83412a8ab55",
"src": "https://github.com/jake-stewart/multicursor.nvim"
"rev": "0b14690211dc5a35cdda343c2ebfc7815bf23373",
"src": "https://github.com/jake-stewart/multicursor.nvim",
"version": "'native'"
},
"neogen": {
"rev": "23e7e9f883d01289ebd90e98025acc860ea26366",
@@ -73,7 +78,7 @@
"src": "https://github.com/rose-pine/neovim"
},
"nvim-lspconfig": {
"rev": "3e8d598d3b5f8338a41699c436e5fa11d2666cf0",
"rev": "d8d2fda7aae57030452ce8cd6e770b1eb704514e",
"src": "https://github.com/neovim/nvim-lspconfig"
},
"nvim-metals": {
@@ -81,12 +86,12 @@
"src": "https://github.com/scalameta/nvim-metals"
},
"nvim-treesitter": {
"rev": "910fdf6f49e9dee7e7257c7d11a76b040fdfb9de",
"rev": "a9c4e1457e2e59f1b82c8f78dcdb3b2517555200",
"src": "https://github.com/nvim-treesitter/nvim-treesitter",
"version": "'main'"
},
"oil.nvim": {
"rev": "b73018b75affd13fa38e2fc94ef753b465f770d7",
"rev": "d3733d933833a0e59b813ecec99341527adf0c28",
"src": "https://github.com/stevearc/oil.nvim"
},
"plenary.nvim": {