dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit b527e89848e002e112e1f0512b1bb6e09e778641
parent 7ec8c54bf704532af85919346aa0656275ed0ceb
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Fri, 14 Jun 2019 18:37:29 +0200

Fix fzf-mru and add bind to switch to most recent file

Diffstat:
M.config/vis/plugins/fzf-mru.lua | 2+-
M.config/vis/visrc.lua | 26++++++++++++++++++++++----
2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/.config/vis/plugins/fzf-mru.lua b/.config/vis/plugins/fzf-mru.lua @@ -52,7 +52,7 @@ vis:command_register("fzfmru", function(argv, force, win, selection, range) local success, msg, status = file:close() if status == 0 then - vis:command(string.format("e '%s'<Enter>", output)) + vis:feedkeys(string.format(":e '%s'<Enter>", output)) elseif status == 1 then vis:info(string.format("fzf-open: No match. Command %s exited with return value %i." , command, status)) elseif status == 2 then diff --git a/.config/vis/visrc.lua b/.config/vis/visrc.lua @@ -17,6 +17,7 @@ vis.events.subscribe(vis.events.INIT, function() vis:map(vis.modes.NORMAL, leader..'l', ':set show-newline!<Enter>') vis:map(vis.modes.NORMAL, leader..'m', ':!make<Enter>') + -- fuzzy open vis:map(vis.modes.NORMAL, leader..'o', function() local file = io.popen('fzf') @@ -31,7 +32,23 @@ vis.events.subscribe(vis.events.INIT, function() return true; end) - vis:map(vis.modes.NORMAL, leader..'b', ':fzfmru<Enter>') + -- fuzzy open recent file + vis:map(vis.modes.NORMAL, leader..',', ':fzfmru<Enter>') + + -- switch to previous file + vis:map(vis.modes.NORMAL, leader..'<Tab>', + function() + local file = io.popen('sed -n 2p ~/.mru') + local output = file:read() + local success, msg, status = file:close() + if status == 0 then + vis:feedkeys(string.format(":e '%s'<Enter>", output)) + else + vis:info('error ' .. tostring(status)) + end + vis:feedkeys('<vis-redraw>') + return true; + end) require('snippets') end) @@ -48,9 +65,10 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) vis:map(vis.modes.NORMAL, leader..'p', function() if win.file.name then - vis:info('return status: ' .. - tostring(os.execute('compile '..win.file.name))) - win.draw() + cmd = os.execute('compile ' .. win.file.name) + if cmd then vis:info('compile complete') + else vis:info('error: return status ' .. tostring(cmd)) end + vis:feedkeys('<vis-redraw>') end return true; end)