diff options
Diffstat (limited to 'config/essentials/vis/visrc.lua')
-rw-r--r-- | config/essentials/vis/visrc.lua | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/config/essentials/vis/visrc.lua b/config/essentials/vis/visrc.lua new file mode 100644 index 0000000..a424613 --- /dev/null +++ b/config/essentials/vis/visrc.lua @@ -0,0 +1,84 @@ +------------------------------------ +--- LIBRARIES +------------------------------------ + +require('vis') +require('plugins/vis-cursors') +require('plugins/vis-title') + +------------------------------------ +--- EVENTS +------------------------------------ + +vis.events.subscribe(vis.events.INIT, function() + vis.options.ignorecase = true + vis.options.autoindent = true + vis.options.shell = "/bin/sh" + theme = "nord" + vis:command("set theme " .. theme) +end) + +vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused args + win.options.relativenumbers = true +end) + +------------------------------------ +--- FUNCTIONS +------------------------------------ + +function map_cmd(mode, map, command, help) + vis:map(mode, map, function() + vis:command(command) + end, help) +end + +function map_cmd_restore(mode, map, command, help) + vis:map(mode, map, function() + if (mode == vis.modes.INSERT) then + vis:feedkeys("<Escape>") + end + + vis:feedkeys("m") + vis:command(command) + vis:feedkeys("M") + + if (mode == vis.modes.INSERT) then + vis:feedkeys("i") + end + end, help) +end + +------------------------------------ +--- VARIABLES +------------------------------------ + +local m = vis.modes + +------------------------------------ +--- COMMANDS +------------------------------------ + +vis:command_register("Q", function(argv, force, win, selection, range) + vis:command("qa!") +end, "Quit all") + +------------------------------------- +--- MAPPINGS +------------------------------------- + +map_cmd_restore(m.NORMAL, " r", "e $vis_filepath", "Reload active file") + +map_cmd(m.NORMAL, " c", "e ~/.config/vis/visrc.lua", "Edit config file") +map_cmd(m.NORMAL, " q", "q!", "Quit (force)") +map_cmd(m.NORMAL, " s", "!doas vis $vis_filepath", "Edit as superuser") +map_cmd(m.NORMAL, " w", "w", "Write") +map_cmd(m.NORMAL, " x", "!chmod u+x $vis_filepath", "Make active file executable") + +vis:map(m.NORMAL, " eh", function() + vis:command("!lowdown $vis_filepath > ${vis_filepath%.md}.html") + vis:info("exported.") +end, "Export markdown to html") +vis:map(m.NORMAL, " nl", function() vis:feedkeys(":<seq -f '%0.0f. ' 1 ") end, "Insert numbered list") + + +-- select markdown list element: ,x/^(\d+\.|[-*])\s+.+\n(^ .+\n)*/ |