Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepopulate blacklist variable #132

Open
xeruf opened this issue May 13, 2020 · 6 comments
Open

Prepopulate blacklist variable #132

xeruf opened this issue May 13, 2020 · 6 comments

Comments

@xeruf
Copy link

xeruf commented May 13, 2020

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.

@ntpeters
Copy link
Owner

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']

@xeruf
Copy link
Author

xeruf commented May 13, 2020

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

@ntpeters
Copy link
Owner

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?

@xeruf
Copy link
Author

xeruf commented May 14, 2020

Yes, this works for now, thank you :)

@Cimbali
Copy link
Collaborator

Cimbali commented May 15, 2020

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
Copy link
Collaborator

Cimbali commented Jul 31, 2020

Actually the VimEnter technique works for me in Vim 8.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants