Skip to content

Color confusion #402

@dgbustos

Description

@dgbustos

When I run gvim file.Rmd, vim complains:

Error detected while processing /nix/store/ibcbbmsln9vhzsz9bd6psnhh8ida523s-vim-full-9.1.1566/share/vim/vimrc[2]../nix/store/ibcbbmsln9vhzsz9bd6psnhh8ida523s-vim-full-9.1.1566/share/vim/vim91/syntax/syntax.vim[44]..BufRead Autocommands for "*.Rmd"..FileType Autocommands for "*"..Syntax Autocommands for "*"..function <SNR>3_SynSet[25]..script /nix/store/ibcbbmsln9vhzsz9bd6psnhh8ida523s-vim-full-9.1.1566/share/vim/vim91/syntax/rmd.vim[41]../nix/store/ibcbbmsln9vhzsz9bd6psnhh8ida523s-vim-full-9.1.1566/share/vim/vim91/syntax/pandoc.vim[702]..function <SNR>10_SetupPandocHighlights:
line  111:
E254: Cannot allocate color 1
line  112:
E254: Cannot allocate color 1
line  111:
E254: Cannot allocate color 1
line  112:
E254: Cannot allocate color 1

E254: Cannot allocate color 1
E254: Cannot allocate color 1

With some debugging statements I determined that synIDattr() at

let s:tmp_val = synIDattr(synIDtrans(hlID('String')), s:i)
is returning 1 instead of Magenta, which is what it returns when I run echo synIDattr(synIDtrans(hlID('String')), 'fg') after the editor is running.

With more debugging statements I determined that when that code is running, term is set to xterm-256color even though has('gui_running') returns 1.

Changing the referenced code to

              let s:tmp_ui =  has('gui_running') || (has('termguicolors') && &termguicolors) ? 'gui' : 'cterm'
              let s:tmp_val = synIDattr(synIDtrans(hlID('String')), s:i, s:tmp_ui)

seems to fix it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions