[vim/vim] Changing colorscheme doesn't change g:terminal_ansi_colors in opened terminal buffer (Issue #12344)

29 views
Skip to first unread message

C.D. MacEachern

unread,
May 4, 2023, 3:39:54 PM5/4/23
to vim/vim, Subscribed

Sorry for another sort-of-odd one and the mind dump, but try this out:

vim --clean
:set termguicolors
" open some random file, vimrc will do...
:colorscheme blue
:term

Here we are with g:terminal_ansi_colors echo'd and a 256 color test script ran in the terminal buffer:

Screenshot 2023-05-04 at 12 47 24 PM

Now escape to terminal normal mode with <C-\><C-n> and run:

:colorscheme habamax

Screenshot 2023-05-04 at 12 49 21 PM

Echoing g:terminal_ansi_colors we can see that they were set correctly to the new habamax defined colors, but the terminal buffers palette is not actually updated. It stays this way even when I tried re-running the 256 demo script and hiding the terminal buffer and reopening it. I expected switching colorscheme would trigger re-coloring of terminal buffers, but it doesn't seem to work this way, it seems only the terminal buffer background colour is changed. I would think this is better handled in vim/vim, but maybe there's something that could be done on colorscheme side? Just thinking out loud, seems like it could be a can of worms (as usual heh).

This is on latest Alacritty release (no tmux running), macOS, and Vim 9.0.1476 huge without GUI, compiled from source.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12344@github.com>

Bram Moolenaar

unread,
May 5, 2023, 5:11:02 PM5/5/23
to vim/vim, Subscribed

I don't think that one can expect that changing g:terminal_ansi_colors will have an immediate effect. It is used when opening a new terminal, not for an existing terminal. Although you can probably refresh it by toggling 'termguicolors'.
I am not sure if changing the value of a global variable should have a side effect. The term_setansicolors() function was meant for that.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12344/1536785122@github.com>

Bram Moolenaar

unread,
May 6, 2023, 9:09:27 AM5/6/23
to vim/vim, Subscribed


> Sorry for another sort-of-odd one and the mind dump, but try this out:
>
> ```
> vim --clean
> :set termguicolors
> " open some random file, vimrc will do...
> :colorscheme blue
> :term
> ```
>
> Here we are with `g:terminal_ansi_colors` echo'd and a 256 color test
> script ran in the terminal buffer:
>
> <img width="2032" alt="Screenshot 2023-05-04 at 12 47 24 PM" src="https://user-images.githubusercontent.com/7416158/236271253-add552b1-9595-4996-89ed-73fbd9c1886c.png">

>
> Now escape to terminal normal mode with `<C-\><C-n>` and run:
>
> ```
> :colorscheme habamax
> ```
>
> <img width="2032" alt="Screenshot 2023-05-04 at 12 49 21 PM" src="https://user-images.githubusercontent.com/7416158/236271690-820c28db-e5ff-4319-945d-3d0e5d116264.png">

>
> Echoing `g:terminal_ansi_colors` we can see that they were set correctly
> to the new habamax defined colors, but the terminal buffers palette is
> not actually updated. It stays this way even when I tried re-running the
> 256 demo script and hiding the terminal buffer and reopening it. I
> expected switching colorscheme would trigger re-coloring of terminal
> buffers, but it doesn't seem to work this way, it seems only the
> terminal buffer background colour is changed. I would think this is
> better handled in vim/vim, but maybe there's something that could be
> done on colorscheme side? Just thinking out loud, seems like it could be
> a can of worms (as usual heh).

The colorscheme affects the things displayed in Vim, especially syntax
highlighting and other UI elements. What happens in a terminal depends
on what is running in there. E.g. if you would run Vim in the terminal
window you can set a colorscheme in that one and expect it to not be
changed by the colorscheme in the top level Vim, that runs the terminal
window. Except for the normal foreground/background colors, since these
are set by the terminal (even when not using any colorscheme).

--
Often you're less important than your furniture. If you think about it, you
can get fired but your furniture stays behind, gainfully employed at the
company that didn't need _you_ anymore.
(Scott Adams - The Dilbert principle)

/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12344/1537139008@github.com>

Christian Brabandt

unread,
May 30, 2023, 3:24:48 AM5/30/23
to vim/vim, Subscribed

closing then.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12344/1567903595@github.com>

Christian Brabandt

unread,
May 30, 2023, 3:24:49 AM5/30/23
to vim/vim, Subscribed

Closed #12344 as completed.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/12344/issue_event/9374778443@github.com>

Reply all
Reply to author
Forward
0 new messages