Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color name or number not recognized in Neovim (with notermguicolors set) #386

Open
PunkPhysicist opened this issue Apr 20, 2023 · 11 comments

Comments

@PunkPhysicist
Copy link

I'm running Neovim and everytime I load vim-pandoc-syntax I get the error

line  693:
E421: Color name or number not recognized: ctermfg=#ffa0a0

This looks identical to the issue in here, except I explicitly do not have (or want) true color enabled, I.e., I have set t_Co=16 in my config and even if I add set notermguicolors I still get this error! Running in vim (with the same config) does not give me this error, only neovim.

How can I make sure vim-pandoc-syntax doesn't assume true colors when I use Neovim?

@pretentiousUsername
Copy link

For me this issue occurs in neovim 0.9.0—it doesn't happen in 0.8.3 or lower, which indicates to me there might be something wrong with neovim and not the plugin. I'm not too sure about that though.

@PunkPhysicist
Copy link
Author

PunkPhysicist commented May 12, 2023

For me this issue occurs in neovim 0.9.0—it doesn't happen in 0.8.3 or lower, which indicates to me there might be something wrong with neovim and not the plugin. I'm not too sure about that though.

For what it's worth, this also doesn't happen with Vim, and have even thought about switching because of this (though I'm not sure I'm ready to stop using neovim because of this one issue)

@pretentiousUsername
Copy link

I think this will probably get fixed in a later patch. Depending on what OS you're using, you can pretty easily downgrade neovim without losing much of anything (if at all), so it's no big deal.

@xunam
Copy link

xunam commented May 16, 2023

I am facing the same issue, in a fresh Neovim 0.9.0 with only vim-pandoc and vim-pandoc-syntax installed. In case it might be useful, I noticed that for some reason, the issue only appears when both plugins are installed, disabling vim-pandoc makes it disappear.

@pretentiousUsername
Copy link

Yeah I just checked that out. It seems like something might be wrong with vim-pandoc.

Looking at this function, it looks like the color is defined elsewhere, though I don't know enough vimscript to really deal with this.

if g:pandoc#syntax#style#emphases == 1
    hi pandocEmphasis gui=italic cterm=italic
    hi pandocStrong gui=bold cterm=bold
    hi pandocStrongEmphasis gui=bold,italic cterm=bold,italic
    hi pandocStrongInEmphasis gui=bold,italic cterm=bold,italic
    hi pandocEmphasisInStrong gui=bold,italic cterm=bold,italic
    if !exists('s:hi_tail')
        let s:fg = '' " Vint can't figure ou these get set dynamically
        let s:bg = '' " so initialize them manually first
        for s:i in ['fg', 'bg']
            let s:tmp_val = synIDattr(synIDtrans(hlID('String')), s:i)
            let s:tmp_ui =  has('gui_running') || (has('termguicolors') && &termguicolors) ? 'gui' : 'cterm'
            if !empty(s:tmp_val) && s:tmp_val != -1
                exe 'let s:'.s:i . ' = "'.s:tmp_ui.s:i.'='.s:tmp_val.'"'
            else
                exe 'let s:'.s:i . ' = ""'
            endif
        endfor
        let s:hi_tail = ' '.s:fg.' '.s:bg
    endif
    exe 'hi pandocNoFormattedInEmphasis gui=italic cterm=italic'.s:hi_tail " <-- Line 693
    exe 'hi pandocNoFormattedInStrong gui=bold cterm=bold'.s:hi_tail
endif

Since vim-pandoc and vim-pandoc-syntax are supposed to be used together, maybe there's something defined in vim-pandoc that's gone a bit awry? I'll check it out in a bit and let you two know.

@pretentiousUsername
Copy link

Hey @PunkPhysicist and @xunam, what plugins are you two using? And what are you using to manage your plugins?

For reference, I'm using Packer for management, and I'm using lualine, vim-pandoc, vim-pandoc-syntax, haskell-vim, julia-vim, rust.vim, vimtex, and SyntaxAttr.vim.

@PunkPhysicist
Copy link
Author

PunkPhysicist commented May 21, 2023

Hey @PunkPhysicist and @xunam, what plugins are you two using? And what are you using to manage your plugins?

For reference, I'm using Packer for management, and I'm using lualine, vim-pandoc, vim-pandoc-syntax, haskell-vim, julia-vim, rust.vim, vimtex, and SyntaxAttr.vim.

I use Vundle for package management. And here is a list of plugins (copied from my vimrc):

