-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfzy.vim
52 lines (40 loc) · 926 Bytes
/
fzy.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function! Buffers() abort
let buffers = map(getbufinfo(), 'v:val.bufnr . "\t" . v:val.name')
let choice = FZY(buffers)
execute "buffer" split(choice, '\t')[0]
endfunction
function! CallCommand()
command
endfunction
function! Commands() abort
let commands = ''
redir => commands
silent call CallCommand()
redir END
let choice = FZY(commands)
endfunction
function! Files() abort
let choice = FZYExternal('fd')
execute "edit" choice
endfunction
function! Lines() abort
let choice = FZYExternal('rg --vimgrep --column "^.*$"')
let [filename, line] = split(choice, ':')[:1]
execute "edit +".line filename
endfunction
function! FZY(input) abort
try
let choice = system('fzy', a:input)
finally
redraw!
endtry
return choice
endfunction
function! FZYExternal(cmd) abort
try
let choice = system(a:cmd . ' | fzy')
finally
redraw!
endtry
return choice
endfunction