diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-06-24 17:06:18 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-06-24 17:06:18 +0200 |
commit | d5a7a2df1fdeb2d82c51a0d78493bfb7241160c2 (patch) | |
tree | 1ac695a756e3570bf06b1a7658d143fc2b264657 /config/essentials/vis/visrc.lua | |
parent | 1f7e952a75a870b0a4e9900964cae3729c216cc3 (diff) |
checkpoint
Diffstat (limited to 'config/essentials/vis/visrc.lua')
-rw-r--r-- | config/essentials/vis/visrc.lua | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/config/essentials/vis/visrc.lua b/config/essentials/vis/visrc.lua index 93954ae..78f7cfe 100644 --- a/config/essentials/vis/visrc.lua +++ b/config/essentials/vis/visrc.lua @@ -52,8 +52,8 @@ local function map_cmd(mode, map, command, help) end, help) end --- TOOD: use window selection to restore position -local function wrap_restore(f, ...) +-- Store and pop position with command ran in between +local function wrap_pos_restore(f, ...) local pos = vis.win.selection.pos f(...) vis.win.selection.pos = pos @@ -83,27 +83,27 @@ end, "Remove trailing whitespace") --- MAPPINGS ------------------------------------- -vis:map(m.NORMAL, " pf", function() - vis:command("fzf") -end, "Open file with fzf") -vis:map(m.NORMAL, " pr", function() - vis:command("fzfmru") -end, "Open file with fzf") - -vis:map(m.NORMAL, " r", function() - wrap_restore(vis.command, vis, "e $vis_filepath") -end, "Reload active file") - -vis:map(m.NORMAL, "=", format.apply, "Format 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") -map_cmd(m.NORMAL, "!", "!bash", "Run bash") - -map_keys(m.NORMAL, " nl", ":<seq -f '%0.0f. ' 1 ", "Insert numbered list") +vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused args + map_cmd(m.NORMAL, " pf", "fzf", "Open file with fzf") + map_cmd(m.NORMAL, " pr", "fzfmru", "Open file with fzf") + + vis:map(m.NORMAL, " r", function() + wrap_pos_restore(vis.command, vis, "e $vis_filepath") + end, "Reload active file") + vis:map(m.NORMAL, "=", format.apply, "Format active file") + map_cmd(m.NORMAL, "<M-m>", "make", "Run 'make'") + 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") + map_cmd(m.NORMAL, "!", "!bash", "Run bash") + map_keys(m.NORMAL, " y", '"+y', "Copy to system clipboard") + map_keys(m.VISUAL, " y", '"+y', "Copy to system clipboard") + map_keys(m.NORMAL, " nl", ":<seq -f '%0.0f. ' 1 ", "Insert numbered list") + map_keys(m.NORMAL, "<M-S-Down>", "ddp", "Move line down") + map_keys(m.NORMAL, "<M-S-Up>", "ddkP", "Move line up") -- Doesn't work at end of file +end) ------------------------------------ --- EVENTS @@ -139,7 +139,7 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused a "Print variable" ) map_keys(m.NORMAL, "\\v", 'V:x/^(\\s*)(.+)$/ c/\\1"$(\\2)"/<Enter><Escape>', "Surround in variable") - map_keys(m.NORMAL, ";|", "V:x/\\| / c/|\n\t/<Enter><Escape>", "Wrap one-line multi pipe command") + map_keys(m.NORMAL, "\\|", "V:x/\\| / c/|\n\t/<Enter><Escape>", "Wrap one-line multi pipe command") map_keys( m.NORMAL, "\\e", @@ -163,5 +163,4 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused a if win.syntax == "ansi_c" then map_keys(m.NORMAL, "\\a", "f,a <Escape>hdw<S-Tab>i<Tab><Escape>", "Align table") end - end) |