Skip to content

Commit

Permalink
feat(editing-support): add vim-visual-multi (#797)
Browse files Browse the repository at this point in the history
* feat(editing-support): add vim-visual-multi

* Apply suggestions from code review

Co-authored-by: Micah Halter <micah@mehalter.com>

---------

Co-authored-by: Micah Halter <micah@mehalter.com>
  • Loading branch information
wroyca and mehalter committed Mar 11, 2024
1 parent 1507af5 commit 6c79f4a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lua/astrocommunity/editing-support/vim-visual-multi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# vim-visual-multi

Multiple cursors plugin for vim/neovim.

**Repository:** <https://github.com/mg979/vim-visual-multi>
32 changes: 32 additions & 0 deletions lua/astrocommunity/editing-support/vim-visual-multi/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
return {
"mg979/vim-visual-multi",
event = { "User AstroFile", "InsertEnter" },
dependencies = {
"astronvim/astrocore",
---@param opts astrocoreopts
opts = function(_, opts)
if not opts.options then opts.options = {} end
if not opts.options.g then opts.options.g = {} end
opts.options.g.VM_silent_exit = 1
opts.options.g.VM_show_warnings = 0

if not opts.autocmds then opts.autocmds = {} end
opts.autocmds.visual_multi_exit = {
{
event = "User",
pattern = "visual_multi_exit",
desc = "Avoid spurious 'hit-enter-prompt' when exiting vim-visual-multi",
callback = function()
vim.o.cmdheight = 1
vim.schedule(function() vim.o.cmdheight = opts.options.opt.cmdheight end)
end,
},
}

if not opts.mappings then opts.mappings = require("astrocore").empty_map_table() end
local maps = assert(opts.mappings)
maps.n["<C-up>"] = { "<C-u>call vm#commands#add_cursor_up(0, v:count1)<cr>", desc = "Add cursor above" }
maps.n["<C-down>"] = { "<C-u>call vm#commands#add_cursor_down(0, v:count1)<cr>", desc = "Add cursor below" }
end,
},
}

0 comments on commit 6c79f4a

Please sign in to comment.