You are not logged in.

#1 2016-09-22 23:09:49

1Try
Member
Registered: 2016-07-21
Posts: 16

[SOLVED] Vim colorscheme color issue

Hi everybody,
I installed arch linux some months ago but only a week ago I decided to make it my main OS so I'm trying to get comfortable with it. Today I tried to set a new colorscheme in Vim but something went wrong with the background color.

I'm using URxvt as terminal and the colorscheme I wanted to try is CodeSchool (http://astonj.com/tech/vim-for-ruby-rai … exy-theme/). Everything works ok but the background color. It is blue where the page is empy and black where it is not (while it should always be something like almost black).
I must admit that I haven't tried any other colorscheme but I've made some researches and I found out that background color issues are quite common among new vim users who set up a different colorscheme for the first time.

The first of the following screenshots shows the blue background where the lines end while the second shows the black background where the page is fully occupied by text.
https://www.dropbox.com/s/ztbo0tz36rxcv … 1.png?dl=0
https://www.dropbox.com/s/5gknuvsp82lo7 … 1.png?dl=0

I couldn't find any working solution for my problem. Any suggestions?
Thanks in advance

Last edited by 1Try (2016-09-23 08:46:48)

Offline

#2 2016-09-22 23:15:47

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,571
Website

Re: [SOLVED] Vim colorscheme color issue

This was not what I expected.  Any number of TERM setting issues can create the problems that often related to background color - but here the explanation is much simpler: that blue is by design.  That is what the theme specifies.

Change the background color for NonText on line 49.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2016-09-23 08:46:24

1Try
Member
Registered: 2016-07-21
Posts: 16

Re: [SOLVED] Vim colorscheme color issue

Hey Trillby you again smile
I would have never thought that it was actually set on purpose. It looked awful. However your solution worked perfectly fine!

Changing line 49

hi NonText ctermfg=59 ctermbg=17 cterm=NONE guifg=#414e58 guibg=#232c31 gui=NONE

To

hi NonText ctermfg=59 cterm=NONE guifg=#414e58 guibg=#232c31 gui=NONE

Did the trick.

However I already regret my initial choice (CodeSchool) and I've found a very useful online tool, which you probably already know, called Vivify (http://bytefluent.com/vivify/) that allows users to create custom colorschemes very easily.

Thank you again Trillby! Also for the explanation on the other post

Edit:
Just one last question. Since Vivify doesn't seem to be able to set colors for new syntax elements I decided to write my own colorscheme without tools.
However I find a bit confusing where I should define the colors.
Here http://vim.wikia.com/wiki/Creating_your … ntax_files it seems that only syntax elements and highlight links should be defined in java.vim (for example) and that colors for those links should be declared in the colorscheme file.
However here http://superuser.com/a/633383/622132 it is adviced to change java.vim and there add the colors for the syntax elements.
If this is the case why at the top of my colorscheme file (currently codeschool.vim) I find the following lines?

highlight clear
if exists("syntax_on")
  syntax reset
endif

Doesn't this erase all the colors possibly declared in java.vim?

Edit2:
I tried to change syntax elements colors in both java.vim and codeschool.vim and it works either way smile however for some reason I still have to understand the color declared in java.vim takes priority

Last edited by 1Try (2016-09-23 10:07:03)

Offline

#4 2016-09-23 11:59:43

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,571
Website

Re: [SOLVED] Vim colorscheme color issue

1Try wrote:

I decided to write my own colorscheme without tools.

This is always the best approach.

1Try wrote:

However I find a bit confusing where I should define the colors.
Here http://vim.wikia.com/wiki/Creating_your … ntax_files it seems that only syntax elements and highlight links should be defined in java.vim (for example) and that colors for those links should be declared in the colorscheme file.
However here http://superuser.com/a/633383/622132 it is adviced to change java.vim and there add the colors for the syntax elements.

The vim wiki is right in this case: it generally is as it is well currated to generally only have the best practices not some garbage that someone once tried that just happened to work for them.

1Try wrote:

If this is the case why at the top of my colorscheme file (currently codeschool.vim) I find the following lines?

In addition to the vim wiki, the help pages within vim are definitely authoritative and would answer this question:

vim help wrote:

If you have changed the colors and messed them up, use this command to get the
defaults back:

  :syntax reset

It is a bit of a wrong name, since it does not reset any syntax items, it only
affects the highlighting.

As for highlight clear:

vim help wrote:

:hi[ghlight] clear      Reset all highlighting to the defaults.  Removes all
                        highlighting for groups added by the user!
                        Uses the current value of 'background' to decide which
                        default colors to use.

Now the difference between the two is not obvious.  And hunting that down by digging through the documentation, the source code, or just some good old trial and error is left as an excercise for the reader ... hey, we're not supposed to know everything about vim hmm

1Try wrote:

Doesn't this erase all the colors possibly declared in java.vim?

Yes, it will, if java.vim was parsed first.  But you shouldn't define any colors in java.vim anyway.  You really shouldn't need to edit any of the major language files.  They already define the language syntax and give each element proper names.  You should just define what color you want to highlight each of those named groups - in a different file: syntax files for syntax definitions, colorscheme files for colorschemes (see, it really does make sense).

1Try wrote:

I still have to understand the color declared in java.vim takes priority

Again this depends on the order of the files being parsed.  You can learn about the default order in the vim documentation - but do not rely on this: as soon as you interactively reset the colorsheme all this can go to crap.  If you want a consistent set up (which is easier to modify/debug) then just do not put colors in your language files (no "highlight/hi" commands in java.vim).


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2016-09-27 08:58:01

1Try
Member
Registered: 2016-07-21
Posts: 16

Re: [SOLVED] Vim colorscheme color issue

Thank you very much for your useful explanations. I'm now working to port my java colorscheme from intellij Idea to vim smile

Offline

Board footer

Powered by FluxBB