Skip to content

Commit 9757771

Browse files
committed
Support external plumb and from clipboard via Plumb wrapper
1 parent 1199c55 commit 9757771

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

bin/Plumb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
exec avim -p "$(xsel -bo)"

bin/avim.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ struct {
1212
{'k', "kill"},
1313
{'l', "look"},
1414
{'o', "open"},
15+
{'p', "plumb"},
1516
{'s', "scratch"},
1617
{'w', "cwd"},
1718
};
@@ -106,9 +107,11 @@ void request(char *argv[], size_t argc) {
106107
avim_strv req = vec_new();
107108
vec_push(&req, cmds[mode].name);
108109
int cmd = cmds[mode].opt;
109-
if (cmd == 's') {
110+
if (cmd == 'p' || cmd == 's') {
110111
vec_push(&req, cwd);
111-
vec_push(&req, "");
112+
if (cmd == 's') {
113+
vec_push(&req, "");
114+
}
112115
}
113116
for (size_t i = 0; i < argc; i++) {
114117
char *arg = argv[i];

plugin/acme.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,9 @@ function AcmeOpen(name, pos)
583583
endfunc
584584

585585
function s:RgOpen(pos)
586+
if s:plumbclick <= 0
587+
return 0
588+
endif
586589
call win_execute(s:plumbwin,
587590
\ 'let s:l = search("\\v^(\\s*(\\d+[-:]|\\-\\-$))@!", "bnW")')
588591
let f = getbufoneline(winbufnr(s:plumbwin), s:l)
@@ -1131,6 +1134,8 @@ function s:CtrlRecv(ch, data)
11311134
call s:Edit(args, cid, 'diff')
11321135
call s:Diff(args)
11331136
let resp = []
1137+
elseif cmd == 'plumb' && len(args) > 1
1138+
call s:Open(args[1], 0, [args[0]], 0)
11341139
endif
11351140
if resp != []
11361141
call s:CtrlSend([cid] + resp)

0 commit comments

Comments
 (0)