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:
Marty Oehme 2020-02-04 12:44:37 +01:00
parent 7917b45859
commit 90dfacf7bd
2 changed files with 31 additions and 28 deletions

View file

@ -16,10 +16,11 @@ function! s:bibtex_ls(...)
return source_cmd
endfunction
" NORMAL MODE CITATION
" insert citation from normal mode at cursor (with brackets)
function! s:bibtex_cite_sink(lines)
let r=system("bibtex-cite ", a:lines)
execute ':normal! i[' . r . ']'
execute ':normal! a[' . r . ']'
endfunction
command! -bang -nargs=* CiteRef call fzf#run(fzf#wrap({
\ 'source': <sid>bibtex_ls(<q-args>),
@ -27,17 +28,21 @@ command! -bang -nargs=* CiteRef call fzf#run(fzf#wrap({
\ 'up': '25%',
\ 'options': '--ansi --multi --prompt "Cite> "'
\ }))
" INSERT MODE CITATION
" insert citation from insert mode at cursor (no brackets inserted)
function! s:bibtex_cite_sink_insert(lines)
let r=system("bibtex-cite ", a:lines)
execute ':normal! i' . r
call feedkeys('a', 'n')
endfunction
" MARKDOWN CITATION
" insert markdown formatted reference
function! s:bibtex_markdown_sink(lines)
let r=system("bibtex-markdown -cache " . g:fzf_bibtex_cache . ' ' . join(g:fzf_bibtex_sources), a:lines)
echo join(a:lines, '; ')
execute ':normal! i' . r
execute ':normal! a' . r
endfunction
command! -bang -nargs=* CiteMarkdown call fzf#run(fzf#wrap({
\ 'source': <sid>bibtex_ls(),

View file

@ -158,25 +158,6 @@ nnoremap <leader><F8> :FzfColors<cr>
" Toggle background light/dark
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
" vim-go mappings - will only activate in go files
" 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
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
" use wiki.vim to look through document outlines in fzf (only for note
" 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>
" 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
" when setting to an empty string
@ -219,8 +223,6 @@ let g:wiki_mappings_global = {
\ '<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
" Format current Paragraph (esp useful in prose writing)
nnoremap <silent> <localleader>q gqap
@ -233,11 +235,7 @@ noremap <F11> :Goyo<CR>
" PLUGIN: fzf-bibtex
" map @@ to automatically insert citation reference at cursor
inoremap <silent> @@ <c-g>u<c-o>:call fzf#run(fzf#wrap({
\ 'source': <sid>bibtex_ls(),
\ 'sink*': function('<sid>bibtex_cite_sink_insert'),
\ 'up': '25%',
\ 'options': '--ansi --multi --prompt "Cite> "'}))<CR>
inoremap <silent> @@ <c-g>u<c-o>:CiteRef<CR>
" map <leader>cc to insert a complete citation at cursor
nnoremap <silent> <localleader>cc :CiteRef<cr>
" map <leader>cm to insert markdown prettified citation