1

I'm trying to debug my Vimrc config files but I can't find the file where the error is coming from, is there a way to find the file that the line is coming from?

For example, I'm given this error:

Error detected while processing function <SNR>28_HL:
line   43:
E254: Cannot allocate color 0
E421: Color name or number not recognized: ctermbg= gui=NONE cterm=NONE

This doesn't tell me where the file that the error is occuring is, I have tried doing vim -V9myvim.log and rooting for the error which gives me this:

line 15: sourcing "/usr/local/share/vim/vim80/syntax/syncolor.vim"
finished sourcing /usr/local/share/vim/vim80/syntax/syncolor.vim
continuing in /Users/thermatix/dotfiles/tag-vim/vim/plugged/gruvbox/colors/gruvbox.vim
Searching for "/usr/local/share/vim/vimfiles/after/syntax/syncolor.vim"
Searching for "/Users/thermatix/dotfiles/tag-vim/vim/plugged/vim-snipmate/after/syntax/syncolor.vim"
Searching for "/Users/thermatix/dotfiles/tag-vim/vim/plugged/vim-polyglot/after/syntax/syncolor.vim"
Searching for "/Users/thermatix/dotfiles/tag-vim/vim/plugged/vim-javascript/after/syntax/syncolor.vim"
Searching for "/Users/thermatix/dotfiles/tag-vim/vim/plugged/tern_for_vim/after/syntax/syncolor.vim"
Searching for "/Users/thermatix/dotfiles/tag-vim/vim/plugged/vim-coffee-script/after/syntax/syncolor.vim"
Searching for "/Users/thermatix/dotfiles/tag-vim/vim/plugged/jedi-vim/after/syntax/syncolor.vim"
Searching for "/Users/thermatix/dotfiles/tag-vim/vim/plugged/ale/after/syntax/syncolor.vim"
Searching for "/Users/thermatix/dotfiles/tag-vim/vim/plugged/vim-markdown/after/syntax/syncolor.vim"
Searching for "/Users/thermatix/.vim/after/syntax/syncolor.vim"
                                                               Error detected while processing function <SNR>28_HL:
line   43:
E254: Cannot allocate color 0
E421: Color name or number not recognized: ctermbg= gui=NONE cterm=NONE
finished sourcing /Users/thermatix/dotfiles/tag-vim/vim/plugged/gruvbox/colors/gruvbox.vim
continuing in /usr/local/share/vim/vim80/syntax/synload.vim
Executing ColorScheme Auto commands for "gruvbox"

But this isn't that helpful because before it was <SNR>32_HL, then I removed tabular (which was the last loaded plugin before the error) and it change to <SNR>28_HL.

Is the error in Searching for "/Users/thermatix/.vim/after/syntax/syncolor.vim"?

Can't be because there is no after folder.

I also tried doing grep -r 'ctermbg= gui=NONE cterm=NONE' .vim/ but that found nothing, and grep-ing for the individual attributes found nothing that seem to be related to the error.

I've also tried using vim -D to try and step through but again, it seems to jump lines till the error happens without actually staging where the error is, so I can't tell where the problem lies, you just get this:

Entering Debug mode.  Type "cont" to continue.
/Users/thermatix/.vimrc
line 1: so ~/.vim/vimrc.vim
>
>n
Error detected while processing function <SNR>28_HL:
line   43:
E254: Cannot allocate color 0
E421: Color name or number not recognized: ctermbg= gui=NONE cterm=NONE
/Users/thermatix/.vimrc
line 2: End of sourced file
>

So how do I find where the error is coming from? I mean, telling me the line number is all well and good but it's useless without the file that it's coming from.

If you find the need, my vim config files can be found here.

2

Is the error in Searching for "/Users/thermatix/.vim/after/syntax/syncolor.vim"?

Can't be because there is no after folder.

Actually the problem may be that some plugin expects the folder to exist.

I also tried doing grep -r 'ctermbg= gui=NONE cterm=NONE' .vimrc/ but that found nothing, and grep-ing for the individual attributes found nothing that seem to be related to the error.

You should try grep in ~/.vim.

In any case, you should follow the procedure in "How do I debug my vimrc file?" (or the procedure at Vim faq-2.5). It will allow you to find which line on your _vimrc or plugin triggers the problem.


Edit:

So there's no way to get vim to spit out a file alongside the line number?

I'm not aware of any Vim option that would include the file name; by default it includes only the function name, which in this case is <SNR>28_HL. Note the <SNR>28_ means it is a script-local function (see :help <SNR>).

That being said, I usually find quite easy and straightforward to follow the procedures in the link above. If you still prefer to avoid it, you should try to improve your use of the debugger:

I've also tried using vim -D to try and step through but again, it seems to jump lines till the error happens without actually staging where the error is, so I can't tell where the problem lies, you just get this:

Entering Debug mode.  Type "cont" to continue.
/Users/thermatix/.vimrc
line 1: so ~/.vim/vimrc.vim
>
>n
Error detected while processing function <SNR>28_HL:
line   43:
E254: Cannot allocate color 0
E421: Color name or number not recognized: ctermbg= gui=NONE cterm=NONE
/Users/thermatix/.vimrc
line 2: End of sourced file
>

Instead of using next in the line sourcing the vimrc.vim, you should try to step -- details can be found at :help >step.

  • I made a slight mistake, It was .vim and not .vimrc not sure why I typed that but thanks for pointing that out, still doesn't change that it found nothing. – Thermatix Oct 19 '17 at 11:11
  • Oh, I see. Anyway, the main answer to your question are the links in the last line. The basic idea is to remove settings/plugins through binary search until you find the culprit. Let me know the results when you try them. – mMontu Oct 19 '17 at 11:13
  • So there's no way to get vim to spit out a file alongside the line number? – Thermatix Oct 19 '17 at 11:20
  • 4
    Note: Use :scriptnames to find out, which script uses the <snr>28 prefix. That is usually faster finding the error than using the debugger. – Christian Brabandt Oct 19 '17 at 12:18
  • 2
    that is documented at :h <SNR> – Christian Brabandt Oct 19 '17 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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