Skip to content

Instantly share code, notes, and snippets.

@andymass
Created December 2, 2017 14:19
Show Gist options
  • Save andymass/370543c3853b473be099cad7ea548f1c to your computer and use it in GitHub Desktop.
Save andymass/370543c3853b473be099cad7ea548f1c to your computer and use it in GitHub Desktop.
TeX match_words prototype
let s:not_bslash = g:matchup#re#not_bslash
function! s:gen_match_words()
let l:delims = [
\ [ '\\l\(angle\|floor\|ceil\|[vV]ert\)\>', '\\r\1\>'],
\ [ '\\ulcorner\>', '\\urcorner\>' ],
\ [ '(', ')' ],
\ [ s:not_bslash.'\[', s:not_bslash.']' ],
\ [ '\\{', '\\}' ]
\]
let l:mods = [
\ ['\\left', '\\right'],
\ ['\(\\[bB]igg\?\)l', '\1r'],
\ ['\(\\[bB]igg\?\)', '\1'],
\ ['\%(\\left\|\\[bB]igg\?l\?\)\@<!',
\ '\%(\\right\|\\[bB]igg\?r\?\)\@<!'],
\]
let l:match_words = ''
for l:d in l:delims
for l:m in l:mods
let l:match_words .= (empty(l:match_words) ? '' : ',')
\ . l:m[0].l:d[0].':'.l:m[1]
\ . (l:m[1] =~# '\\1'
\ ? substitute(l:d[1], '\\1', '\\2', 'g') : l:d[1])
endfor
endfor
let l:match_words .= ',{:},\\(:\\),\\\[:\\]'
let l:match_words .= ',\\begin\s*\({[^}]*}\):\\end\s*\1'
return l:match_words
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment