andymass / vim-matchup

vim match-up: even better % :facepunch: navigate and highlight matching words :facepunch: modern matchit and matchparen. Supports both vim and neovim + tree-sitter.
https://www.vim.org/scripts/script.php?script_id=5624
MIT License
1.71k stars 73 forks source link

Matchparen highlights one additional character in augroup XXX augroup END #7

Closed kiryph closed 6 years ago

kiryph commented 6 years ago

See following screenshot: matchup

andymass commented 6 years ago

Believe it or not, this is not a bug but is due to the definition of b:match_words in ftplugin/vim.vim.

Try the following (please do an update of the plugin first),

" file: test/issues/7/hotfix.vim
function! AugroupHotfix()
    call matchup#util#patch_match_words(
        \ '\<aug\%[roup]\s\+\%(END\>\)\@!\S:',
        \ '\<aug\%[roup]\s\+\%(END\>\)\@!\S\+:')
endfunction

let g:matchup_hotfix_vim = 'AugroupHotfix'

Equivalently, it could be patched to not show the augroup name.

Note: if you execute this after loading you must reload the test example using :edit.

kiryph commented 6 years ago

Thanks for clarifying this and considering it despite that is related to the definition in $VIMRUNTIME/ftplugin/vim.vim.

With your hotfix it looks now as following: untitled

I guess I would prefer that only the matched words are highlighted. This seems to be more consistent compared to if elseif etc.

Since this is actually not related to your plugin, I close this issue.

andymass commented 6 years ago

Thanks for testing. Here is an example which does not highlight the name.

" file: test/issues/7/hotfix2.vim
function! AugroupHotfix()
    call matchup#util#patch_match_words(
        \ '\<aug\%[roup]\s\+\%(END\>\)\@!\S:',
        \ '\<aug\%[roup]\s\+\%(END\>\)\@!\S\@=:')
endfunction

let g:matchup_hotfix_vim = 'AugroupHotfix'

Note that the hotfix function is general and can be used for any filetype with g:matchup_hotfix_{&filetype}.