Closed k0kubun closed 10 years ago
Hi, I love the concept but the MatchExtraWhitespace function seems kind of messy.
Do you think you could try organizing it something like this?
function! ShouldMatchWhitespace()
return false if file type should be ignored
return true otherwise
endfunction
autocmd BufWinEnter * if call ShouldMatchWhitespace() | match ExtraWhitespace /\s\+$/ | endif
autocmd InsertLeave * if call ShouldMatchWhitespace() | match ExtraWhitespace /\s\+$/ | endif
autocmd InsertEnter * if call ShouldMatchWhitespace() | match ExtraWhitespace /\s\+\%#\@<!$/ | endif
That mess is just off the top of my head, just meant as illustration... But I hope organizing it like this makes it easier to read.
Thanks!
Thank you for your nice review! I'm a beginner of Vim script, so your comment was very helpful.
Your concept works well and I refactored my code, squashed the commits and force pushed.
Looks great!
The if ft ==# &filetype | return 0 | endif
looks a little odd but I can't think of anything better so maybe it's just Vim that's odd. :) Thanks!
I have a problem with the combination of this plugin and unite.vim. Because unite.vim shows extra whitespace from the end of the line, the unite buffer becomes like this. So I want this plugin not to highlight buffer with unite FileType.
And markdown needs extra whitespace to start a new line, I want to disable this highlight for buffer with mkd FileType too.
So I introduced
g:extra_whitespace_ignored_filetypes
option to solve such problems.