linux-qubasis
linux oasis port as a qubes template
git clone https://9o.is/git/linux-qubasis.git
commit 8c46615f2cab05e39b617d2732382c6e5b0d1c0b parent e34b2f161c8134cea443906e87a792276bf24a81 Author: Jul <jul@9o.is> Date: Thu, 7 Aug 2025 09:20:14 -0400 add vis config for fzy/fe Diffstat:
| M | pkg/vis/config/config/navigation.lua | | | 4 | +++- |
| A | pkg/vis/config/config/picker.lua | | | 42 | ++++++++++++++++++++++++++++++++++++++++++ |
| A | pkg/vis/config/plugins/util.lua | | | 39 | +++++++++++++++++++++++++++++++++++++++ |
| M | pkg/vis/config/visrc.lua | | | 1 | + |
4 files changed, 85 insertions(+), 1 deletion(-)
diff --git a/pkg/vis/config/config/navigation.lua b/pkg/vis/config/config/navigation.lua @@ -1,5 +1,7 @@ require('vis') +local util = require("plugins/util") + local function count_windows() local count = 0 for _, _ in vis:windows() do @@ -29,6 +31,6 @@ vis.events.subscribe(vis.events.INIT, function() end end, 'Close current window') - vis:map(vis.modes.NORMAL, '<C-t>', ':!tmux new-window -a vis<Enter>') + vis:map(vis.modes.NORMAL, '<C-t>', ':!echo "create \'vis \\$(fe)\'" > $DVTM_CMD_FIFO<Enter>') end) diff --git a/pkg/vis/config/config/picker.lua b/pkg/vis/config/config/picker.lua @@ -0,0 +1,42 @@ +require("vis") + +local util = require("plugins/util") + +vis:command_register("pick", function(argv, force, win, selection, range) + local command = table.concat(argv, " ") + local file = io.popen(command) + local output = {} + for line in file:lines() do + table.insert(output, line) + end + local _, __, status = file:close() + + if status == 0 and output[1] ~= nil then + vis:feedkeys(string.format(":e '%s'<Enter>", output[1])) + end + + vis:feedkeys("<vis-redraw>") + return true; +end, "Pick files to open") + +function map(key, command, help) + vis:map(vis.modes.NORMAL, key, function() + vis:command(command) + end, help) +end + +vis.events.subscribe(vis.events.INIT, function() + map(",sf", "pick find -type f | fzy", "[S]earch [F]iles") + map(",sd", "pick fe $(find -type d | fzy)", "[S]earch [D]irectories") +end) + +vis.events.subscribe(vis.events.WIN_OPEN, function(win) + local function dir(command) + return string.format(command, util.dirname(win.file.name)) + end + + map("-", string.format("pick fe ./%s", win.file.name), "Explore files") + map(",ssf", dir("pick find %s -type f | fzy"), "[S]earch [S]ub-directory [F]iles") + map(",ssd", dir("pick fe $(find %s -type d | fzy)"), "[S]earch [S]ub-directory [D]irectories") +end) + diff --git a/pkg/vis/config/plugins/util.lua b/pkg/vis/config/plugins/util.lua @@ -0,0 +1,39 @@ +local M = {} + +M.dirname = function(pathname) + if pathname == nil then + return '.' + elseif type(pathname) ~= 'string' then + error('pathname must be string', 2) + end + + -- remove trailing-slashes + local head = string.find(pathname, '/+$', 2) + if head then + pathname = string.sub(pathname, 1, head - 1) + end + + -- remove last-segment + head = string.find(pathname, '[^/]+$') + if head then + pathname = string.sub(pathname, 1, head - 1) + end + + -- remove trailing-slashes + head = string.find(pathname, '/+$') + if head then + if head == 1 then + return '/' + end + pathname = string.sub(pathname, 1, head - 1) + end + + -- empty or dotted string + if string.find(pathname, '^%s*$') or string.find(pathname, '^%.+$') then + return '.' + end + + return pathname +end + +return M diff --git a/pkg/vis/config/visrc.lua b/pkg/vis/config/visrc.lua @@ -4,6 +4,7 @@ require('plugins/pairs') require('plugins/surround') require('config/status') require('config/navigation') +require('config/picker') vis.events.subscribe(vis.events.INIT, function() vis:command('set theme default-16')