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

How to disable/enable? #125

Closed
eduardoarandah opened this issue May 5, 2020 · 9 comments
Closed

How to disable/enable? #125

eduardoarandah opened this issue May 5, 2020 · 9 comments

Comments

@eduardoarandah
Copy link

In some filetypes, it doesn't make sense having this highlighting enabled.

Is there a way of enabling/disabling?
o based on filetype?

I'm thinking about enabling only for css

@ap
Copy link
Owner

ap commented May 20, 2020

There is currently no such feature. What filetypes do you find it unnecessary in?

@eduardoarandah
Copy link
Author

Sometimes it's distracting in html, with color names (red, blue, white)

Also, it's weird to color names in a .txt file hehe, let's say you're taking notes about a company called "yellow submarine"

I tried this, but I don't know why it doesn't have effect:

Plug 'ap/vim-css-color', { 'for': [ 'css', 'scss' ] }

https://github.com/junegunn/vim-plug#example

(right one is html)
image

@ap
Copy link
Owner

ap commented May 21, 2020

Would you say your request has the same motivation as #124 then?

I am guessing the fact that this plugin relies on the after and autoload mechanisms of Vim is why you can’t disable it that way.

@eduardoarandah
Copy link
Author

Yeah I guess.

Without knowing how this plugin does its magic, can't it be registered only when a specific filetype opens?

like setlocal instead of set or autocmd BufReadAfter *.css ?

I have this in my vimrc to do some customization on specific filetypes:

augroup filetypes
  autocmd!

  " Blade filetype
  autocmd BufRead,BufNewFile *.blade.php set filetype=blade

  " Txt as markdown
  autocmd BufReadPost *.txt set filetype=markdown

augroup END

@ap
Copy link
Owner

ap commented May 21, 2020

It doesn’t work that way, so no. At least not without changing how it works. Now that I think about it, the way it works may just be historical baggage and not necessary, and changing it might solve other problems as well. I need to have a think on that.

@ap ap pinned this issue Aug 9, 2020
@ap
Copy link
Owner

ap commented Aug 9, 2020

@at1047 just posted a real solution for this in #136, albeit one that requires modifying the plugin.

@Zeioth
Copy link

Zeioth commented Nov 5, 2020

It would be nice to be able to enable it only on CSS files. I don't want my .md to highlight every time i write 'blue' or 'silver'.

@ap
Copy link
Owner

ap commented Nov 23, 2020

@Zeioth:

I don't want my .md to highlight every time i write 'blue' or 'silver'.

I wouldn’t want that either. And so it doesn’t:

It highlights blue or silver only when those are actually used in CSS when defining colours. That fact is literally the whole point of using this plugin over otherwise similar, comparable ones.

@eduardoarandah
Copy link
Author

Here's a solution to not load this plugin in files other than CSS/SCSS

Plug 'ap/vim-css-color', { 'for': [ 'css', 'scss' ] }

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