From ae1a477301c8def871201ea2541b340c8ec0f8a8 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 23 Nov 2019 17:52:29 +0100 Subject: [PATCH] Add prose module to vim --- .config/alacritty/alacritty.yml | 2 +- .config/nvim/init.vim | 2 +- .config/nvim/pluglist/design.vim | 2 +- .config/nvim/pluglist/prose.vim | 57 ++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 .config/nvim/pluglist/prose.vim diff --git a/.config/alacritty/alacritty.yml b/.config/alacritty/alacritty.yml index afe07b0..574923c 100644 --- a/.config/alacritty/alacritty.yml +++ b/.config/alacritty/alacritty.yml @@ -290,7 +290,7 @@ onelight: &one-light cyan: '0x3E999F' white: '0xF5F5F5' -colors: *one-light +colors: *gruvbox-dark # Visual Bell # diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index b46c5a1..54f4f74 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -40,7 +40,7 @@ runtime! pluglist/**/*.vim call plug#end() endif -colo one +colo gruvbox " }}} " VIM SETTINGS {{{ diff --git a/.config/nvim/pluglist/design.vim b/.config/nvim/pluglist/design.vim index 767984a..1ce40de 100644 --- a/.config/nvim/pluglist/design.vim +++ b/.config/nvim/pluglist/design.vim @@ -33,4 +33,4 @@ let g:one_allow_italics=1 let g:pencil_terminal_italics=1 " per this discussion: https://github.com/junegunn/vim-plug/issues/300 -autocmd VimEnter * colorscheme one +autocmd VimEnter * colorscheme gruvbox diff --git a/.config/nvim/pluglist/prose.vim b/.config/nvim/pluglist/prose.vim new file mode 100644 index 0000000..16cc276 --- /dev/null +++ b/.config/nvim/pluglist/prose.vim @@ -0,0 +1,57 @@ +" Prose Workflow +Plug 'kana/vim-textobj-user' " dependency for most other textobj plugins +Plug 'reedes/vim-textobj-sentence' " extends the capabilities of sentence detection +" and allows you to jump to the *end* of this or last sentence. + +Plug 'reedes/vim-pencil', { 'for': ['markdown', 'txt'], 'on': 'Goyo' } " provide md convenience functions like hard/softwrap +" PLUGIN: vim-pencil +" set default wrap mode to hard - TODO test which mode works better for +" me, it seems hardmode has trouble with markdown lists (see issue #31) +let g:pencil#wrapModeDefault = 'soft' " default is 'hard' + +Plug 'junegunn/goyo.vim', { 'for': ['markdown', 'txt'], 'on': 'Goyo' } " provide distraction free writing +" PLUGIN: goyo +" set up functions for entering/exiting distraction free mode, or leaving it +function! s:goyo_enter() + " remove the tmux status bar for actual distraction free environment + silent !tmux set status off + " maximize the tmux pane that vim is in if any (usually I have vim open as the only pane) + silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z + " disable line highlighting, we really don't need it for prose + set nocursorline + " enable limelight which highlights whatever paragraph you are in and lowlights the rest + Limelight +endfunction +function! s:goyo_leave() + silent !tmux set status on + silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z + set cursorline + Limelight! +endfunction +" actually call the functions on entering/leaving goyo +autocmd! User GoyoEnter nested call goyo_enter() +autocmd! User GoyoLeave nested call goyo_leave() + + +Plug 'junegunn/limelight.vim', { 'for': ['markdown', 'txt'], 'on': 'Goyo' } " provide even distraction free-er writing (lowlight paragraphs) + +" PROSE: function to automatically enables markdown plugins for md & txt files +function! 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'] + +" call the prose function defined above for any md files +au FileType pandoc,markdown,md,mkd call Prose() +" or invoke it manually by writing :Prose +command! -nargs=0 Prose call Prose()