diff --git a/README.md b/README.md index e3c5494..64f4157 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,6 @@ match-up is a plugin that lets you highlight, navigate, and operate on sets of matching text. It extends vim's `%` key to language-specific words instead of just single characters. -[![Gitter](https://badges.gitter.im/vim-matchup/community.svg)](https://gitter.im/vim-matchup/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) - ## Screenshot diff --git a/after/ftplugin/html_matchup.vim b/after/ftplugin/html_matchup.vim index 1db634d..347c246 100644 --- a/after/ftplugin/html_matchup.vim +++ b/after/ftplugin/html_matchup.vim @@ -12,8 +12,8 @@ let s:save_cpo = &cpo set cpo&vim call matchup#util#patch_match_words( - \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>', - \ '<\@<=\([^/][^ \t>]*\)\%(>\|$\|[ \t][^>]*\%(>\|$\)\):<\@<=/\1>' + \ '[^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>', + \ '[^ \t>]*\)\%(>\|$\|[ \t][^>]*\%(>\|$\)\):<\@<=/\1>' \) if matchup#util#matchpref('nolists', diff --git a/autoload/matchup/loader.vim b/autoload/matchup/loader.vim index b7efba6..e78243b 100644 --- a/autoload/matchup/loader.vim +++ b/autoload/matchup/loader.vim @@ -35,7 +35,7 @@ function! matchup#loader#init_buffer() abort " {{{1 let l:has_ts_hl = 0 if s:ts_may_be_supported && matchup#ts_engine#is_hl_enabled(bufnr('%')) let l:has_ts_hl = 1 - + if matchup#ts_engine#get_option( \ bufnr('%'), 'additional_vim_regex_highlighting') if empty(&syntax) diff --git a/autoload/matchup/util.vim b/autoload/matchup/util.vim index 64488ce..584eaf2 100644 --- a/autoload/matchup/util.vim +++ b/autoload/matchup/util.vim @@ -68,35 +68,6 @@ endfunction " }}}1 -function! matchup#util#uniq(list) " {{{1 - if exists('*uniq') | return uniq(a:list) | endif - if len(a:list) <= 1 | return a:list | endif - - let l:uniq = [a:list[0]] - for l:next in a:list[1:] - if l:uniq[-1] != l:next - call add(l:uniq, l:next) - endif - endfor - return l:uniq -endfunction - -" }}}1 -function! matchup#util#uniq_unsorted(list) " {{{1 - if len(a:list) <= 1 | return a:list | endif - - let l:visited = [a:list[0]] - for l:index in reverse(range(1, len(a:list)-1)) - if index(l:visited, a:list[l:index]) >= 0 - call remove(a:list, l:index) - else - call add(l:visited, a:list[l:index]) - endif - endfor - return a:list -endfunction - -" }}}1 function! matchup#util#has_duplicate_str(list) " {{{1 if len(a:list) <= 1 | return 0 | endif let l:seen = {} @@ -133,7 +104,7 @@ function! matchup#util#patch_match_words(from, to, ...) abort " {{{1 endfunction " }}}1 -function! matchup#util#check_match_words(sha256) " {{{1 +function! matchup#util#check_match_words(sha256) abort " {{{1 if !exists('b:match_words') | return 0 | endif return sha256(b:match_words) =~# '^'.a:sha256 endfunction @@ -152,7 +123,7 @@ endfunction " }}}1 -function! matchup#util#matchpref(id, default) " {{{1 +function! matchup#util#matchpref(id, default) abort " {{{1 return get(get(g:matchup_matchpref, &filetype, {}), a:id, a:default) endfunction @@ -160,22 +131,38 @@ endfunction function! matchup#util#standard_html(...) abort " {{{1 let l:prefs = a:0 ? a:1 : {} + let l:variant = get(l:prefs, 'variant', 'html') let l:words = '<:>,<\@<=!--:-->' - if get(l:prefs, 'lists', 0) - let l:words .= ',<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>' - let l:words .= ',<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>' + if l:variant ==# 'html' && get(l:prefs, 'lists', 0) + let l:words .= ',<\@<=[ou]l\>\g{hlend}[^>]*\%(>\|$\)' + \ . ':<\@<=li\>' + \ . ':<\@<=/[ou]l\g{hlend}>' + let l:words .= ',<\@<=dl\>\g{hlend}[^>]*\%(>\|$\)' + \ . ':<\@<=d[td]\>' + \ . ':<\@<=/dl\g{hlend}>' endif - if get(l:prefs, 'tagnameonly', 1) - let l:words .= ',<\@<=\([^/][^ \t>]*\)\g{hlend}' + if l:variant ==# 'html' + let l:words .= ',<\@<=\([^/!][^ \t>]*\)\g{hlend}' \ . '\%(>\|$\|[ \t][^>]*\%(>\|$\)\)' \ . ':<\@<=/\1\g{hlend}>' - else - let l:words .= ',<\@<=\([^/][^ \t>]*\)' - \ . '\%(>\|$\|[ \t][^>]*\%(>\|$\)\)' + elseif l:variant ==# 'xml' + let l:words .= ',<\@<=!\[CDATA\[:]]>' + let l:words .= ',<\@<=?\k\+:?>' + let l:words .= ',<\@<=\([^ \t>/]\+\)\g{hlend}' + \ . '\%(\s\+[^>]*\%([^/]>\|$\)\|>\|$\)' \ . ':<\@<=/\1>' + let l:words .= ',<\@<=\%([^ \t>/]\+\)\g{hlend}' + \ . '\%(\s\+[^>]*[^/>]\|$\)' + \ . ':/>' + else + echoerr 'match-up: invalid variant' l:variant + endif + + if !get(l:prefs, 'tagnameonly', 1) + let l:words = substitute(l:words, '\\g{hlend}', '', 'g') endif return l:words diff --git a/doc/matchup.txt b/doc/matchup.txt index a504c45..0265171 100644 --- a/doc/matchup.txt +++ b/doc/matchup.txt @@ -6,7 +6,7 @@ Web: https://github.com/andymass/vim-matchup Script ID: 5624 License: MIT license {{{ - Copyright (c) 2021 Andy Massimino + Copyright (c) 2017--2022 Andy Massimino Copyright (c) 2016 Karl Yngve LervÄg