dotfiles/.config/nvim/pluglist/prose.vim

57 lines
2.5 KiB
VimL

" 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 <g)> or last <g(> 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 <SID>goyo_enter()
autocmd! User GoyoLeave nested call <SID>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()