vim-indent-guides icon indicating copy to clipboard operation
vim-indent-guides copied to clipboard

indent guides overwrite Todo

Open shawn-sterling opened this issue 12 years ago • 8 comments
trafficstars

Hello, I have

match Todo /\s\+$/

in my vimrc, so that whitespace stands out like crazy (because whitespace is evil). When indent guides are turned on, or if

let g:indent_guides_enable_on_vim_startup = 1

I no longer see the whitespace (Todo) match.

If I turn on indent guides then do a

:match Todo /\s\+$/

then I have working indent guides as well as the Todo match. I thought this might be an order of operations issue, so I put the match statement as the last line of my .vimrc, but that doesn't work.

Do you have any suggestions?

Thanks.

-Shawn

shawn-sterling avatar Aug 27 '13 18:08 shawn-sterling

Moving the :match to the end of the vimrc doesn't change anything because plugins are loaded after the vimrc.

The reference doesn't say, but I'm wondering if the priority of :match is the same as the default priority of matchadd(). Try changing the calls to matchadd() in autoload/indent_guides.vim to include a priority argument of -1 (e.g., https://github.com/nathanaelkane/vim-indent-guides/blob/master/autoload/indent_guides.vim#L55 call add(w:indent_guides_matches, matchadd(l:group, l:soft_pattern, -1)))

The priority of 'hlsearch' is 0, so I recommend changing the plugin to use negative priority values to avoid overruling :match or 'hlsearch'.

graywh avatar Aug 28 '13 02:08 graywh

That worked! Thank you very much!

Not sure if I should close the issue or if that might be a good change for the plugin?

shawn-sterling avatar Aug 28 '13 21:08 shawn-sterling

I wasn't able to replicate the problem on my end, but I don't see the harm in adding the lower priority to matchadd calls. Will test it for a few days and see how it goes.

nathanaelkane avatar Aug 28 '13 23:08 nathanaelkane

Okay, I figured out how to replicate the issue, and found another one (I can open another issue if preferred).

I changed my .vimrc to be the absolute minimum, and put it here: https://gist.github.com/shawn-sterling/6382925

Using .vimrc-1 , and editing 'install.pp' (also in that gist) it looks like this (not correct): http://imgur.com/OSU5VXh,nSpk6Qk,xir1g5b,u6yFdgC#0

NOTE: The indent column colors may be hard to see depending on your monitor settings

If I change to .vimrc-2 (which is just commenting out the autocommand) OR make the change graywh suggested it will correctly look like this: http://imgur.com/OSU5VXh,nSpk6Qk,xir1g5b,u6yFdgC#1

The problem also goes away if I do not set the IndentGuides in the .vimrc.

The next problem is with vim tabs. If I do a

vim -p install.pp install.pp

The first tab will look correct (with graywh's change), but the second tab won't have any of the Match highlights as you can see here: http://imgur.com/OSU5VXh,nSpk6Qk,xir1g5b,u6yFdgC#2

Have a good day.

-Shawn

shawn-sterling avatar Aug 29 '13 20:08 shawn-sterling

:matches are added to the window, in this case just the first one (not related to indent guides at all).

graywh avatar Aug 29 '13 21:08 graywh

Thank you again graywh! I did not know that was how vim worked for the matching.

I have read a lot more about matching, and have now worked around the second problem with the following modification to my .vimrc

hi ExtraWhitespace ctermbg=yellow
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()

However, the first problem is still there, but all works as it should with graywh's suggested change.

shawn-sterling avatar Aug 29 '13 21:08 shawn-sterling

I'm having the same issue with my extraneous whitespace matching. The following commands are what I'm using:

autocmd InsertEnter * syn clear EOLWS | syn match EOLWS excludenl /\s\+\%#\@!$/
autocmd InsertLeave,BufReadPost * syn clear EOLWS | syn match EOLWS excludenl /\s\+$/

I've attempted the modifications that graywh suggested, but to no avail. Is there any other way to have this whitespace checking overwrite the indent guides on lines that are empty except for whitespace?

ntpeters avatar Feb 04 '14 01:02 ntpeters

I managed to solve the issue by reducing the match priority as suggested by graywh, and ended up writing my own plugin that makes highlighting and cleaning extra whitespace a bit nicer: https://github.com/ntpeters/vim-better-whitespace

ntpeters avatar Feb 09 '14 20:02 ntpeters