Fri, 05 May 2023 13:12:54 -0500
factor out bina install
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 |
1095
226221dc1d6b
Simplify command aliases
Meredith Howard <mhoward@roomag.org>
parents:
1080
diff
changeset
|
2 | local cmd, fn = vim.cmd, vim.fn |
1078
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3 | |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
4 | command("Hgcd", function() |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
5 | 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
|
6 | if vim.v.shell_error == 0 then |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
7 | cmd.cd(root) |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
8 | end |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
9 | end, {}) |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
10 | |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
11 | command("Gcd", function() |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
12 | 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
|
13 | if vim.v.shell_error == 0 then |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
14 | cmd.cd(root) |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
15 | end |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
16 | end, {}) |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
17 | |
1079 | 18 | command("Grep", function(ctx) |
19 | local pattern = ctx.fargs[1] or fn.expand("<cword>") | |
20 | local grepcmd = table.concat({ | |
21 | vim.o.grepprg, | |
22 | fn.shellescape(pattern), | |
23 | table.concat(vim.list_slice(ctx.fargs, 2, #ctx.fargs), " "), | |
24 | }, " ") | |
25 | ||
26 | 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
|
27 | fn.setreg("/", [[\v]] .. pattern) |
1079 | 28 | cmd.copen() |
29 | cmd.cfirst() | |
30 | end, { nargs = "*", complete = "file" }) | |
31 | ||
1095
226221dc1d6b
Simplify command aliases
Meredith Howard <mhoward@roomag.org>
parents:
1080
diff
changeset
|
32 | require("config.util").calias({ |
226221dc1d6b
Simplify command aliases
Meredith Howard <mhoward@roomag.org>
parents:
1080
diff
changeset
|
33 | -- replace default: |
226221dc1d6b
Simplify command aliases
Meredith Howard <mhoward@roomag.org>
parents:
1080
diff
changeset
|
34 | grep = "Grep", |
1078
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
35 | |
1095
226221dc1d6b
Simplify command aliases
Meredith Howard <mhoward@roomag.org>
parents:
1080
diff
changeset
|
36 | -- typos: |
226221dc1d6b
Simplify command aliases
Meredith Howard <mhoward@roomag.org>
parents:
1080
diff
changeset
|
37 | Q = "q", |
226221dc1d6b
Simplify command aliases
Meredith Howard <mhoward@roomag.org>
parents:
1080
diff
changeset
|
38 | Qa = "qa", |
226221dc1d6b
Simplify command aliases
Meredith Howard <mhoward@roomag.org>
parents:
1080
diff
changeset
|
39 | W = "w", |
226221dc1d6b
Simplify command aliases
Meredith Howard <mhoward@roomag.org>
parents:
1080
diff
changeset
|
40 | gcd = "Gcd", |
226221dc1d6b
Simplify command aliases
Meredith Howard <mhoward@roomag.org>
parents:
1080
diff
changeset
|
41 | hgcd = "Hgcd", |
1078
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
42 | |
1095
226221dc1d6b
Simplify command aliases
Meredith Howard <mhoward@roomag.org>
parents:
1080
diff
changeset
|
43 | -- Make the ! versions default to stay in one window + buffer: |
226221dc1d6b
Simplify command aliases
Meredith Howard <mhoward@roomag.org>
parents:
1080
diff
changeset
|
44 | doc = "ViewDoc!", |
226221dc1d6b
Simplify command aliases
Meredith Howard <mhoward@roomag.org>
parents:
1080
diff
changeset
|
45 | help = "ViewDocHelp!", |
226221dc1d6b
Simplify command aliases
Meredith Howard <mhoward@roomag.org>
parents:
1080
diff
changeset
|
46 | man = "ViewDocMan!", |
226221dc1d6b
Simplify command aliases
Meredith Howard <mhoward@roomag.org>
parents:
1080
diff
changeset
|
47 | perldoc = "ViewDocPerl!", |
226221dc1d6b
Simplify command aliases
Meredith Howard <mhoward@roomag.org>
parents:
1080
diff
changeset
|
48 | }) |