Fri, 05 May 2023 13:12:54 -0500
factor out bina install
1074 | 1 | local api = vim.api |
2 | local fn = vim.fn | |
3 | ||
4 | local function tig(ctx) | |
5 | local cmd = ctx.fargs | |
6 | local orig_number = vim.wo.number | |
7 | ||
8 | local buf = api.nvim_create_buf(false, true) | |
9 | vim.bo[buf].bufhidden = "delete" | |
10 | ||
11 | api.nvim_set_current_buf(buf) | |
12 | vim.wo.number = false | |
13 | ||
14 | table.insert(cmd, 1, "tig") | |
15 | fn.termopen(cmd, { | |
16 | on_exit = function() | |
17 | vim.wo.number = orig_number | |
18 | vim.cmd.buffer("#") | |
19 | end, | |
20 | }) | |
21 | end | |
22 | ||
1085
c2d11f022cf0
Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
1076
diff
changeset
|
23 | api.nvim_create_user_command("Tig", tig, { nargs = "*", complete = "file" }) |
1074 | 24 | |
1085
c2d11f022cf0
Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
1076
diff
changeset
|
25 | api.nvim_create_user_command("TigBlame", function() |
c2d11f022cf0
Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
1076
diff
changeset
|
26 | tig({ fargs = { "blame", "+" .. fn.line("."), "--", fn.expand("%") } }) |
c2d11f022cf0
Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
1076
diff
changeset
|
27 | end, {}) |
1074 | 28 | |
1085
c2d11f022cf0
Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
1076
diff
changeset
|
29 | api.nvim_create_user_command("TigLog", function() |
c2d11f022cf0
Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
1076
diff
changeset
|
30 | tig({ fargs = { "log", "-p", "--", fn.expand("%") } }) |
c2d11f022cf0
Port encrypted file edit to lua
Meredith Howard <mhoward@roomag.org>
parents:
1076
diff
changeset
|
31 | end, {}) |