vim-better-whitespace icon indicating copy to clipboard operation
vim-better-whitespace copied to clipboard

Prepopulate blacklist variable

Open xeruf opened this issue 4 years ago • 6 comments

I wanted to leave the original blacklist untouched and simply append a type (btw, even though it is a custom one from taskwarrior, you could add that in natively, because you should never highlight or strip white-space in that file - it is prepopulated with lots of trailing white-spaces and will be trimmed automatically on save):

let g:better_whitespace_filetypes_blacklist += ['taskedit']

But I got the error that the variable was undefined - how about predefining that variable so that we can extend it? My concern here is that if you update the blacklist, I would have to manually update mine. Also DRY.

xeruf avatar May 13 '20 19:05 xeruf

The variable is predefined, but plugins aren't yet loaded while your vimrc is being read. Setting an auto command to append to the list after startup should work:

autocmd VimEnter * let g:better_whitespace_filetypes_blacklist += ['taskedit']

ntpeters avatar May 13 '20 20:05 ntpeters

Ah, that makes sense, thanks! But unfortunately, this doesn't seem to work :/

xeruf avatar May 13 '20 21:05 xeruf

Hm, looks like that's due to the plugin setting everything up on FileType, WinEnter, and BufWinEnter events, all of which fire before VimEnter... 😕

I suppose a workaround would be to just disable it for that file type (with a check to prevent any errors if you ever don't load the plugin):

autocmd FileType taskedit if exists(":DisableWhitespace") | execute ":DisableWhitespace" | endif

@Cimbali, any ideas on a better way to handle this?

ntpeters avatar May 13 '20 23:05 ntpeters

Yes, this works for now, thank you :)

xeruf avatar May 14 '20 08:05 xeruf

I’m afraid I don’t have a better solution right now. I can see 2 only options:

  • copy the blacklist, or
  • add an “append to blacklist“ option

Cimbali avatar May 15 '20 09:05 Cimbali

Actually the VimEnter technique works for me in Vim 8.1

Cimbali avatar Jul 31 '20 09:07 Cimbali