Plugin 'VundleVim/Vundle.vim'               " required
Plugin 'ervandew/supertab'                  " tab completion
Plugin 'easymotion/vim-easymotion'          " Quick motions
Plugin 'jlanzarotta/bufexplorer'            " Buffer Explorer
Plugin 'tpope/vim-surround'                 " 'quoting/parenthesizing made simple'
Plugin 'tpope/vim-repeat'                   " Allow '.' repeat for surround.vim, speeddating.vim, unimpaired.vim, and vim-easyclip
Plugin 'tpope/vim-characterize'             " Better Unicode character metadata (when press 'ga')
Plugin 'Raimondi/delimitMate'               " 'auto-completion for quotes, parens, brackets, etc.'
Plugin 'godlygeek/tabular'                  " Aligning text (e.g. in tables)
Plugin 'kshenoy/vim-signature'              " 'plugin to place, toggle and display marks.'
Plugin 'altercation/vim-colors-solarized'   " Solarized colorscheme
Plugin 'Konfekt/FastFold'                   " Update folds only when called-for 
Plugin 'tpope/vim-commentary'               " Adds operator gc{motion}|{visual}gc to comment/uncomment selection
                                                                                                                                   
" Snippets
Plugin 'SirVer/ultisnips'                   " Snippets engine
Plugin 'honza/vim-snippets'                 " Snippets files
                                                                                                                                   
" Autocompletion
Plugin 'Shougo/deoplete.nvim'               " Asynchronous neovim completion framework 
Plugin 'zchee/deoplete-jedi'                " Completions for jedi (Python introspection)
Plugin 'davidhalter/jedi-vim'               " Deeper jedi completion (not asynchronous)
Plugin 'wellle/tmux-complete.vim'           " Completion of words in other tmux panes
Plugin 'Shougo/neco-syntax'                 " Completions via keywords in syntax highlighting file
Plugin 'Shougo/neco-vim'                    " Completions for Vim commands
                                                                                                                                   
" Pandoc stuff
Plugin 'vim-pandoc/vim-pandoc'
Plugin 'vim-pandoc/vim-pandoc-syntax'
                                                                                                                                   
" Todo.txt editing
Plugin 'freitass/todo.txt-vim'
                                                                                                                                   
" LaTeX
Plugin 'vim-latex/vim-latex'
Plugin 'LaTeX-Box-Team/LaTeX-Box'

" Python/vim-Slime
Plugin 'jpalardy/vim-slime' 

@xunam
Copy link

xunam commented May 22, 2023

Hey @PunkPhysicist and @xunam, what plugins are you two using? And what are you using to manage your plugins?

I use vim-plug and created a minimal configuration for testing purposes, with only this:

call plug#begin()
Plug 'vim-pandoc/vim-pandoc'
Plug 'vim-pandoc/vim-pandoc-syntax'
call plug#end()

The problem appears, but only if both Plug lines are present.

@pretentiousUsername
Copy link

Alright, I know it's been two months since I've responded, but I managed to find a fix for this problem today—all you need to do is go into your colorscheme file and search for the color that neovim won't recognize (in this case #ffa0a0) and change it to a cterm color (e.g. 1–16). For some reason if you're using neovim in your terminal it still parses guifg colors.

@PunkPhysicist
Copy link
Author

Alright, I know it's been two months since I've responded, but I managed to find a fix for this problem today—all you need to do is go into your colorscheme file and search for the color that neovim won't recognize (in this case #ffa0a0) and change it to a cterm color (e.g. 1–16). For some reason if you're using neovim in your terminal it still parses guifg colors.

That works in principle, but the problem is I use colorschemes from elsewhere (rather than defining my own). So I would need to manually patch any colorscheme I might use or only use only my own defined colors. Neither of which I would consider a solution

chunyunma added a commit to chunyunma/dotfiles-nvim that referenced this issue Sep 6, 2023
@xunam
Copy link

xunam commented Aug 28, 2024

Hello,

It has been a year since the last message but the issue apparently still needs a reliable fix. I just wanted to share a simple temporary fix that works for me without patching colorschemes files: after setting the colorscheme in the init.vim file, say

exec 'hi String guifg=' . synIDattr(synIDtrans(hlID('String')), 'fg', 'cterm')

The point is that, apparently, there is a bug that makes vim-pandoc-syntax fetch guifg instead of ctermfg specifically through the String class. This happens in the s:SetupPandocHighlights() function where there is complicated logic that I fail to precisely understand, but the line above avoids the error by changing the guifg to the value of the associated ctermfg.

Hope this helps...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants