Skip to content

Commit 303c191

Browse files
committed
feat(integration): Use <C-k>d to input docname in vim
1 parent 278f624 commit 303c191

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/sphinxnotes/snippet/integration/binding.vim

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function! g:SphinxNotesSnippetEdit(id)
1010
let file = system(join([s:snippet, 'get', '--file', a:id, '2>/dev/null'], ' '))
1111
let line = system(join([s:snippet, 'get', '--line-start', a:id, '2>/dev/null'], ' '))
1212
if &modified
13-
execute 'tabedit ' . file
13+
execute 'vsplit ' . file
1414
else
1515
execute 'edit ' . file
1616
endif
@@ -38,7 +38,22 @@ function! g:SphinxNotesSnippetListAndUrl()
3838
call g:SphinxNotesSnippetList(function('s:CallUrl'), 'ds')
3939
endfunction
4040

41+
function! g:SphinxNotesSnippetInput(id, item)
42+
let docname = system(join([s:snippet, 'get', '--' . a:item, a:id, '2>/dev/null'], ' '))
43+
let docname = substitute(docname, '\n\+$', '', '') " skip trailing \n
44+
execute 'normal! i:doc:`/' . docname . '`'
45+
endfunction
46+
47+
function! g:SphinxNotesSnippetListAndInputDocname()
48+
function! s:CallInputDocname(selection)
49+
call g:SphinxNotesSnippetInput(s:SplitID(a:selection), 'docname')
50+
endfunction
51+
call g:SphinxNotesSnippetList(function('s:CallInputDocname'), 'd')
52+
endfunction
53+
4154
nmap <C-k>e :call g:SphinxNotesSnippetListAndEdit()<CR>
4255
nmap <C-k>u :call g:SphinxNotesSnippetListAndUrl()<CR>
56+
nmap <C-k>d :call g:SphinxNotesSnippetListAndInputDocname()<CR>
57+
imap <C-k>d <Esc>:call g:SphinxNotesSnippetListAndInputDocname()<CR>a
4358
4459
" vim: set shiftwidth=2:

0 commit comments

Comments
 (0)