3

Basically, all I'm trying to do is enable the syntax option.

syntax enable
colorscheme cobalt2

For some reason, I get no errors if I comment out the first line, but in case I don't comment it, I get:

Error detected while processing /usr/share/vim/vim81/syntax/synload.vim:
line   19:
E185: Cannot find color scheme 'cobalt'

which is not exactly the name of the theme that I'm trying to use.

Any ideas why this would be happening?

6
  • It looks like if you disable syntax, then it doesn't do the color highlighting scheme anyways. If syntax enable is commented out, do you still get any colorscheme when you open a file in ViM? If you do ls /usr/share/vim/vim81/colors, that will display a list of all available color schemes you have available to you. Maybe double check the one you want exists?
    – Vee
    Dec 17, 2020 at 21:07
  • Hey @Vee, cobalt2 exists and I'm able to apply it after commenting out the syntax enable as mentioned above.
    – rexagod
    Dec 17, 2020 at 21:15
  • What's strange though, is the fact that the error message displays the incorrect theme name, which of course, does not exist.
    – rexagod
    Dec 17, 2020 at 21:17
  • 2
    Well, in looking at my own synload.vim, line 19 is exe "colors " . colors_name. Since I don't have the cobalt color scheme, when I'm in vim and I type :colors cobalt I get the same error you see. I did a grep for the variable colors_name in /usr/share/vim/vim81 and got all the colors .vim files defining that global variable. Can you confirm that your /usr/share/vim/vim81/colors/cobalt2.vim defines the colors_name variable as cobalt2?
    – Vee
    Dec 17, 2020 at 21:42
  • 2
    Welcome to Vi and Vim!
    – D. Ben Knoble
    Dec 17, 2020 at 22:11

1 Answer 1

3

It's important that a theme set the g:colors_name variable correctly to match the name of the theme script file, because Vim will use it when it needs to reload the theme (and it does so in a few situations.)

I could find at least one cobalt2 theme online that had a commit fixing it from incorrectly setting the variable to cobalt, to setting it correctly as cobalt2.

See this commit, which is the latest commit in theme cobalt2 available as Vim package GertjanReynaert/cobalt2-vim-theme.

It's the latest commit of that repo, but it's dated of over five years ago, 2015, so I'm not sure how you would end up with that repo but an older version of that...

In any case, try to update your cobalt2 theme to the latest. If you're already on the latest, look inside the colors/cobalt2.vim script inside it and see how it sets colors_name. If it sets it incorrectly, you can fix it there (and hopefully report it to the maintainer of the source where you got it, so it can be fixed there too.)

2
  • 2
    That looks like the other piece of the puzzle.
    – Vee
    Dec 18, 2020 at 16:17
  • 1
    That is some Sherlock-level sleuthing right there. Works now, thanks!
    – rexagod
    Dec 19, 2020 at 0:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.