~gpanders/dotfiles

ref: 2da1dde5ea566f82ebe6532bc6d3b8670fd77ce8 dotfiles/vim/.vim/after/ftplugin/markdown.vim -rw-r--r-- 1.4 KiB
2da1dde5Greg Anders Note 'open' subcommand opens editor in NOTES_DIR when no argument given 1 year, 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
" Markdown filetype plugin
" Author: Greg Anders <greg@gpanders.com>

let b:undo_ftplugin = get(b:, 'undo_ftplugin', '')

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

setlocal textwidth=79
" https://github.com/tpope/vim-markdown/issues/134
setlocal comments=n:>
setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^\\s*[-*+]\\s\\+\\\|^\\[^\\ze[^\\]]\\+\\]:
let b:undo_ftplugin .= '|setl tw< com< flp<'

if has('conceal')
  setlocal conceallevel=2
  let b:undo_ftplugin .= '|setl cole<'
endif

if executable('pandoc')
  compiler pandoc
  let &l:formatprg = 'pandoc -f commonmark -t commonmark --standalone --columns=' . &textwidth
  setlocal formatexpr=ft#markdown#formatexpr()
  command! -buffer Toc call ft#markdown#toc()
  command! -bang -buffer Reflinks call ft#markdown#reflinks(<bang>0)
  let b:undo_ftplugin .= '|setl fp< fex<|delc Toc|delc Reflinks'
endif

" Use [[ and ]] to navigate between sections
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>
let b:undo_ftplugin .= '|nun <buffer> Z!'

nnoremap <buffer> <silent> <CR> :<C-U>call ft#markdown#open('edit')<CR>
nnoremap <buffer> <silent> <C-W><CR> :<C-U>call ft#markdown#open('split')<CR>
let b:undo_ftplugin .= '|nun <buffer> <CR>|nun <buffer> <C-W><CR>'