vis-config

lua scripts to configure vis editor

git clone https://9o.is/git/vis-config.git

commit 8be7ec577d6e82122d00d7d9a62e515ef41589c3
parent 6c0482510225400d6c82c5c2138b1acd418dbd23
Author: Jul <jul@9o.is>
Date:   Sat,  7 Feb 2026 09:32:14 -0500

implement x11 window manager with st as terminal

Diffstat:
Mlib/status.lua | 2+-
Mlib/window-manager/x11.lua | 82++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
Mvisrc.lua | 2+-
3 files changed, 77 insertions(+), 9 deletions(-)

diff --git a/lib/status.lua b/lib/status.lua @@ -63,7 +63,7 @@ vis.events.subscribe(vis.events.WIN_STATUS, function(win) end if right ~= lastr then - wm.set_status(right .. ' « ') + wm.set_status(right) lastr = right end else diff --git a/lib/window-manager/x11.lua b/lib/window-manager/x11.lua @@ -1,33 +1,101 @@ +local fd_qrexec +local fd_tmux local winid +local tmuxid + +local function write(cmd) + if io.type(fd_qrexec) ~= 'file' then + vis:info('qrexec-winstatus client is not running') + return false + end + fd_qrexec:write(cmd .. '\n') + fd_qrexec:flush() + return true +end + +local function write_tmux(cmd) + if io.type(fd_tmux) ~= 'file' then + vis:info('tmux client is not running') + return false + end + fd_tmux:write(cmd .. '\n') + fd_tmux:flush() + return true +end local x11 = {} x11.init = function() winid = os.getenv('WINDOWID') + tmuxid = os.getenv('TMUX_PANE') + + if not winid then + return + end + + fd_qrexec = vis:communicate('qrexec-winstatus', + string.format('exec qrexec-client-vm @default user.WindowStatus+%s', winid)) + + if tmuxid then + fd_tmux = vis:communicate('tmux', + string.format("exec env -u TMUX tmux -C attach -t %s", tmuxid)) + end + + vis.events.subscribe(vis.events.PROCESS_RESPONSE, function(name, event, code, msg) + if name ~= 'qrexec-winstatus' and name ~= 'tmux' then + return + end + + if event == 'EXIT' then + vis:info(string.format('%s client exited: %s', name, code)) + elseif event == 'SIGNAL' then + vis:info(string.format('%s client exited: %s', name, code)) + end + end) + end x11.enabled = function() - return false + return io.type(fd_qrexec) == 'file' end x11.hasstatus = function() - return false + return true end +local function spawn_terminal(cmd) + return os.execute(string.format('st -e sh -c "%s" >/dev/null 2>&1 &', cmd)) +end x11.navigate = function(path, cmd) - return false + cmd = cmd and "+'"..cmd.."'" or '' + return spawn_terminal(string.format('vis %s %s', cmd, path)) end x11.tabnew = function(argv) - return false + return spawn_terminal(string.format('vis %s', table.concat(argv, ' '))) end x11.terminal = function(argv) - return false + local cmd = os.getenv('SHELL') or 'sh' + if #argv ~= 0 then cmd = table.concat(argv, ' '):gsub('"', '\\"') end + return spawn_terminal(cmd) end -x11.set_title = function() end -x11.set_status = function() end +x11.set_title = function(title) + if fd_tmux then + return write_tmux(string.format("select-pane -t %s -T '%s'", tmuxid, title)) + end + + local f = io.open("/dev/tty", "w") + if f then + f:write("\27]2;" .. title .. "\7") + f:close() + end +end + +x11.set_status = function(status) + return write(status) +end return x11 diff --git a/visrc.lua b/visrc.lua @@ -13,7 +13,7 @@ local m = vis.modes local ll = ' ' -- left leader local lr = '<Backspace>' -- right leader -vis:command('set wm tmux') +vis:command('set wm x11') vis.events.subscribe(vis.events.INIT, function() vis:command('set autoindent on')