From bacc2552699376770a8c87cd6d3bc71aeb1f9330 Mon Sep 17 00:00:00 2001 From: Sam Nystrom Date: Fri, 27 Dec 2024 17:25:54 -0500 Subject: vis: add config --- .config/vis/visrc.lua | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .config/vis/visrc.lua (limited to '.config/vis/visrc.lua') diff --git a/.config/vis/visrc.lua b/.config/vis/visrc.lua new file mode 100644 index 0000000..9641dd6 --- /dev/null +++ b/.config/vis/visrc.lua @@ -0,0 +1,61 @@ +require('vis') + +require('plugins/vis-backspace') +require('plugins/vis-ctags') +require('plugins/vis-cursors') +require('plugins/vis-editorconfig') +require('plugins/vis-quickfix') + +for _, ext in ipairs({ "%.jsx$", "%.ts", "%.tsx$" }) do + table.insert(vis.ftdetect.filetypes.javascript.ext, ext) +end + +vis.ftdetect.filetypes.hare = { + ext = { "%.ha$" }, +} + +shebangs = { + awk = { "awk" }, + bash = { "bash", "sh" }, + execline = { "execlineb" }, + perl = { "perl" }, + python = { "python", "python3" }, +} + +vis.events.subscribe(vis.events.WIN_OPEN, function(win) + local shebang = vis.win.file.lines[1] + local cmd = shebang:match("^#!%g*/([^/%s]+)") + if cmd == "env" then + cmd = shebang:match("^#!%g*/env (%g+)") + end + for syntax, cmds in pairs(shebangs) do + for _, c in ipairs(cmds) do + if c == cmd then + vis:command("set syntax " .. syntax) + return + end + end + end +end) + +vis.events.subscribe(vis.events.INIT, function() + vis:command('set escdelay 25') + vis:command('set autoindent') + vis:command('set theme flexoki') +end) + +vis.events.subscribe(vis.events.WIN_OPEN, function(win) + vis:command('set relativenumbers') +end) + +function automake_handler() + vis:command('make') +end + +vis:option_register('automake', 'bool', function(value, toggle) + if toggle then + vis.events.subscribe(vis.events.FILE_SAVE_POST, automake_handler) + else + vis.events.unsubscribe(vis.events.FILE_SAVE_POST, automake_handler) + end +end, 'Run :make automatically after saving') -- cgit v1.2.3