wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
17.28k stars 781 forks source link

`cursor_bg` and `cursor_fg` cannot be overriden by neovim/vim in some cases #2260

Closed milanglacier closed 2 years ago

milanglacier commented 2 years ago

What Operating System(s) are you seeing this problem on?

macOS

WezTerm version

wezterm 20220624-141144-bd1b7c5d

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

I tried the nightly build (manually build from source) and it has the same problem.

Some neovim/vim colorschemes doesn't specifically set the cursor fg and bg as a fixed color value, sometimes they uses: highlight Cursor cterm=reverse to reverse the fg and bg of the cell under the cursor. In alacritty(if don't set any curor color inalacritty.yml) or iterm2 (set Preferences-Profiles-Colors-Smart box cursor color to true), cterm=reverse is respected, and in wez, cterm=reverse is not respected.

To Reproduce

cd ~/.config/wezterm
vim --clean -c "hi Cursor cterm=reverse" wezterm.lua # run in no plugin mode
nvim --clean -c "hi Cursor cterm=reverse" wezterm.lua # run in no plugin mode

Configuration

wezterm config:

return {
    color_scheme = 'Builtin Solarized Light'
}

Expected Behavior

Respect highlight Cursor cterm=reverse by vim/neovim

Logs

No response

Anything else?

screenshot:

Screen Shot 2022-07-13 at 17 29 18

alacritty

Screen Shot 2022-07-13 at 17 28 56

wezterm

wez commented 2 years ago

Perhaps you want to enable https://wezfurlong.org/wezterm/config/lua/config/force_reverse_video_cursor.html ?

milanglacier commented 2 years ago

This works amazingly! Thanks!

milanglacier commented 2 years ago

For people like me who prefer to swtich the colorscheme dynamically (based on OS theme), I find that every time if a colorsheme resets, then force_reverse_video_cursor automatically sets to false, then manually set it to true in everytime override works:


local function switch_color_scheme_with_OS()
    wezterm.on('window-config-reloaded', function(window, _)
        local overrides = window:get_config_overrides() or {}
        local appearance = window:get_appearance()
        local scheme = scheme_for_appearance(appearance, _)
        if overrides.color_scheme ~= scheme then
            overrides.color_scheme = scheme
            overrides.force_reverse_video_cursor = true
            window:set_config_overrides(overrides)
        end
    end)
end
vimpostor commented 2 years ago

For people like me who prefer to swtich the colorscheme dynamically (based on OS theme), I find that every time if a colorsheme resets, then force_reverse_video_cursor automatically sets to false, then manually set it to true in everytime override works:

If you use the new color_scheme = scheme_for_appearance(wezterm.gui.get_appearance()) instead of the old window-config-reloaded hack, then your workaround is not necessary and force_reverse_video_cursor persists.

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.