~gpanders/dotfiles

68988059705fa2ee3037aaa3c3f20d6f3ef5fc68 — Greg Anders 2 years ago c8591de
Update markdown ftplugin
2 files changed, 17 insertions(+), 9 deletions(-)

M vim/.vim/after/ftplugin/markdown.vim
M vim/.vim/autoload/ft/markdown.vim
M vim/.vim/after/ftplugin/markdown.vim => vim/.vim/after/ftplugin/markdown.vim +10 -9
@@ 5,13 5,7 @@ let b:undo_ftplugin = get(b:, 'undo_ftplugin', '')

let g:markdown_interp_languages = ['python', 'sh=bash', 'bash', 'ruby', 'console=bash']

if executable('pandoc')
  compiler pandoc
  setlocal formatprg=pandoc\ -f\ markdown\ -t\ markdown\ --reference-links
  let b:undo_ftplugin .= '|setl fp<'
endif

setlocal textwidth=72
setlocal textwidth=79
setlocal spell
" https://github.com/tpope/vim-markdown/issues/134
setlocal comments=n:>


@@ 23,9 17,16 @@ if has('conceal')
  let b:undo_ftplugin .= '|setl cole<'
endif

if executable('pandoc')
  compiler pandoc
  let &l:formatprg = 'pandoc -f gfm -t gfm --standalone --columns=' . &textwidth
  command! -buffer Toc exe '%!' . &l:formatprg . ' --toc'
  let b:undo_ftplugin .= '|setl fp<|delc Toc'
endif

" Use [[ and ]] to navigate between sections
nnoremap <buffer> <silent> [[ :<C-U>for _ in range(v:count1)<Bar>call search('^#', 'bsW')<Bar>endfor<CR>
nnoremap <buffer> <silent> ]] :<C-U>for _ in range(v:count1)<Bar>call search('^#', 'sW')<Bar>endfor<CR>
nnoremap <buffer> <silent> [[ :<C-U>call ft#markdown#section(1)<CR>
nnoremap <buffer> <silent> ]] :<C-U>call ft#markdown#section(0)<CR>
let b:undo_ftplugin .= '|nun <buffer> [[|nun <buffer> ]]'

nnoremap <buffer> <silent> Z! :<C-U>call ft#markdown#eval()<CR>

M vim/.vim/autoload/ft/markdown.vim => vim/.vim/autoload/ft/markdown.vim +7 -0
@@ 1,3 1,10 @@
function! ft#markdown#section(back)
    for _ in range(v:count1)
        call search('\%(^#\+ \|^\S.*\n^-\+$\|^\S.*\n^=\+$\)',
                    \ (a:back ? 'b' : '') . 'sW')
    endfor
endfunction

function! ft#markdown#eval()
  let view = winsaveview()
  let line = line('.')