summaryrefslogtreecommitdiff
path: root/.config/vis/visrc.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/vis/visrc.lua')
-rw-r--r--.config/vis/visrc.lua65
1 files changed, 65 insertions, 0 deletions
diff --git a/.config/vis/visrc.lua b/.config/vis/visrc.lua
new file mode 100644
index 0000000..982056e
--- /dev/null
+++ b/.config/vis/visrc.lua
@@ -0,0 +1,65 @@
+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
+
+for _, ext in ipairs({ "^Containerfile$", "%.Containerfile$" }) do
+ table.insert(vis.ftdetect.filetypes.dockerfile.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')