Reformat bibtex section, add preliminary edit command
:CiteEdit added to fuzzy find a source and open it in vim for editing. The function is not working yet, I have to find a way to go from the fuzzy finder to papis, select the correct file and edit it in vim.
This commit is contained in:
parent
8fd5d274df
commit
f04b875859
1 changed files with 52 additions and 28 deletions
|
|
@ -228,43 +228,67 @@ function! Bibtex_ls(...)
|
|||
return 'bibtex-ls -cache ' . g:bibtex_cache . ' ' . g:bibtex_source . ' ' . join(a:000, ' ')
|
||||
endfunction
|
||||
|
||||
" insert citation from insert mode at cursor
|
||||
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>
|
||||
\ 'options': '--ansi --multi --prompt "Cite> "'})<CR>
|
||||
|
||||
" insert citation from normal mode at cursor
|
||||
function! s:bibtex_cite_sink(lines)
|
||||
let r=system("bibtex-cite ", 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 --multi --prompt "Cite> "'
|
||||
\ })
|
||||
|
||||
" insert pretty formatted markdown reference
|
||||
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=* CitePretty call skim#run({
|
||||
\ 'source': Bibtex_ls(<q-args>),
|
||||
\ 'sink*': function('<sid>bibtex_markdown_sink'),
|
||||
\ 'up': '25%',
|
||||
\ 'options': '--ansi --multi --prompt "Markdown> "'
|
||||
\ })
|
||||
|
||||
" edit the document info.yaml
|
||||
" needs papis to function
|
||||
" could be abstracted out to work with .bib file or the papis .yaml
|
||||
" TODO THESE FUNCTIONS DO NOT WORK YET. NEED TO FIND A WAY TO GO FROM fzf ->
|
||||
" papis -> editor
|
||||
function! s:bibtex_edit_info_sink(lines)
|
||||
echom "edit info sink: " . join(a:lines, ",")
|
||||
let r=system("bibtex-cite ", a:lines)
|
||||
let s=system("papis edit ref=\"" . join(a:lines,"") . "\"")
|
||||
" execute ':e s'
|
||||
echo s
|
||||
endfunction
|
||||
command! -bang -nargs=* CiteEdit call skim#run({
|
||||
\ 'source': Bibtex_ls(<q-args>),
|
||||
\ 'sink*': function('<sid>bibtex_edit_info_sink'),
|
||||
\ 'up': '25%',
|
||||
\ 'options': join([
|
||||
\ '--ansi',
|
||||
\ '--with-nth=..',
|
||||
\ '--preview-window=:wrap',
|
||||
\ '--prompt "Edit> "',
|
||||
\ '--preview=''papis edit -e cat ref="echo {} | bibtex-cite" '' ',
|
||||
\ ])
|
||||
\})
|
||||
|
||||
" PLUGIN: vim-go
|
||||
" change the tabstops for go to use tabs and a width of 4
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue