daylerees / colour-schemes

Colour schemes for a variety of editors created by Dayle Rees.
http://daylerees.github.io
Other
9.31k stars 1.62k forks source link

vim color scheme error #142

Closed harris21 closed 10 years ago

harris21 commented 10 years ago

Hello there. I am trying to apply a vim color scheme. The problem is, I cannot make it work, although it works fine in MacVim. I have attached two images, one using macvim and one using terminal vim. I've been searching for over 5 hours and this thing is driving me crazy. Any ideas what am I doing wrong?? screen shot 2014-03-28 at 3 47 58 am screen shot 2014-03-28 at 3 49 32 am

daylerees commented 10 years ago

Hey buddy, I'm by no means a VIM expert, but I think there's a setting for the terminal emulation to use, and you need to use more than 256 colours. I can't remember the exact configuration sorry. @machuga might know this one, let's see if he gets pinged in.

harris21 commented 10 years ago

Yeah, I started using vim this week, so I am not a vim expert as well. All I know is that GUI like MacVim has some million colours and the terminal VIM can only have up to 256 colours. Maybe @JeffreyWay or @machuga can help on this one.

machuga commented 10 years ago

@daylerees 256 is the max terms can handle. t_Co=256 like the author has set will enable that mode as long as the current terminal supports it. @harris21 if you're using iTerm, make sure you set the terminal emulation to xterm-256color.

If the theme requires additional colors it won't be able to find them.

Another caveat is that if all elements of the vim theme are not handled it'll fall back to the terminal emulator's default theming options so that could start conflicting as well. In short - MacVim's GUI mode will definitely give you better color support.

Hope that helps some!

daylerees commented 10 years ago

Thanks Matt! Yep it would be a boatload of work to calculate + use the closest colour in the 256 pallette so I think that's an unlikely route. Sorry dude.

machuga commented 10 years ago

:thumbsup:

harris21 commented 10 years ago

@daylerees I see...thank you both. I guess I won't be able to use your color schemes in terminal VIM :( @machuga I have tried the xterm-256color in iterm but still no luck... :S

machuga commented 10 years ago

@harris21 ya you're out-of-luck for themes that require more than 256 colors. Limitations of legacy technology, sadly.

joeytwiddle commented 10 years ago

it would be a boatload of work to calculate + use the closest colour in the 256 pallette

I don't think it is an unimaginable task. We just need to pair up each terminal colour with its RGB/HSL/YUV equivalent, then use a difference function to find the closest.

Finding the closest efficiently would be a bit more work, but ... well there are only 256 to loop. ;) Also it might be worth looking into colour spaces, because closeness in RGB is not the same closeness that the human eye perceives. I think YUI/YUV should be more appropriate.

Obviously you and I are too busy to work on this. I just wanted to give encouragement to anyone who thought it might be impossible: it's not!

kyrias commented 9 years ago

@machuga: "256 is the max terms can handle"

That’s not true at all, there are plenty of terminal emulators that support 24-bit colors. (i.e. RGB colors)

machuga commented 9 years ago

Sure. I didn't learn that till after I posted this back months ago and subsequently forgot about it. That being said I don't think it'll benefit most cli apps that aren't setup to leverage these color options but I could be wrong.

kyrias commented 9 years ago

Indeed, which is why it’s a bit sad that more people haven’t ported applications to use it.


For an example, if you have a TE that supports 24-bit colors, try this:

   printf "\x1b[38;2;255;170;070mTRUECOLOR\x1b[0m\n"

where 255;170;070 is a RGB color.

rrotaru commented 9 years ago

Here's a link to a really simple python script that can generate the closest color in a 256 color palette based on the hex code. I was super happy with Snappy for MacVim but noticed that it sucks in terminal, so I went in and edited the colorscheme file to fix it and it turned out fairly well. Check out the before and after as well as the file itself. Before After https://gist.github.com/rrotaru/869f85fa860271c1d11f

@daylerees if you're interested and you like the way Snappy turned out, I can help convert the rest of your colorschemes and send you a pull request with the changes

thomasbkahn commented 8 years ago

@rrotaru I'm interested. If there hasn't been any response would you consider making a fork?

rrotaru commented 8 years ago

Done @thomasbkahn. Here's the fork, and the pull request.

Thanks for reminding me about this, I meant to get back to finishing it a while ago.

thomasbkahn commented 8 years ago

@rrotaru Awesome, thanks!

rrotaru commented 8 years ago

For the sake of posterity for anyone who stumbles across this and wants to convert future colorschemes, here is the python script I wrote to convert the color codes from hex to 256 term values for these files: https://gist.github.com/rrotaru/4911151e3623f2af7e9f8ade58ccf33d

You will also need this file to run this successfully: https://gist.github.com/MicahElliott/719710

Ping @daylerees