.
This commit is contained in:
parent
725d1d1ead
commit
dc6995c0e1
4 changed files with 43 additions and 10 deletions
|
|
@ -23,13 +23,46 @@ vis.events.subscribe(vis.events.INIT, function()
|
|||
vis:map(vis.modes.NORMAL, ' d', '"+d')
|
||||
vis:map(vis.modes.NORMAL, ' x', '"+x')
|
||||
|
||||
vis:map(vis.modes.NORMAL, ' m', function()
|
||||
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, ' c', function()
|
||||
|
||||
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, ' t', function()
|
||||
vis:map(vis.modes.NORMAL, 'mt', function()
|
||||
vis:command("!make test; read a")
|
||||
end)
|
||||
end)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue