~gpanders/dotfiles

5136277bfb3d2845f4b64a70575b0eb3659cf7ae — Greg Anders 1 year, 9 months ago 6a02efc
Update vim markdown settings

- Use 'commonmark' format with pandoc for formatprg
- Fix undo_ftplugin variable (forgot to change mapping)
- Remove custom syntax definitions that concealed links
- Update ft#markdown#open() regex pattern
M vim/.vim/after/ftplugin/markdown.vim => vim/.vim/after/ftplugin/markdown.vim +2 -2
@@ 18,7 18,7 @@ endif

if executable('pandoc')
  compiler pandoc
  let &l:formatprg = 'pandoc -f markdown -t markdown --atx-headers --standalone --columns=' . &textwidth
  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)


@@ 35,4 35,4 @@ 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> <S-CR>'
let b:undo_ftplugin .= '|nun <buffer> <CR>|nun <buffer> <C-W><CR>'

M vim/.vim/after/syntax/markdown.vim => vim/.vim/after/syntax/markdown.vim +0 -7
@@ 2,15 2,8 @@
syntax clear markdownCodeBlock
syn region markdownCodeBlock start="\n\(    \|\t\)" end="\v^((\t|\s{4})@!|$)" contained

syn region markdownLinkText matchgroup=markdownLinkTextDelimiter start="!\=\[\%(\_[^]]*]\%( \=[[(]\)\)\@=" end="\]\%( \=[[(]\)\@=" nextgroup=markdownLink,markdownId skipwhite contains=@markdownInline,markdownLineStart concealends
syn region markdownLink matchgroup=markdownLinkDelimiter start="(" end=")" contains=markdownUrl keepend contained conceal
syn region markdownId matchgroup=markdownIdDelimiter start="\[" end="\]" keepend contained conceal

" https://github.com/tpope/vim-markdown/pull/141/
hi def link markdownLinkDelimiter     Delimiter
hi def link markdownLinkTextDelimiter Delimiter

" Don't highlight pure whitespace lines, as these are sometimes useful in
" Markdown
let b:highlight_trailing_whitespace = 0
syn match TrailingWhitespace /\S\+\zs\\\@<!\s\+\%#\@<!$/ containedin=ALL

M vim/.vim/autoload/ft/markdown.vim => vim/.vim/autoload/ft/markdown.vim +1 -1
@@ 27,7 27,7 @@ function! ft#markdown#open(action) abort
        return
    endif

    let matches = matchlist(line, '\(\[[^]]\+\]\)\(([^)]\+)\|\[[^]]\+]\|\[]\|[^[(]\=\)', col-1)
    let matches = matchlist(line, '\(\[[^][]\+\]\)\(([^)]\+)\|\[[^]]\+]\|\[]\|[^[(]\=\)', col-1)
    if matches[2] =~# '([^)]\+)'
        " Normal link
        let link = matchstr(matches[2], '(\zs\([^)]\+\)\ze)')