Sort vim plugin loading

This commit is contained in:
Marty Oehme 2020-02-04 11:36:42 +01:00
parent 2c374249d4
commit 36c202f48a
6 changed files with 10 additions and 8 deletions

View file

@ -0,0 +1 @@
:Prose

View file

@ -0,0 +1,47 @@
" set up fzf-bibtex
let g:fzf_bibtex_cache = '~/.cache/'
let g:fzf_bibtex_sources = g:pandoc#biblio#bibs
" prepare bibtex_ls function to look for bib files in cwd/parent/subdirs,
" attach the standard bibtex source file
" return the command with standard cache directory filled
function! s:bibtex_ls(...)
let bibfiles = (
\ globpath('.', '*.bib', v:true, v:true) +
\ globpath('..', '*.bib', v:true, v:true) +
\ globpath('*/', '*.bib', v:true, v:true)
\ )
let bibfiles = join(bibfiles, ' ')
let source_cmd = 'bibtex-ls -cache ' . g:fzf_bibtex_cache . ' ' .bibfiles . ' ' . join(g:fzf_bibtex_sources)
return source_cmd
endfunction
" 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 . ']'
endfunction
command! -bang -nargs=* CiteRef call fzf#run(fzf#wrap({
\ 'source': <sid>bibtex_ls(<q-args>),
\ 'sink*': function('<sid>bibtex_cite_sink'),
\ 'up': '25%',
\ 'options': '--ansi --multi --prompt "Cite> "'
\ }))
" 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
" 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
endfunction
command! -bang -nargs=* CiteMarkdown call fzf#run(fzf#wrap({
\ 'source': <sid>bibtex_ls(),
\ 'sink*': function('<sid>bibtex_markdown_sink'),
\ 'up': '25%',
\ 'options': '--ansi --multi --prompt "Markdown> "'
\ }))

View file

@ -0,0 +1,20 @@
" PROSE: function to automatically enables markdown plugins for md & txt files
function! s:Prose()
call plug#load('vim-pencil')
call plug#load('goyo.vim')
call plug#load('limelight.vim')
call pencil#init()
" PLUGIN: vim-textobj-sentence
" enable extended sentence textobject use on md and plaintext files
call textobj#sentence#init()
" hide the markdown cruft
setlocal conceallevel=2
setlocal foldlevel=2
endfunction
" enable syntax highlighting for codeblocks WITHIN markdown
let g:markdown_fenced_languages = ['html', 'python', 'bash=sh', 'javascipt', 'go']
" invoke it manually by writing :Prose
" or, it will get automatically sourced for certain filetypes in
" after/ftplugin directory
command! -nargs=0 Prose call s:Prose()