vis-config

lua scripts to configure vis editor

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

commit 6c0482510225400d6c82c5c2138b1acd418dbd23
parent bd7346f3c2f28b28b41285e9cefb5e539957b35c
Author: Jul <jul@9o.is>
Date:   Fri,  6 Feb 2026 07:30:37 -0500

initialize an x11 window manager

Diffstat:
Mlib/status.lua | 4++--
Mlib/window-manager/init.lua | 19++++++++++++++++++-
Mlib/window-manager/tmux.lua | 8+++++---
Alib/window-manager/x11.lua | 33+++++++++++++++++++++++++++++++++
Mvisrc.lua | 2++
5 files changed, 60 insertions(+), 6 deletions(-)

diff --git a/lib/status.lua b/lib/status.lua @@ -56,9 +56,9 @@ vis.events.subscribe(vis.events.WIN_STATUS, function(win) scroll_percent ) - if wm.enabled() then + if wm.enabled() and wm.hasstatus() then if left ~= lastl then - wm.set_title('vis ' .. left) + wm.set_title(left) lastl = left end diff --git a/lib/window-manager/init.lua b/lib/window-manager/init.lua @@ -1,4 +1,7 @@ local tmux = require('lib/window-manager/tmux') +local x11 = require('lib/window-manager/x11') + +local wm = 'none' local function nullfunc() vis:info('window manager missing') @@ -7,6 +10,7 @@ end local nullstrategy = { enabled = function() return false end, + hasstatus = function() return false end, init = nullfunc, tabnew = nullfunc, terminal = nullfunc, @@ -20,13 +24,18 @@ local M = { } M.init = function() - if os.getenv('TMUX') then + if wm == 'tmux' and os.getenv('TMUX') then M.strategy = tmux M.strategy.init() end + if wm == 'x11' and os.getenv('WINDOWID') then + M.strategy = x11 + M.strategy.init() + end end M.enabled = function(...) return M.strategy.enabled(...) end +M.hasstatus = function(...) return M.strategy.hasstatus(...) end M.tabnew = function(...) return M.strategy.tabnew(...) end M.terminal = function(...) return M.strategy.terminal(...) end M.navigate = function(...) return M.strategy.navigate(...) end @@ -40,4 +49,12 @@ end) vis:command_register('tabnew', M.tabnew, 'Run vis command in a new tab page') vis:command_register('terminal', M.terminal, 'Run shell command in a new tab page') +vis:option_register('wm', 'string', function(value) + if value == 'none' or value == 'tmux' or value == 'x11' then + wm = value + return + end + vis:message('invalid window manager: ' .. value) +end, 'Set window manager') + return M diff --git a/lib/window-manager/tmux.lua b/lib/window-manager/tmux.lua @@ -11,9 +11,7 @@ local function write(cmd) return true end -local tmux = { - type = 'tmux', -} +local tmux = {} tmux.init = function() pane_id = os.getenv('TMUX_PANE') @@ -42,6 +40,10 @@ tmux.enabled = function() return io.type(fd) == 'file' end +tmux.hasstatus = function() + return true +end + tmux.navigate = function(path, cmd) cmd = cmd and "+'"..cmd.."'" or '' return write(string.format('new-window -b vis %s %s', cmd, path)) diff --git a/lib/window-manager/x11.lua b/lib/window-manager/x11.lua @@ -0,0 +1,33 @@ +local winid + +local x11 = {} + +x11.init = function() + winid = os.getenv('WINDOWID') +end + +x11.enabled = function() + return false +end + +x11.hasstatus = function() + return false +end + + +x11.navigate = function(path, cmd) + return false +end + +x11.tabnew = function(argv) + return false +end + +x11.terminal = function(argv) + return false +end + +x11.set_title = function() end +x11.set_status = function() end + +return x11 diff --git a/visrc.lua b/visrc.lua @@ -13,6 +13,8 @@ local m = vis.modes local ll = ' ' -- left leader local lr = '<Backspace>' -- right leader +vis:command('set wm tmux') + vis.events.subscribe(vis.events.INIT, function() vis:command('set autoindent on') vis:command('set ignorecase on')