require("vis") require("plugins/vis-ctags") require("plugins/vis-sneak") 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)