Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
118 lines
3.4 KiB
VimL
118 lines
3.4 KiB
VimL
" vim match-up - even better matching
|
|
"
|
|
" Maintainer: Andy Massimino
|
|
" Email: a@normed.space
|
|
"
|
|
|
|
if !exists('g:loaded_matchup') || !exists('b:did_ftplugin')
|
|
finish
|
|
endif
|
|
|
|
let s:save_cpo = &cpo
|
|
set cpo&vim
|
|
|
|
function! s:has_plugin(plug)
|
|
return !empty(filter(split(&rtp,','), 'v:val =~? ''\<'.a:plug.'\>'''))
|
|
endfunction
|
|
|
|
let s:not_bslash = '\v%(\\@<!%(\\\\)*)@4<=\m'
|
|
|
|
function! s:get_match_words()
|
|
" left and right modifiers, any delimiters
|
|
let l:delim = '\%(\\\w\+\>\|\\[|{}]\|.\)'
|
|
let l:match_words = '\\left\>'.l:delim
|
|
\ .':\\middle\>'.l:delim
|
|
\ .':\\right\>'.l:delim
|
|
let l:match_words .= ',\(\\[bB]igg\?\)l\>'.l:delim
|
|
\ . ':\1m\>'.l:delim
|
|
\ . ':\1r\>'.l:delim
|
|
|
|
" un-sided sized, left and right delimiters
|
|
let l:mod = '\(\\[bB]igg\?\)'
|
|
let l:wdelim = '\%(angle\|floor\|ceil\|[vV]ert\|brace\)\>'
|
|
let l:ldelim = '\%(\\l'.l:wdelim.'\|\\[lu]lcorner\>\|(\|\[\|\\{\)'
|
|
let l:mdelim = '\%(\\vert\>\||\|\\|\)'
|
|
let l:rdelim = '\%(\\r'.l:wdelim.'\|\\[lu]rcorner\>\|)\|]\|\\}\)'
|
|
let l:mtopt = '\%(\%(\w\[\)\@2<!\|\%(\\[bB]igg\?\[\)\@6<=\)'
|
|
let l:match_words .= ','.l:mod.l:ldelim
|
|
\ . ':\1'.l:mdelim
|
|
\ . ':'.l:mtopt.'\1'.l:rdelim
|
|
|
|
" unmodified delimiters
|
|
let l:nomod = '\%(\\left\|\\right\|\[\@1<!\\[bB]igg\?[lr]\?\)\@6<!'
|
|
for l:pair in [['\\{', '\\}'], ['\[', ']'], ['(', ')'],
|
|
\ ['\\[lu]lcorner', '\\[lu]rcorner']]
|
|
let l:match_words .= ','.l:nomod.s:not_bslash.l:pair[0]
|
|
\ . ':'.l:nomod.s:not_bslash.l:pair[1]
|
|
endfor
|
|
let l:match_words .= ','.l:nomod.s:not_bslash.'\\l\('.l:wdelim.'\)'
|
|
\ . ':'.l:nomod.s:not_bslash.'\\r\1\>'
|
|
|
|
" the curly braces
|
|
let l:match_words .= ',{:}'
|
|
|
|
" latex equation markers
|
|
let l:match_words .= ',\\(:\\),'.s:not_bslash.'\\\[:\\]'
|
|
|
|
" simple blocks
|
|
let l:match_words .= ',\\if\%(\w\|@\)*\>:\\else\>:\\fi\>'
|
|
let l:match_words .= ',\\makeatletter:\\makeatother'
|
|
let l:match_words .= ',\\begingroup:\\endgroup,\\bgroup:\\egroup'
|
|
|
|
" environments
|
|
let l:match_words .= ',\\begin{tabular}'
|
|
\ . ':\\toprule\>:\\midrule\>:\\bottomrule\>'
|
|
\ . ':\\end{tabular}'
|
|
|
|
" enumerate, itemize
|
|
let l:match_words .= ',\\begin\s*{\(enumerate\*\=\|itemize\*\=\)}'
|
|
\ . ':\\item\>:\\end\s*{\1}'
|
|
|
|
" generic environment
|
|
let l:match_words .= ',\\begin\s*{\([^}]*\)}:\\end\s*{\1}'
|
|
|
|
return l:match_words
|
|
endfunction
|
|
|
|
function! s:setup_match_words()
|
|
setlocal matchpairs=(:),{:},[:]
|
|
let b:matchup_delim_nomatchpairs = 1
|
|
let b:match_words = s:get_match_words()
|
|
|
|
" the syntax method is too slow for latex
|
|
let b:match_skip = 'r:\\\@<!\%(\\\\\)*%'
|
|
|
|
" the old regexp engine is a bit faster '\%#=1'
|
|
let b:matchup_regexpengine = 1
|
|
|
|
let b:undo_ftplugin =
|
|
\ (exists('b:undo_ftplugin') ? b:undo_ftplugin . '|' : '')
|
|
\ . 'unlet! b:matchup_delim_nomatchpairs b:match_words'
|
|
\ . ' b:match_skip b:matchup_regexpengine'
|
|
endfunction
|
|
|
|
if get(g:, 'vimtex_enabled',
|
|
\ s:has_plugin('vimtex') || exists('*vimtex#init'))
|
|
if get(g:, 'matchup_override_vimtex', 0)
|
|
silent! nunmap <buffer> %
|
|
silent! xunmap <buffer> %
|
|
silent! ounmap <buffer> %
|
|
|
|
" lervag/vimtex/issues/1051
|
|
let g:vimtex_matchparen_enabled = 0
|
|
silent! call vimtex#matchparen#disable()
|
|
|
|
call s:setup_match_words()
|
|
else
|
|
let b:matchup_matchparen_enabled = 0
|
|
let b:matchup_matchparen_fallback = 0
|
|
endif
|
|
else
|
|
call s:setup_match_words()
|
|
endif
|
|
|
|
let &cpo = s:save_cpo
|
|
|
|
" vim: fdm=marker sw=2
|
|
|