.config/nvim/lua/config/commands.lua

changeset 1079
b59861305252
parent 1078
aa4c1aa529a5
child 1080
83c9f8460bde
equal deleted inserted replaced
1078:aa4c1aa529a5 1079:b59861305252
15 if vim.v.shell_error == 0 then 15 if vim.v.shell_error == 0 then
16 cmd.cd(root) 16 cmd.cd(root)
17 end 17 end
18 end, {}) 18 end, {})
19 19
20 command("Grep", function(ctx)
21 local pattern = ctx.fargs[1] or fn.expand("<cword>")
22 local grepcmd = table.concat({
23 vim.o.grepprg,
24 fn.shellescape(pattern),
25 table.concat(vim.list_slice(ctx.fargs, 2, #ctx.fargs), " "),
26 }, " ")
27
28 fn.setqflist({}, " ", { title = grepcmd, lines = fn.systemlist(grepcmd) })
29 fn.setreg("/", [[\V]] .. pattern)
30 cmd.copen()
31 cmd.cfirst()
32 end, { nargs = "*", complete = "file" })
33
20 calias("Q", "q") 34 calias("Q", "q")
21 calias("Qa", "qa") 35 calias("Qa", "qa")
22 calias("W", "w") 36 calias("W", "w")
23 calias("grep", "Grep") 37 calias("grep", "Grep")
24 38

mercurial