Skip to content

Commit 3648237

Browse files
committed
update
1 parent 7b84022 commit 3648237

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

integration/plugin.vim

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
" Vim integration for sphinxnotes-snippet
2+
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
"
4+
" :Author: Shengyu Zhang
5+
" :Date: 2021-04-01
6+
" :License: BSD
7+
"
8+
" NOET: fzf.vim is required
9+
10+
let s:snippet = 'snippet'
11+
12+
function! s:SplitID(row)
13+
let id = split(a:row, ' ')[0]
14+
endfunction
15+
16+
function! g:SphinxNotesSnippetList(callback, kinds)
17+
" Closure for ID
18+
let l:id = ''
19+
20+
let l:cmd = [s:snippet, 'list', '--kinds', a:kinds]
21+
call fzf#run({
22+
\ 'source': join(l:cmd, ' '),
23+
\ 'sink': callback,
24+
\ 'options': ['--with-nth', '2..', '--no-hscroll', '--header-lines', '1'],
25+
\ })
26+
echoerr l:id
27+
endfunction
28+
29+
function! g:SphinxNotesSnippetView()
30+
call g:SphinxNotesSnippetList(function('s:PostView'), 'c')
31+
32+
function! s:PostView(selection)
33+
let l:id = s:SplitID(a:selection)
34+
copen
35+
endfunction
36+
endfunction
37+
38+
call g:SphinxNotesSnippetList('c')
39+
40+
" vim: set shiftwidth=2:

0 commit comments

Comments
 (0)