Add fuzzy citation tools to vim
Use <leader>c to insert a bibtex reference in your text. By default it is a pandoc reference (@bibref), but it can be changed to latex style (\cite(bibref)). <leader>CM inserts a pretty-printed reference to the selected work, using markdown styling. If you want to insert a citation while writing, use @@ from insertmode to insert the bibref instead. The settings add two commands: :CiteRef and :CitePretty which call the respective functions. You can pass any amount of .bibtex libraries to the commands and they will be available to fuzzy search through.
This commit is contained in:
parent
c5ee7b6ca2
commit
8fd5d274df
1 changed files with 56 additions and 1 deletions
|
|
@ -219,6 +219,53 @@ endfunction
|
|||
autocmd! User GoyoEnter nested call <SID>goyo_enter()
|
||||
autocmd! User GoyoLeave nested call <SID>goyo_leave()
|
||||
|
||||
" PLUGIN: fzf-bibtex
|
||||
" Citation and Bibtex utilities
|
||||
let g:bibtex_cache = '/home/marty/.cache/'
|
||||
let g:bibtex_source = '/home/marty/Nextcloud/Library/academia/academia.bib'
|
||||
|
||||
function! Bibtex_ls(...)
|
||||
return 'bibtex-ls -cache ' . g:bibtex_cache . ' ' . g:bibtex_source . ' ' . join(a:000, ' ')
|
||||
endfunction
|
||||
|
||||
function! s:bibtex_cite_sink_insert(lines)
|
||||
let r=system("bibtex-cite ", a:lines)
|
||||
execute ':normal! i' . r
|
||||
call feedkeys('a', 'n')
|
||||
endfunction
|
||||
|
||||
function! s:bibtex_cite_sink(lines)
|
||||
let r=system("bibtex-cite ", a:lines)
|
||||
execute ':normal! i' . r
|
||||
endfunction
|
||||
|
||||
function! s:bibtex_markdown_sink(lines)
|
||||
let r=system("bibtex-markdown " . g:bibtex_source, a:lines)
|
||||
echo join(a:lines, '; ')
|
||||
execute ':normal! i' . r
|
||||
endfunction
|
||||
|
||||
command! -bang -nargs=* CiteRef call skim#run({
|
||||
\ 'source': Bibtex_ls(<q-args>),
|
||||
\ 'sink*': function('<sid>bibtex_cite_sink'),
|
||||
\ 'up': '25%',
|
||||
\ 'options': '--ansi --tac --multi --prompt "Cite> "'
|
||||
\ })
|
||||
|
||||
" pretty-cite a source by turning it into markdown
|
||||
command! -bang -nargs=* CitePretty call skim#run({
|
||||
\ 'source': Bibtex_ls(<q-args>),
|
||||
\ 'sink*': function('<sid>bibtex_markdown_sink'),
|
||||
\ 'up': '25%',
|
||||
\ 'options': '--ansi --tac --multi --prompt "Markdown> "'
|
||||
\ })
|
||||
|
||||
inoremap <silent> @@ <c-g>u<c-o>:call skim#run({
|
||||
\ 'source': Bibtex_ls(),
|
||||
\ 'sink*': function('<sid>bibtex_cite_sink_insert'),
|
||||
\ 'up': '25%',
|
||||
\ 'options': '--ansi --layout=reverse-list --multi --prompt "Cite> "'})<CR>
|
||||
|
||||
" PLUGIN: vim-go
|
||||
" change the tabstops for go to use tabs and a width of 4
|
||||
" this conforms with the gofmt expectations
|
||||
|
|
@ -470,8 +517,11 @@ noremap <C-F> :Rg<cr>
|
|||
noremap <leader>n :NV<cr>
|
||||
noremap <leader>N :NV!<cr>
|
||||
|
||||
" FZF git diff
|
||||
noremap <leader>gd :GFiles?<cr>
|
||||
|
||||
" Configure notational-fzf-vim
|
||||
let g:nv_search_paths = [ '~/Nextcloud/Notes/' ]
|
||||
let g:nv_search_paths = [ g:wiki_root ]
|
||||
let g:nv_wrap_preview_text=1
|
||||
" Dictionary with string keys and values. Must be in the form 'ctrl-KEY':
|
||||
" 'command' or 'alt-KEY' : 'command'. See examples below.
|
||||
|
|
@ -499,6 +549,11 @@ nnoremap <leader>wF :execute(":call SearchWiki()")<cr>
|
|||
nnoremap <leader>wf :execute(":call RgWiki()")<cr>
|
||||
vnoremap <C-F> <Plug>CtrlSFVwordPath
|
||||
|
||||
" insert a citation of a source using bib ref (uses academia library)
|
||||
nnoremap <leader>c :CiteRef<cr>
|
||||
" insert a pretty printed Markdown version of a reference
|
||||
nnoremap <leader>CM :CitePretty<cr>
|
||||
|
||||
" Mostly dealing with Prose writing from here on out
|
||||
" Format current Paragraph (esp useful in prose writing)
|
||||
nnoremap <silent> <leader>q gqap
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue