require("vis") local plug = (function() if not pcall(require, 'plugins/vis-plug') then os.execute('git clone --quiet https://github.com/erf/vis-plug ' .. (os.getenv('XDG_CONFIG_HOME') or os.getenv('HOME') .. '/.config') .. '/vis/plugins/vis-plug') end return require('plugins/vis-plug') end)() local plugins = { { 'erf/vis-sneak' }, { 'kupospelov/vis-ctags' }, { 'https://codeberg.org/luxanna/vis-autoclose' }, { 'http://forge.kentoj.de/kento2/vis-lspc.git' } } plug.init(plugins, true) vis.events.subscribe(vis.events.INIT, function() vis:command("set theme kento2") vis.options.autoindent = true vis.options.breakat = " " vis:map(vis.modes.NORMAL, 'h', 'gh') vis:map(vis.modes.NORMAL, 'j', 'gj') vis:map(vis.modes.NORMAL, 'k', 'gk') vis:map(vis.modes.NORMAL, 'l', 'gl') vis:map(vis.modes.NORMAL, '0', 'g0') vis:map(vis.modes.VISUAL, ' y', '"+y') vis:map(vis.modes.VISUAL, ' p', '"+p') vis:map(vis.modes.VISUAL, ' d', '"+d') vis:map(vis.modes.VISUAL, ' x', '"+x') vis:map(vis.modes.NORMAL, ' y', '"+y') vis:map(vis.modes.NORMAL, ' p', '"+p') vis:map(vis.modes.NORMAL, ' d', '"+d') vis:map(vis.modes.NORMAL, ' x', '"+x') vis:command_register("grep", function(argv, force, win, selection, range) local text = argv[1] if selection.anchored then text = win.file:content(selection.range) end if not text then return false end local escaped = text:gsub("'","'\\''") local proc = io.popen("grep -n -I -R -- "..escaped .." | tr '\t' ' ' | fzy") if not proc then return false end local sel = proc:read("*a") or "" proc:close(); local path, line = sel:match("^(.-):(%d+):") if not path or not line then return false end selection:remove() selection.anchored = false vis:command("e "..path) vis.win.selection:to(tonumber(line), 1) vis:redraw() return true end) vis:map(vis.modes.VISUAL, ' g', function() vis:command("grep") end) vis:map(vis.modes.NORMAL, ' f', function() vis:command("!make; read a") end) vis:map(vis.modes.NORMAL, 'mm', function() vis:command("!make; read a") end) vis:map(vis.modes.NORMAL, 'mc', function() vis:command("!make check; read a") end) vis:map(vis.modes.NORMAL, 'mt', function() vis:command("!make test; read a") end) end) vis.events.subscribe(vis.events.WIN_OPEN, function(win) win.options.tabwidth = 2 win.options.expandtab = true -- win.options.wrapcolumn = 80 end)