summaryrefslogtreecommitdiff
path: root/config/essentials/vis/visrc.lua
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2024-06-20 22:30:24 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2024-06-20 22:30:24 +0200
commit3d099d5157ce479b6a15e30ff2efbe1ee0d377c3 (patch)
treec015e0fc9322fef2c5f2d826d9b4e2a4761a8ee3 /config/essentials/vis/visrc.lua
parent41d3ecdd5245c8c3f8adaa76bbdca24eacd9e007 (diff)
checkpoint
Diffstat (limited to 'config/essentials/vis/visrc.lua')
-rw-r--r--config/essentials/vis/visrc.lua69
1 files changed, 42 insertions, 27 deletions
diff --git a/config/essentials/vis/visrc.lua b/config/essentials/vis/visrc.lua
index 81e09eb..05df7ee 100644
--- a/config/essentials/vis/visrc.lua
+++ b/config/essentials/vis/visrc.lua
@@ -3,50 +3,41 @@
------------------------------------
require('vis')
-require('plugins')
-------------------------------------
---- EVENTS
-------------------------------------
+-- plugins
+require("backup")
+require("cursors")
+require("title")
-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)
+local map_cmd = function(mode, map, command, help)
+ vis:map(mode, map, function() vis:command(command) end, help)
end
-function map_cmd_restore(mode, map, command, help)
+local map_cmd_restore = function(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
end, help)
end
+local map_keys = function(mode, map, keys, help)
+ vis:map(mode, map, function() vis:feedkeys(keys) end, help)
+end
+
------------------------------------
--- VARIABLES
------------------------------------
@@ -55,11 +46,9 @@ local m = vis.modes
------------------------------------
--- COMMANDS
-------------------------------------
+-----------------------------------
-vis:command_register("Q", function(argv, force, win, selection, range)
- vis:command("qa!")
-end, "Quit all")
+vis:command_register("Q", function() vis:command("qa!") end, "Quit all")
-------------------------------------
--- MAPPINGS
@@ -77,7 +66,33 @@ 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")
+map_keys(m.NORMAL, " nl", ":<seq -f '%0.0f. ' 1 ", "Insert numbered list")
+map_keys(m.NORMAL, " ws", ":,x/[ \t]+$|^[ \t]+$/d<Enter>", "Remove trailing whitespace")
-- select markdown list element: ,x/^(\d+\.|[-*])\s+.+\n(^ .+\n)*/
+
+
+
+------------------------------------
+--- EVENTS
+------------------------------------
+
+vis.events.subscribe(vis.events.INIT, function()
+ vis.options.ignorecase = true
+ vis.options.autoindent = true
+ vis.options.shell = "/bin/sh"
+ local 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
+
+ if win.syntax == "bash" then
+ map_keys(m.NORMAL, " v",
+ "V:x/^(\\s*)(.+)$/ c/\\1>\\&2 printf '\\2: %s\\\\n' \"$\\2\"/<Enter><Escape>", "Print variable")
+ end
+
+end)
+