chrisbra / Colorizer

color hex codes and color names
547 stars 30 forks source link

Basic usage for colorizer? #47

Closed michael-coleman closed 8 years ago

michael-coleman commented 8 years ago

Hi there, this looks like a great plugin and I'd love to try it, I'm just wondering how to get started with it? I am running terminal vim with Gnome Terminal on Ubuntu.
I have installed pathogen (I normally have pathogen and many other plugins running but for the purposes of trying to debug this plugin install I have stripped vim down to simply pathogen and then git cloned this repo into ~/.vim/bundle contents of ~/.vimrc is simply

execute pathogen#infect()
syntax on
filetype plugin indent on

If I open a file containing hex values (e.g. style.css) then run :ColorHighlight nothing happens.
How can I basic highlighting happening with this plugin? thanks

chrisbra commented 8 years ago

What is your terminal configuration? Does your Vim work with 256colors? If you do echo getmatches() do you see some color matches? Does it work in gui version of vim?

michael-coleman commented 8 years ago

thanks for the reply, While trying to dump values on terminal config to answer your questions I found the problem and got this colorizer plugin working!
This is really cool! I've just been opening all the files I usually edit and running :ColorHighlight and its working great now, nice job on this! I'm running Gnome terminal which is 256 color, however I am also running tmux - which might have been interferring? either way vim seems unable to properly detect the terminal capabilities and was setting &t_Co to either 8 or 16.
So :ColorHighlight was doing nothing - it might have been useful for me if vim reported some error e.g. when running :ColorHighlight

if &t_Co < 16  
   echo("ColorHighlight needs minimum 88 colors to work")
endif

I added the following to my vimrc

if $TERM =~ "linux"
    set t_Co=16
elseif $TERM =~ "xterm-256color" || $TERM =~ "screen"
    "echom('setting t_Co=256')
    set t_Co=256
endif

and that did the trick

chrisbra commented 8 years ago

Yeah, will add something like this to notify the user. Thanks.

boardfish commented 7 years ago

I'm getting this problem too. I've attempted with both gnome-terminal and terminator. The contents of the file I'm trying to colorize is as follows:

#040305
#221F2A
#403D4B
#CD2E4C
#529865
#FEFE03
#FBF716
#E5D92F
#F6F22E
#CBA748
#E2D855
#E3DC57
#1D65A0
#E2559F
#26B6D7
#DDC8BC

Since it's just pure hex values, I'm surprised that:

  1. echo getmatches() returns an empty array and
  2. despite using @michael-coleman's fix, I receive the following error: Colorizer: Color configuration seems wrong, skipping colorization! Check t_Co setting!

My gnome-terminal has true color support, for sure. .vimrc is here.

chrisbra commented 7 years ago

This line is responsible for this warning. That looks like your t_Co setting is reset by some plugin. Check :verbose set t_Co?. Also you claim true color support, but you don't set termguicolors option.

boardfish commented 7 years ago

Seems that the wal colorscheme was the issue. It's actually a plugin that locks to 16-color support. Fixed.