diff options
Diffstat (limited to 'mut/vis/visrc.lua')
| -rw-r--r-- | mut/vis/visrc.lua | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/mut/vis/visrc.lua b/mut/vis/visrc.lua index 898df9c..4f87b50 100644 --- a/mut/vis/visrc.lua +++ b/mut/vis/visrc.lua @@ -19,6 +19,7 @@ format.formatters.terraform = format.stdio_formatter("terraform fmt -", {on_save vis.events.subscribe(vis.events.INIT, function() vis:command"set shell '/usr/bin/bash'" vis:command"set edconfhooks on" + vis:command"set change256colors off" vis:command"set theme lemonsoda" vis:map(m.INSERT, '<C-r>"', '<C-r>+') @@ -39,6 +40,9 @@ end) local files = {} vis.events.subscribe(vis.events.WIN_OPEN, function(win) vis:command"set cul on" + vis:command"set number" + vis:command"set relativenumber" + vis:command"set change256colors off" local radix = files[vis.win.file.path] for p, i in pairs(files) do if (radix == nil) or (radix >= i) then @@ -50,7 +54,7 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) end end) -vis:map(m.NORMAL, "<M-x>b", function() +vis:map(m.NORMAL, "<C-x>b", function() local keys = {} for k in pairs(files) do if k ~= vis.win.file.path then table.insert(keys, k) end end if next(keys) == nil then @@ -64,35 +68,41 @@ vis:map(m.NORMAL, "<M-x>b", function() return true; end) -vis:map(m.NORMAL, "<M-x>~", function() - vis:command("cd " .. vis.win.file.path:match("(.+)/[^/]+$")) +local parent = function(filename) + if filename ~= nil then + return filename:match("(.+)/[^/]+$") + end + return nil +end + +local lfcd = function(cd_or_select_path) + local code, result, err = vis:pipe("", "lf --print-selection " .. cd_or_select_path) + vis:command("cd " .. err) + if result then + vis:command("e " .. result) + end + return true; +end + +vis:map(m.NORMAL, "<C-x>~", function() + vis:command("cd " .. (parent(vis.win.file.path) or ".")) return true; end) -vis:map(m.NORMAL, "<M-x>f", function() - local code, result, err = vis:pipe("", "vis-open .") +vis:map(m.NORMAL, "<C-x><C-f>", function() + local code, result, err = vis:pipe("", "vis-open " .. (parent(vis.win.file.path) or ".")) if result then - if not os.execute("cd " .. result) then vis:command("e " .. result) else - vis:command("cd " .. result) - local code, result, err = vis:pipe("", "lf --print-selection") - if not result then return true end - local lines = {} - for line in result:gmatch("[^\n]+") do table.insert(lines, line) end - if lines[1] then - vis:command("e " .. lines[1]) - end + return lfcd(result) end return true; end return true; end) -vis:map(m.NORMAL, "<M-x>-", function() - local code, result, err = vis:pipe("", "lf --print-selection") - vis:command("cd " .. err) - if result then - vis:command("e " .. result) - end - return true; +vis:map(m.NORMAL, "<C-x>-", function() + return lfcd(parent(vis.win.file.path) or "") +end) +vis:map(m.NORMAL, "<C-x>_", function() + return lfcd(".") end) |
