Thu, 16 Mar 2023 12:30:54 -0500
Cleaner conflict resolution
1078
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1 | local command = vim.api.nvim_create_user_command |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2 | local calias = require("config.util").calias |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3 | local cmd = vim.cmd |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
4 | local fn = vim.fn |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
5 | |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
6 | command("Hgcd", function() |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
7 | local root = fn.systemlist("hg root 2>/dev/null")[1] |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
8 | if vim.v.shell_error == 0 then |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
9 | cmd.cd(root) |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
10 | end |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
11 | end, {}) |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
12 | |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
13 | command("Gcd", function() |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
14 | local root = fn.systemlist("git rev-parse --show-toplevel 2>/dev/null")[1] |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
15 | if vim.v.shell_error == 0 then |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
16 | cmd.cd(root) |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
17 | end |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
18 | end, {}) |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
19 | |
1079 | 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) }) | |
1080
83c9f8460bde
continue to confuse the verymagic options
Meredith Howard <mhoward@roomag.org>
parents:
1079
diff
changeset
|
29 | fn.setreg("/", [[\v]] .. pattern) |
1079 | 30 | cmd.copen() |
31 | cmd.cfirst() | |
32 | end, { nargs = "*", complete = "file" }) | |
33 | ||
1078
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
34 | calias("Q", "q") |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
35 | calias("Qa", "qa") |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
36 | calias("W", "w") |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
37 | calias("grep", "Grep") |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
38 | |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
39 | calias("gcd", "Gcd") |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
40 | calias("hgcd", "Hgcd") |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
41 | |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
42 | -- Switch these to default to stay in one window + buffer |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
43 | calias("doc", "ViewDoc!") |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
44 | calias("help", "ViewDocHelp!") |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
45 | calias("man", "ViewDocMan!") |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
46 | calias("perldoc", "ViewDocPerl!") |