From 90dfacf7bdddedd3bf9a0cde5572b0343d787313 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Tue, 4 Feb 2020 12:44:37 +0100 Subject: [PATCH] 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. --- nvim/.config/nvim/after/plugin/bibcite.vim | 9 +++- nvim/.config/nvim/maps.vim | 50 +++++++++++----------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/nvim/.config/nvim/after/plugin/bibcite.vim b/nvim/.config/nvim/after/plugin/bibcite.vim index d0d405f..9c61b5c 100644 --- a/nvim/.config/nvim/after/plugin/bibcite.vim +++ b/nvim/.config/nvim/after/plugin/bibcite.vim @@ -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': bibtex_ls(), @@ -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': bibtex_ls(), diff --git a/nvim/.config/nvim/maps.vim b/nvim/.config/nvim/maps.vim index 1c7b5df..c02e8be 100644 --- a/nvim/.config/nvim/maps.vim +++ b/nvim/.config/nvim/maps.vim @@ -158,25 +158,6 @@ nnoremap :FzfColors " Toggle background light/dark call togglebg#map("") -" 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 n :NV -noremap N :NV! -" PLUGIN: CtrlSF -" (non-fuzzy) search in wiki with ctrlsf, in fullscreen window -nnoremap wf :execute(":call SearchNotes()") - " 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 :GoCoverageToggle -short " go to the definition of whatever you hover over au FileType go nnoremap (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 n :NV +noremap N :NV! +" PLUGIN: CtrlSF +" (non-fuzzy) search in wiki with ctrlsf, in fullscreen window +nnoremap wF :execute(":call SearchNotes()") " 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 wf :WikiFzfPages +nnoremap l :WikiFzfTags nnoremap l :WikiFzfToc + " 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 = { \ '(wiki-link-toggle-operator)' : '======================', \} -" 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 q gqap @@ -233,11 +235,7 @@ noremap :Goyo " PLUGIN: fzf-bibtex " map @@ to automatically insert citation reference at cursor -inoremap @@ u:call fzf#run(fzf#wrap({ - \ 'source': bibtex_ls(), - \ 'sink*': function('bibtex_cite_sink_insert'), - \ 'up': '25%', - \ 'options': '--ansi --multi --prompt "Cite> "'})) +inoremap @@ u:CiteRef " map cc to insert a complete citation at cursor nnoremap cc :CiteRef " map cm to insert markdown prettified citation