From a84c18f7aba0f411f08bcc3de7459f17b9824633 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 2 Sep 2019 21:44:54 +0200 Subject: [PATCH 1/4] [nvim] Add function to show all keymappings Use :ShowMaps to display all currently mapped things for vim. Will not include things like `i`, but actual mappings. --- .config/nvim/init.vim | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index cebfcf9..85dced0 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -358,6 +358,26 @@ call matchadd('ColorColumn', '\%81v', 100) " KEYBINDINGS {{{ " ================================================================================ " +" Show all mapped keys in a list - from https://stackoverflow.com/questions/13990136/display-a-ordered-vim-keyboard-mapping +function! s:ShowMaps() + let old_reg = getreg("a") " save the current content of register a + let old_reg_type = getregtype("a") " save the type of the register as well +try + redir @a " redirect output to register a + " Get the list of all key mappings silently, satisfy "Press ENTER to continue" + silent map | call feedkeys("\") + redir END " end output redirection + vnew " new buffer in vertical window + put a " put content of register + " Sort on 4th character column which is the key(s) + %!sort -k1.4,1.4 +finally " Execute even if exception is raised + call setreg("a", old_reg, old_reg_type) " restore register a +endtry +endfunction +" use :ShowMaps to call the function +com! ShowMaps call s:ShowMaps() " Enable :ShowMaps to call the function + " set our leader key to space since with hjkl, space is largely useless let mapleader = "\" " maps the leader for buffer local mappings (e.g. vim-waikiki for files under From 5f57994570d161ab91fac0f03760ed358634fc3e Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 2 Sep 2019 22:45:24 +0200 Subject: [PATCH 2/4] [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 From dcd3f07a8f3c37ed83414859c9aeb7f646e1c4f2 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 2 Sep 2019 23:21:56 +0200 Subject: [PATCH 3/4] [nvim] Add useful writing colorscheme Pencil is from reedes, cribbed from iWriter. It is a good, subdued colorscheme for writing prose. All colorschemes in this vimrc now come with italicized letters (for comments, and words that should be italic). All themes also respect the background= dark/light distinction and enable the respective mode. --- .config/nvim/init.vim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 65f3927..000178d 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -111,6 +111,7 @@ Plug 'edkolev/tmuxline.vim' " Colorschemes Plug 'morhetz/gruvbox' Plug 'rakr/vim-one' +Plug 'reedes/vim-colors-pencil' call plug#end() endif @@ -312,9 +313,14 @@ let g:ale_linters = { let g:airline_powerline_fonts=1 let g:airline_theme='raven' +" Enable italics for colorschemes that support them let g:gruvbox_italic=1 +let g:one_allow_italics=1 +let g:pencil_terminal_italics=1 + colorscheme gruvbox + " disable automatically refreshing the mux statusbar since it breaks tmux " prefix highlighting. Instead, when changing vim statusbar just create " snapshot with :TmuxlineSnapshot file and stick it into tmux config manually From 3ce896af43e2c0fc1e650e1b2eeb8d5e7ff336a1 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 2 Sep 2019 23:23:43 +0200 Subject: [PATCH 4/4] [nvim] Improve compilation filetype target Allows compilation using pandoc to happen for markdown, as well as rmarkdown files. --- .config/nvim/init.vim | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 000178d..606cd18 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -145,8 +145,6 @@ 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') @@ -499,8 +497,8 @@ au FileType go nnoremap (go-def) " 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 +autocmd FileType markdown,rmarkdown noremap c :RMarkdown pdf +autocmd FileType markdown,rmarkdown noremap C :RMarkdown! pdf " Call leaderf with (necessary to enable leaderf lazyloading) nnoremap F :LeaderfFile