sainnhe / gruvbox-material

Gruvbox with Material Palette
MIT License
1.96k stars 166 forks source link

Terminal uses the same colors for bright and non-bright ANSI #152

Closed samjwill closed 2 years ago

samjwill commented 2 years ago

I have done the following steps before reporting this issue:

Operating system/version

Kubuntu 22.04

Terminal emulator/version

Konsole 21.12.3

$TERM environment variable

xterm-256color

Tmux version

N/A

Feature matrix

nvim: health#nvim#check
========================================================================
## Configuration
  - WARNING: Missing user config file: /home/my_username/.config/nvim/init.vim
    - ADVICE:
      - :help |init.vim|

## Performance
  - OK: Build type: Release

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=\177
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $COLORTERM='truecolor'

provider: health#provider#check
========================================================================
## Clipboard (optional)
  - OK: Clipboard tool found: xclip

## Python 3 provider (optional)
  - WARNING: No Python executable found that can `import neovim`. Using the first available executable for diagnostics.
  - WARNING: Could not load Python 3:
    /usr/bin/python3 does not have the "neovim" module.
    /usr/bin/python3.10 does not have the "neovim" module.
    python3.9 not found in search path or not executable.
    python3.8 not found in search path or not executable.
    python3.7 not found in search path or not executable.
    python not found in search path or not executable.
    - ADVICE:
      - See :help |provider-python| for more information.
      - You may disable this provider (and warning) by adding `let g:loaded_python3_provider = 0` to your init.vim
  - INFO: Executable: Not found

## Python virtualenv
  - OK: no $VIRTUAL_ENV

## Ruby provider (optional)
  - INFO: Ruby: ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux-gnu]
  - WARNING: `neovim-ruby-host` not found.
    - ADVICE:
      - Run `gem install neovim` to ensure the neovim RubyGem is installed.
      - Run `gem environment` to ensure the gem bin directory is in $PATH.
      - If you are using rvm/rbenv/chruby, try "rehashing".
      - See :help |g:ruby_host_prog| for non-standard gem installations.
      - You may disable this provider (and warning) by adding `let g:loaded_ruby_provider = 0` to your init.vim

## Node.js provider (optional)
  - WARNING: `node` and `npm` (or `yarn`, `pnpm`) must be in $PATH.
    - ADVICE:
      - Install Node.js and verify that `node` and `npm` (or `yarn`, `pnpm`) commands work.

## Perl provider (optional)
  - WARNING: "Neovim::Ext" cpan module is not installed
    - ADVICE:
      - See :help |provider-perl| for more information.
      - You may disable this provider (and warning) by adding `let g:loaded_perl_provider = 0` to your init.vim

vim.lsp: require("vim.lsp.health").check()
========================================================================
  - INFO: LSP log level : WARN
  - INFO: Log path: /home/my_username/.local/state/nvim/lsp.log
  - INFO: Log size: 0 KB

vim.treesitter: require("vim.treesitter.health").check()
========================================================================
  - INFO: Runtime ABI version : 14
  - OK: Loaded parser for c: ABI version 13
  - OK: Loaded parser for help: ABI version 14
  - OK: Loaded parser for lua: ABI version 13
  - OK: Loaded parser for vim: ABI version 14

Minimal vimrc that can reproduce this bug.

I included the Packer bootstrapping boilerplate for convenience. Only the "use" statements and the last 4 lines of the below are important.

-- Automatically install Packer on startup.
local install_path = vim.fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
    packer_bootstrap = vim.fn.system
    {
        'git',
        'clone',
        '--depth',
        '1',
        'https://github.com/wbthomason/packer.nvim',
        install_path
    }
    vim.cmd("packadd packer.nvim")
end

local packer = require("packer")
packer.startup(function(use)
    -- Packer needs to manage itself
    use 'wbthomason/packer.nvim'

    use "sainnhe/gruvbox-material"

    -- Installing just for reference.
    use "ellisonleao/gruvbox.nvim"
    -- not "morhetz/gruvbox"

    -- Automatically set up your configuration after cloning packer.nvim
    if packer_bootstrap then
        vim.api.nvim_create_autocmd("User", {
            pattern = "PackerComplete",
            callback = function() print("Installation is complete! Please restart Neovim.") end
        })
        require('packer').sync()
    end
end)

vim.g.gruvbox_material_foreground='original'
vim.cmd("set termguicolors")
vim.cmd("colorscheme gruvbox-material")
-- vim.cmd("colorscheme gruvbox")

