vim-utils / vim-troll-stopper

Stop Unicode trolls from messing with your code.
MIT License
177 stars 4 forks source link

Stop for certain filetypes? #4

Open for-coursera opened 8 years ago

for-coursera commented 8 years ago

Is it possible to stop the plugin for certain filetypes? Something like

autocmd FileType mkd let g:loaded_troll_stopper = 0 

may be? (The example above one doesn't work but I use it here only to illustrate the idea...)

EDITED: Or, may be, vice versa, only enable it for some filetypes?

bruno- commented 8 years ago

Hi, unfortunately this wouldn't be so easy to add as one might expect.

I'm aware it's a common feature of many plugins to enable/disable functionality for a given filetype. This is hard-ish for this plugin because highlighting of "troll" chars is added on a per-window (vim window) basis. This was not an intentional decision, it's the way vim enables adding highlight groups dynamically. More about this can be read in vim's help :h matchadd().

Would you mind sharing a bit how would you use the disable feature if it existed? Why would you disable this plugin in markdown files?

for-coursera commented 8 years ago

Bruno,

Thanks for you interest and explanation!

As per your question, it's pretty simple: I use Vim for my writings in Russian (UTF-8), too (be it Markdown, HTML, plain text or something else) – and troll-stopper, as one may expect, starts to highlight characters it thinks are wrong (like Russian letters "с", "о", "е", "а", etc) :).

bruno- commented 8 years ago

Hey, that makes sense.

How about adding an option g:whitelist_troll_stopper = ['с', 'о'...] so that those characters are never highlighted?

This could make sense as you might have Russian characters in the actual code files as a part of strings or comments.

for-coursera commented 8 years ago

But doesn't that destroy the whole idea of the plugin? :) Especially, in this particular case – since switching between languages now and then may introduce additional typos in the code...

Having said that, I've turned to the original mimic for the time being, running it as external command from Vim. It's not that handy, sure, but after you've described the possible difficulties of enabling the plugin per filetype, I think it just doesn't worth your time and efforts to address the situation of such rarity :).

But still, thanks again for your interest!

vyorkin commented 8 years ago

btw it also highlights patched font's symbols, e.g. https://github.com/ryanoasis/vim-devicons

bruno- commented 8 years ago

Hey @vyorkin, can you elaborate a bit? Are you saying patched font's symbols are highlighted when this plugin is installed? If yea, which symbols exactly?

vyorkin commented 8 years ago

Yeah, sure! Here is the font that I'm using: item Its taken from the nerd fonts repo I'm also using the vim nerdtree plugin & vim-devicons and all together it looks like this: nerdtree+devicons+vimtrollstopper

vyorkin commented 8 years ago

I'm still not sure about the cause of the problem, maybe it isn't related to your vim plugin at all... For now i just let g:webdevicons_enable_nerdtree = 0 to disable devicons in nerdtree.

ryanoasis commented 8 years ago

@vyorkin Your screenshot links appear to be broken. Can you add new links?

Feel free to open an issue on vim-devicons/issues if it infact does turn out not to have to do with vim-troll-stopper

Freed-Wu commented 4 years ago

in some ascii art, it also exist some speacial characters considered to be incorrect unicode character by this plugin. if it can exist a method, when enter some filetypes, or run some command, execute

highlight TrollStopper ctermbg = NONE guibg = NONE

after leave this filetype, or stop this command, execute

highlight TrollStopper ctermbg = red guibg = #FF0000

perhaps this problem can be solved.