qvacua / qvacua/vimr

Themes with highlight groups using "links" to other groups do not propagate colors to SwiftUI properly

Open
#1,069 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
7k
Forks
233
Avg merge
11d 18h
Merged PRs (30d)
1

Description

I think I figured out why another bug where some themes do not propagate their theme colors to VimR, such as dracula.

I noticed color changes are propagated from
In NvimView+Resize.swift, line 129

autocmd ColorScheme * call rpcnotify(\(channel), 'autocommand', 'colorscheme', get(nvim_get_hl(0, {'id': hlID('Normal')}), 'fg', -1), get(nvim_get_hl(0, {'id': hlID('Normal')}), 'bg', -1), get(nvim_get_hl(0, {'id': hlID('Visual')}), 'fg', -1), get(nvim_get_hl(0, {'id': hlID('Visual')}), 'bg', -1), get(nvim_get_hl(0, {'id': hlID('Directory')}), 'fg', -1), get(nvim_get_hl(0, {'id': hlID('TablineSel')}), 'bg', -1), get(nvim_get_hl(0, {'id': hlID('TablineSel')}), 'fg', -1))

But when I try to get those specific groups in neovim:

echo get(nvim_get_hl(0, {'id': hIID('TablineSel')}, 'fg') 
['bold': vitrue, 'cterm': {'bold': vitrue}, 'link': 'Normal'})

echo get(nvim_get_hl(0, {'id': hIID('TablineFill')}, 'fg') 
({'link': 'DraculaBgDark'})

Because some themes define highlight groups that pull their values from other groups ("link" to other groups), when using the existing code, get(nvim_get_hl(0, {'id': hlID('TablineFill')}), 'bg', -1), the result with these highlight groups is always -1.

Reading up on highlight groups in the neovim docs, they suggest using something more like synIDattr(synIDtrans(hlID('TablineFill')),'bg').

Trying it in my clients, I get:

echo synIDattr(synIDtrans(hlID('TablineFill')),'bg')
#21222c

echo synIDattr(synIDtrans(hlID('TablineFill')),'fg')

This is a lot better, returning with hex color codes starting with #, but it results in empty strings when there is no value set, which could affect how existing code handles missing color codes.

I'm working on a pull-request that changes how the colors are grabbed, without changing how their error handling ( value of -1 ) works; but I wanted to also have this issue to explain the problem.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in NvimView+Resize.swift around line 129 and inspect how the ColorScheme autocmd reads the TablineFill and TablineSel highlight groups. Compare linked and directly defined groups in Neovim, then verify that linked colors propagate while missing values retain the existing -1 handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, swift, vim
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.