Steps to reproduce this bug using minimal vimrc

  1. Launch Neovim. Wait for Packer to install colorschemes. Expected error occurs when it tries to set a colorscheme that's not installed yet. It's fine.
  2. Restart. Observe that colorscheme is applied.
  3. Open a terminal emulator with :ter and press enter.
  4. Install Neofetch with the terminal by running apt install neofetch.
  5. Run neofetch.
  6. Observe output.

Expected behavior

Colors are displayed. There are no duplicates between colors which are meant to be different shades.

With https://github.com/ellisonleao/gruvbox.nvim installed and swapping the comments for the lines:

            -- vim.cmd("colorscheme gruvbox-material")
            vim.cmd("colorscheme gruvbox")

from the provided vimrc, with the regular "gruvbox" colorscheme it looks like this:

image

Actual behavior

Colors that are supposed to be different shades, are instead, the same exact color. image

antoineco commented 2 years ago

I agree, we shouldn't be relying on terminal emulators to display text in bold font for bright colors. This is a dated and hacky practice, and we should use proper bright shades of the Gruvbox Material palette instead for ANSI colors 8 to 15.

@sainnhe maybe it would be simple enough to apply a shade to terminal emulators' bright colors without having to extend the core palette?

sainnhe commented 2 years ago

No. My opinion is that the shade is not really necessary, it's more important to keep darker and brighter colors the same.

Consider this example, there's a terminal app A that decided to use blue to display the text, while a terminal app B decided to use brighterBlue to display text.

So do you want to modify blue or brighterBlue? Current colors are carefully chosen, modified version won't look better.

I agree that the shade is sometimes useful, but considering the previous example we need to make a compromise, and I think keeping the colors the same is more important.

Btw, it's not just this color scheme that does it, another very popular color scheme nord also choose to not use shade.

antoineco commented 2 years ago

A potential shortcoming of this design choice is that, if an application deliberately prints something in "bright blue", it usually signals "I want to put emphasis on that text".

Nowadays modern terminal emulators do not default to "Use bold for bright colors" (related discussion), so part of the users will not see the difference which could be a loss of accessibility.


@samjwill if you fall into the category of users who needs to distinguish between Bright and non-Bright, I would suggest overriding just the options you need in your vimrc/init.lua using an autocmd, and apply a shade to base colors as I proposed above. You can see an example of setting up an autocmd here: https://github.com/sainnhe/gruvbox-material/issues/139#issuecomment-1239121715

antoineco commented 2 years ago

Closing with the following concrete suggestion to apply to your own Neovim config, based on my above comment(s):

:page_facing_up: init.vim

```vim " Apply custom highlights on colorscheme change. " Must be declared before executing ':colorscheme'. augroup custom_highlights_gruvboxmaterial autocmd! " terminal bright colors autocmd ColorScheme gruvbox-material \ let g:terminal_color_0 = '#45403d' | \ let g:terminal_color_9 = '#f0948f' | \ let g:terminal_color_10 = '#cfd6a9' | \ let g:terminal_color_11 = '#e7c898' | \ let g:terminal_color_12 = '#b0cec7' | \ let g:terminal_color_13 = '#dda2b2' | \ let g:terminal_color_14 = '#b4cfaf' | \ let g:terminal_color_15 = '#ddc7a1' augroup END colorscheme gruvbox-material ```

:page_facing_up: init.lua

```lua -- Apply custom highlights on colorscheme change. -- Must be declared before executing ':colorscheme'. grpid = vim.api.nvim_create_augroup('custom_highlights_gruvboxmaterial', {}) vim.api.nvim_create_autocmd('ColorScheme', { group = grpid, pattern = 'gruvbox-material', command = -- terminal bright colors [[let g:terminal_color_0 = '#45403d' |]] .. [[let g:terminal_color_9 = '#f0948f' |]] .. [[let g:terminal_color_10 = '#cfd6a9' |]] .. [[let g:terminal_color_11 = '#e7c898' |]] .. [[let g:terminal_color_12 = '#b0cec7' |]] .. [[let g:terminal_color_13 = '#dda2b2' |]] .. [[let g:terminal_color_14 = '#b4cfaf' |]] .. [[let g:terminal_color_15 = '#ddc7a1' ]] }) vim.cmd'colorscheme gruvbox-material' ```

Before

Screenshot 2022-11-13 at 13 33 11

After

Screenshot 2022-11-13 at 13 36 49