From 5f57994570d161ab91fac0f03760ed358634fc3e Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 2 Sep 2019 22:45:24 +0200 Subject: [PATCH] [nvim] Add rmarkdown, pandoc plugins and bindings PDFs can be compiled using rmarkdown by invoking c, or C to open the file (which pauses vim however). The best workflow is to open the pdf manually in something like zathura, which will auto-update when the document is newly compiled. --- .config/nvim/init.vim | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 85dced0..65f3927 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -82,6 +82,11 @@ Plug 'junegunn/goyo.vim', { 'for': ['markdown', 'txt'], 'on': 'Goyo' } " provide Plug 'junegunn/limelight.vim', { 'for': ['markdown', 'txt'], 'on': 'Goyo' } " provide even distraction free-er writing (lowlight paragraphs) Plug 'rhysd/vim-grammarous', { 'for': ['markdown', 'txt'], 'on': 'Goyo' } " integrate vim with languagetool for grammar checking (needs java8) +" RMarkdown & LaTeX workflow +Plug 'vim-pandoc/vim-pandoc-syntax' +Plug 'vim-pandoc/vim-pandoc' +Plug 'vim-pandoc/vim-rmarkdown' + " Note-Taking Workflow Plug 'lervag/wiki.vim' @@ -139,8 +144,11 @@ augroup END au! BufRead,BufNewFile *.markdown set filetype=markdown au! BufRead,BufNewFile *.md set filetype=markdown au! BufRead,BufNewFile *.mkd set filetype=markdown +au! BufRead,BufNewFile *.rmd set filetype=markdown +au! BufRead,BufNewFile *.Rmd set filetype=markdown " automatically enables markdown plugins for md & txt files function! Prose() + call plug#load('vim-pencil') call pencil#init() " PLUGIN: vim-textobj-sentence " enable extended sentence textobject use on md and plaintext files @@ -152,10 +160,25 @@ endfunction let g:markdown_fenced_languages = ['html', 'python', 'bash=sh', 'javascipt', 'go'] " call the prose function defined above for any md files -autocmd FileType markdown,txt call Prose() +autocmd FileType markdown,txt,rmarkdown call Prose() " or invoke it manually by writing :Prose command! -nargs=0 Prose call Prose() +" PLUGIN: vim-pandoc +let g:pandoc#modules#enabled=["metadata", "toc", "hypertext", "command"] +let g:pandoc#command#prefer_pdf=1 +let g:pandoc#biblio#bibs=["~/Nextcloud/Library/academia/academia.bib"] +let g:pandoc#completion#bib#mode='citeproc' +let g:pandoc#keyboard#use_default_mappings=0 +let g:pandoc#folding#level=2 +let g:pandoc#folding#fold_yaml=1 +let g:pandoc#folding#fastfolds=1 +let g:pandoc#spell#default_langs=["en_us", "de_de"] +let g:pandoc#hypertext#ausosave_on_edit_open_link=1 +let g:pandoc#hypertext#create_if_no_alternates_exists=1 +" configuration for vim-pandoc and vim-rmarkdown +let g:pandoc#syntax#conceal#use = 0 + " PLUGIN: wiki.vim if $WIKIROOT ==? "" let g:wiki_root = '~/Nextcloud/Notes/' @@ -465,6 +488,14 @@ au FileType go nnoremap :GoCoverageToggle -short " go to the definition of whatever you hover over au FileType go nnoremap (go-def) +" Markdown & Pandoc compilation group +" the commented out command can be used if vim-rmarkdown plugin is not +" installed (it is a bit more brittle) +" autocmd FileType rmd noremap :!echo"require(rmarkdown);render('%')"\|R--vanilla +" Compile with rmarkdown +autocmd FileType markdown noremap c :RMarkdown pdf +autocmd FileType markdown noremap C :RMarkdown! pdf + " Call leaderf with (necessary to enable leaderf lazyloading) nnoremap F :LeaderfFile nnoremap f :LeaderfBuffer