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.68k stars 71 forks source link

"Unhighlight" match after a few seconds #18

Closed filipekiss closed 6 years ago

filipekiss commented 6 years ago

Hey Andy, first of all, thank you so much for the plugin. It really is a life saver, specially regarding the motions!

I have a doubt: Can you add an option to "unhighlight" the matches after a specified timeout? For example, I do have some legacy javascript and matchup perfectly matches the tags inside that strings, like the example below:

image

As you can see, when I'm inside the span, everything is highlighted. So visual selection doesn't work properly (I mean, I can still use visual select and it will yank/change/delete, but I can't see the visual selection itself).

Maybe add an option to remove the highlight after I've been in the tag, so I can set for something like, 2 seconds, and after that it won't highlight that part again until I leave that tag and comeback to it?

(Or if you have any suggestions on how I can circumvent this problem, I'm all ears).

Here's my matchup config, but I don't think that's the cause (running with the default options yields the same result)

" Enable experimental transmute module
" See https://github.com/andymass/vim-matchup#d1-parallel-transmutation
let g:matchup_transmute_enabled = 1

" Deferred highlight for performance reasons
let g:matchup_matchparen_deferred = 1

" Adjust highlight timeouts
let g:matchup_matchparen_timeout = 150
let g:matchup_matchparen_insert_timeout = 30

Thank you for your time :)

andymass commented 6 years ago

Thanks, I think this should be relatively easy to accomplish since you're using the "deferred" style of highlighting which uses already timers. I will look into it.

But first.. I will quickly mention that you may want to adjust your highlighting so that visual and matching are distinct regardless. For instance (these colors are ugly, you will want to adjust them to your tastes),

highlight Visual guifg=white guibg=black ctermfg=white ctermbg=black
highlight MatchParen guifg=yellow guibg=blue ctermfg=yellow ctermbg=blue 

Which color scheme are you using? Different schemes set these colors differently.

filipekiss commented 6 years ago

@andymass Thank you for the quick response!

I'm currently using gruvbox, that's my go to theme, but I do have my moments where I change to something else just to look to some different colors.

The highlight groups worked great for now! (I'll just need to adjust the colors, I'll look into how I should do that to use my current theme colors).

Thanks for the help!


Edit: Just found out about hi! link <highlightGroup> <highlightGroup> and I guess I'm going to use that to make it work with more themes out of the box!