vim-pandoc / vim-pandoc-syntax

pandoc markdown syntax, to be installed alongside vim-pandoc
MIT License
425 stars 61 forks source link

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

Open PunkPhysicist opened 1 year ago

PunkPhysicist commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 12 months ago

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 commented 12 months ago

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