Fix pandoc fzf citation adding location
Pandoc citations added through fzf (with the :CiteRef command) were added in place, with an i. The usual case however is to write a sentence, or part of a sentence, going out of insertion mode and wanting the citation to appear *after* what was written. Same story for insert mode citation (automatically called by typing `@@`); also simplified its calling function somewhat. Added simple maps for fzf finding note files from anywhere, searching through wiki tags.
This commit is contained in:
parent
7917b45859
commit
90dfacf7bd
2 changed files with 31 additions and 28 deletions
|
@ -16,10 +16,11 @@ function! s:bibtex_ls(...)
|
||||||
return source_cmd
|
return source_cmd
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" NORMAL MODE CITATION
|
||||||
" insert citation from normal mode at cursor (with brackets)
|
" insert citation from normal mode at cursor (with brackets)
|
||||||
function! s:bibtex_cite_sink(lines)
|
function! s:bibtex_cite_sink(lines)
|
||||||
let r=system("bibtex-cite ", a:lines)
|
let r=system("bibtex-cite ", a:lines)
|
||||||
execute ':normal! i[' . r . ']'
|
execute ':normal! a[' . r . ']'
|
||||||
endfunction
|
endfunction
|
||||||
command! -bang -nargs=* CiteRef call fzf#run(fzf#wrap({
|
command! -bang -nargs=* CiteRef call fzf#run(fzf#wrap({
|
||||||
\ 'source': <sid>bibtex_ls(<q-args>),
|
\ 'source': <sid>bibtex_ls(<q-args>),
|
||||||
|
@ -27,17 +28,21 @@ command! -bang -nargs=* CiteRef call fzf#run(fzf#wrap({
|
||||||
\ 'up': '25%',
|
\ 'up': '25%',
|
||||||
\ 'options': '--ansi --multi --prompt "Cite> "'
|
\ 'options': '--ansi --multi --prompt "Cite> "'
|
||||||
\ }))
|
\ }))
|
||||||
|
|
||||||
|
" INSERT MODE CITATION
|
||||||
" insert citation from insert mode at cursor (no brackets inserted)
|
" insert citation from insert mode at cursor (no brackets inserted)
|
||||||
function! s:bibtex_cite_sink_insert(lines)
|
function! s:bibtex_cite_sink_insert(lines)
|
||||||
let r=system("bibtex-cite ", a:lines)
|
let r=system("bibtex-cite ", a:lines)
|
||||||
execute ':normal! i' . r
|
execute ':normal! i' . r
|
||||||
call feedkeys('a', 'n')
|
call feedkeys('a', 'n')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" MARKDOWN CITATION
|
||||||
" insert markdown formatted reference
|
" insert markdown formatted reference
|
||||||
function! s:bibtex_markdown_sink(lines)
|
function! s:bibtex_markdown_sink(lines)
|
||||||
let r=system("bibtex-markdown -cache " . g:fzf_bibtex_cache . ' ' . join(g:fzf_bibtex_sources), a:lines)
|
let r=system("bibtex-markdown -cache " . g:fzf_bibtex_cache . ' ' . join(g:fzf_bibtex_sources), a:lines)
|
||||||
echo join(a:lines, '; ')
|
echo join(a:lines, '; ')
|
||||||
execute ':normal! i' . r
|
execute ':normal! a' . r
|
||||||
endfunction
|
endfunction
|
||||||
command! -bang -nargs=* CiteMarkdown call fzf#run(fzf#wrap({
|
command! -bang -nargs=* CiteMarkdown call fzf#run(fzf#wrap({
|
||||||
\ 'source': <sid>bibtex_ls(),
|
\ 'source': <sid>bibtex_ls(),
|
||||||
|
|
|
@ -158,25 +158,6 @@ nnoremap <leader><F8> :FzfColors<cr>
|
||||||
" Toggle background light/dark
|
" Toggle background light/dark
|
||||||
call togglebg#map("<F8>")
|
call togglebg#map("<F8>")
|
||||||
|
|
||||||
" Note Searching
|
|
||||||
" PLUGIN: Notational-FZF
|
|
||||||
" set notational-fzf-vim keys for the NV window itself
|
|
||||||
let g:nv_fzf_binds = [
|
|
||||||
\ 'alt-a:select-all',
|
|
||||||
\ 'alt-q:deselect-all',
|
|
||||||
\ 'alt-p:toggle-preview',
|
|
||||||
\ 'alt-u:page-up',
|
|
||||||
\ 'alt-d:page-down',
|
|
||||||
\ 'ctrl-w:backward-kill-word',
|
|
||||||
\ ]
|
|
||||||
" FZF note full-text search with notational-velocity like functions (in wiki
|
|
||||||
" directory)
|
|
||||||
noremap <leader>n :NV<cr>
|
|
||||||
noremap <leader>N :NV!<cr>
|
|
||||||
" PLUGIN: CtrlSF
|
|
||||||
" (non-fuzzy) search in wiki with ctrlsf, in fullscreen window
|
|
||||||
nnoremap <leader>wf :execute(":call SearchNotes()")<cr>
|
|
||||||
|
|
||||||
" PLUGIN: vim-go
|
" PLUGIN: vim-go
|
||||||
" vim-go mappings - will only activate in go files
|
" vim-go mappings - will only activate in go files
|
||||||
" most of this credit to https://hackernoon.com/my-neovim-setup-for-go-7f7b6e805876
|
" most of this credit to https://hackernoon.com/my-neovim-setup-for-go-7f7b6e805876
|
||||||
|
@ -195,10 +176,33 @@ au FileType go nnoremap <F9> :GoCoverageToggle -short<cr>
|
||||||
" go to the definition of whatever you hover over
|
" go to the definition of whatever you hover over
|
||||||
au FileType go nnoremap <F12> <Plug>(go-def)
|
au FileType go nnoremap <F12> <Plug>(go-def)
|
||||||
|
|
||||||
|
" Note Searching
|
||||||
|
" PLUGIN: Notational-FZF
|
||||||
|
" set notational-fzf-vim keys for the NV window itself
|
||||||
|
let g:nv_fzf_binds = [
|
||||||
|
\ 'alt-a:select-all',
|
||||||
|
\ 'alt-q:deselect-all',
|
||||||
|
\ 'alt-p:toggle-preview',
|
||||||
|
\ 'alt-u:page-up',
|
||||||
|
\ 'alt-d:page-down',
|
||||||
|
\ 'ctrl-w:backward-kill-word',
|
||||||
|
\ ]
|
||||||
|
" FZF note full-text search with notational-velocity like functions (in wiki
|
||||||
|
" directory)
|
||||||
|
noremap <leader>n :NV<cr>
|
||||||
|
noremap <leader>N :NV!<cr>
|
||||||
|
" PLUGIN: CtrlSF
|
||||||
|
" (non-fuzzy) search in wiki with ctrlsf, in fullscreen window
|
||||||
|
nnoremap <leader>wF :execute(":call SearchNotes()")<cr>
|
||||||
" PLUGIN: wiki.vim
|
" PLUGIN: wiki.vim
|
||||||
" use wiki.vim to look through document outlines in fzf (only for note
|
" use wiki.vim to look through document outlines in fzf (only for note
|
||||||
" directory atm)
|
" directory atm)
|
||||||
|
" leader is used when it is callable from anywhere
|
||||||
|
" localleader is used when it is specific to the local file
|
||||||
|
nnoremap <leader>wf :WikiFzfPages<cr>
|
||||||
|
nnoremap <leader>l :WikiFzfTags<cr>
|
||||||
nnoremap <localleader>l :WikiFzfToc<cr>
|
nnoremap <localleader>l :WikiFzfToc<cr>
|
||||||
|
|
||||||
" overwrites some default mappings I don't use, or that interfere with my own
|
" overwrites some default mappings I don't use, or that interfere with my own
|
||||||
" mappings TODO: currently this just assigns bogus shortcuts, since the plugin grumbles
|
" mappings TODO: currently this just assigns bogus shortcuts, since the plugin grumbles
|
||||||
" when setting to an empty string
|
" when setting to an empty string
|
||||||
|
@ -219,8 +223,6 @@ let g:wiki_mappings_global = {
|
||||||
\ '<plug>(wiki-link-toggle-operator)' : '<leader>======================',
|
\ '<plug>(wiki-link-toggle-operator)' : '<leader>======================',
|
||||||
\}
|
\}
|
||||||
|
|
||||||
" TODO The following should be put into a prose / compiled mapping module
|
|
||||||
|
|
||||||
" Mostly dealing with Prose writing from here on out
|
" Mostly dealing with Prose writing from here on out
|
||||||
" Format current Paragraph (esp useful in prose writing)
|
" Format current Paragraph (esp useful in prose writing)
|
||||||
nnoremap <silent> <localleader>q gqap
|
nnoremap <silent> <localleader>q gqap
|
||||||
|
@ -233,11 +235,7 @@ noremap <F11> :Goyo<CR>
|
||||||
|
|
||||||
" PLUGIN: fzf-bibtex
|
" PLUGIN: fzf-bibtex
|
||||||
" map @@ to automatically insert citation reference at cursor
|
" map @@ to automatically insert citation reference at cursor
|
||||||
inoremap <silent> @@ <c-g>u<c-o>:call fzf#run(fzf#wrap({
|
inoremap <silent> @@ <c-g>u<c-o>:CiteRef<CR>
|
||||||
\ 'source': <sid>bibtex_ls(),
|
|
||||||
\ 'sink*': function('<sid>bibtex_cite_sink_insert'),
|
|
||||||
\ 'up': '25%',
|
|
||||||
\ 'options': '--ansi --multi --prompt "Cite> "'}))<CR>
|
|
||||||
" map <leader>cc to insert a complete citation at cursor
|
" map <leader>cc to insert a complete citation at cursor
|
||||||
nnoremap <silent> <localleader>cc :CiteRef<cr>
|
nnoremap <silent> <localleader>cc :CiteRef<cr>
|
||||||
" map <leader>cm to insert markdown prettified citation
|
" map <leader>cm to insert markdown prettified citation
|
||||||
|
|
Loading…
Reference in a new issue