sainnhe / gruvbox-material

Gruvbox with Material Palette
MIT License
1.81k stars 164 forks source link

hop hint is not visible when searching text are highlight #189

Open Weissle opened 7 months ago

Weissle commented 7 months ago

I have done the following steps before reporting this issue:

Operating system/version

WSL Ubuntu20.04

Terminal emulator/version

Windows terminal 1.18.3181.0

$TERM environment variable

tmux-256color

Tmux version

tmux 3.0a

Feature matrix


==============================================================================
conform: require("conform.health").check()

conform.nvim report ~
- Log file: /home/weissle/.local/state/nvim/conform.log
- OK beautysh ready (sh)
- OK black ready (python)
- OK jq ready (json)
- OK stylua ready (lua)

==============================================================================
diffview: require("diffview.health").check()

Checking plugin dependencies ~
- OK nvim-web-devicons installed.

Checking VCS tools ~
- The plugin requires at least one of the supported VCS tools to be valid.
- OK Git found.
- OK Git is up-to-date. (2.40.1)
- WARNING Configured `hg_cmd` is not executable: 'hg'

==============================================================================
hop: require("hop.health").check()

Ensuring keys are unique ~
- OK Keys are unique

Checking for deprecated features ~
- OK All good

==============================================================================
lazy: require("lazy.health").check()

lazy.nvim ~
- OK Git installed
- OK no existing packages found by other package managers
- OK packer_compiled.lua not found

==============================================================================
mason: require("mason.health").check()

mason.nvim ~
- OK mason.nvim version v1.8.3
- OK PATH: prepend
- OK Providers: 
  mason.providers.registry-api
  mason.providers.client
- OK neovim version >= 0.7.0

mason.nvim [Registries] ~
- OK Registry `github.com/mason-org/mason-registry version: 2023-12-09-crisp-queen` is installed.

mason.nvim [Core utils] ~
- OK unzip: `UnZip 6.00 of 20 April 2009, by Debian. Original by Info-ZIP.`
- OK wget: `GNU Wget 1.20.3 built on linux-gnu.`
- OK curl: `curl 8.2.1 (x86_64-conda-linux-gnu) libcurl/8.2.1 OpenSSL/3.2.0 zlib/1.2.13 zstd/1.5.5 libssh2/1.11.0 nghttp2/1.52.0`
- OK gzip: `gzip 1.10`
- OK tar: `tar (GNU tar) 1.30`
- OK bash: `GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)`
- OK sh: `Ok`

mason.nvim [Languages] ~
- WARNING Go: not available
  - ADVICE:
    - spawn: go failed with exit code - and signal -. go is not executable
- WARNING Composer: not available
  - ADVICE:
    - spawn: composer failed with exit code - and signal -. composer is not executable
- WARNING luarocks: not available
  - ADVICE:
    - spawn: luarocks failed with exit code - and signal -. luarocks is not executable
- WARNING Ruby: not available
  - ADVICE:
    - spawn: ruby failed with exit code - and signal -. ruby is not executable
- WARNING RubyGem: not available
  - ADVICE:
    - spawn: gem failed with exit code - and signal -. gem is not executable
- WARNING javac: not available
  - ADVICE:
    - spawn: javac failed with exit code - and signal -. javac is not executable
- WARNING java: not available
  - ADVICE:
    - spawn: java failed with exit code - and signal -. java is not executable
- WARNING julia: not available
  - ADVICE:
    - spawn: julia failed with exit code - and signal -. julia is not executable
- OK node: `v20.8.0`
- OK cargo: `cargo 1.73.0 (9c4383fb5 2023-08-26)`
- OK PHP: `PHP 7.4.3 (cli) (built: Jul  5 2021 15:13:35) ( NTS )`
- OK python: `Python 3.10.9`
- OK npm: `10.1.0`
- OK pip: `pip 23.2.1 from /home/weissle/miniconda3/lib/python3.10/site-packages/pip (python 3.10)`
- OK python venv: `Ok`

mason.nvim [GitHub] ~
- OK GitHub API rate limit. Used: 4. Remaining: 56. Limit: 60. Reset: Wed Dec 13 23:36:51 2023.
  Install and authenticate via gh-cli to increase rate limit.

==============================================================================
nvim: require("nvim.health").check()

Configuration ~
- OK no issues found

Runtime ~
- OK $VIMRUNTIME: /home/weissle/.local/bin/spec/nvim_v0.9.4/share/nvim/runtime

Performance ~
- OK Build type: Release

Remote Plugins ~
- OK Up to date

terminal ~
- key_backspace (kbs) terminfo entry: `key_backspace=\177`
- key_dc (kdch1) terminfo entry: `key_dc=\E[3~`

tmux ~
- OK escape-time: 10
- OK focus-events: on
- $TERM: tmux-256color

==============================================================================
nvim-treesitter: require("nvim-treesitter.health").check()

Installation ~
- WARNING `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
- OK `node` found v20.8.0 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
  Version: cc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
  machine = "x86_64",
  release = "5.10.102.1-microsoft-standard-WSL2",
  sysname = "Linux",
  version = "#1 SMP Wed Mar 2 00:30:59 UTC 2022"
} ~

Parser/Features         H L F I J
  - bash                ✓ ✓ ✓ . ✓
  - c                   ✓ ✓ ✓ ✓ ✓
  - cmake               ✓ . ✓ ✓ .
  - cpp                 ✓ ✓ ✓ ✓ ✓
  - html                ✓ ✓ ✓ ✓ ✓
  - json                ✓ ✓ ✓ ✓ .
  - lua                 ✓ ✓ ✓ ✓ ✓
  - markdown            ✓ . ✓ ✓ ✓
  - python              ✓ ✓ ✓ ✓ ✓
  - query               ✓ ✓ ✓ ✓ ✓
  - rust                ✓ ✓ ✓ ✓ ✓
  - vim                 ✓ ✓ ✓ . ✓
  - vimdoc              ✓ . . . ✓
  - xml                 ✓ ✓ ✓ ✓ ✓

  Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang} ~

==============================================================================
provider: health#provider#check

Clipboard (optional) ~
- OK Clipboard tool found: win32yank

Python 3 provider (optional) ~
- `g:python3_host_prog` is not set.  Searching for python3.8 in the environment.
- Multiple python3.8 executables found.  Set `g:python3_host_prog` to avoid surprises.
- Executable: /usr/bin/python3.8
- Other python executable: /bin/python3.8
- ERROR Command error (job=15, exit code 1): `'/usr/bin/python3.8' -c 'import sys; sys.path = [p for p in sys.path if p != ""]; import neovim; print(neovim.__file__)'` (in '/home/weissle/.config/dotfiles/nvim')
  stderr: Traceback (most recent call last):  File "<string>", line 1, in <module>  File "/home/weissle/.local/lib/python3.8/site-packages/neovim/__init__.py", line 5, in <module>    import pynvim  File "/home/weissle/.local/lib/python3.8/site-packages/pynvim/__init__.py", line 9, in <module>    from pynvim.api import Nvim, NvimError  File "/home/weissle/.local/lib/python3.8/site-packages/pynvim/api/__init__.py", line 7, in <module>    from pynvim.api.buffer import Buffer  File "/home/weissle/.local/lib/python3.8/site-packages/pynvim/api/buffer.py", line 2, in <module>    from pynvim.api.common import Remote  File "/home/weissle/.local/lib/python3.8/site-packages/pynvim/api/common.py", line 4, in <module>    from msgpack import unpackbModuleNotFoundError: No module named 'msgpack'
- Python version: 3.8.5
- pynvim version: unable to load neovim Python module
- ERROR pynvim is not installed.
  Error: unable to load neovim Python module
  - ADVICE:
    - Run in shell: /usr/bin/python3.8 -m pip install pynvim

Python virtualenv ~
- OK no $VIRTUAL_ENV

Ruby provider (optional) ~
- WARNING `ruby` and `gem` must be in $PATH.
  - ADVICE:
    - Install Ruby and verify that `ruby` and `gem` commands work.

Node.js provider (optional) ~
- Node.js: v20.8.0
- WARNING Missing "neovim" npm (or yarn, pnpm) package.
  - ADVICE:
    - Run in shell: npm install -g neovim
    - Run in shell (if you use yarn): yarn global add neovim
    - Run in shell (if you use pnpm): pnpm install -g neovim
    - You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim

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

==============================================================================
telescope: require("telescope.health").check()

Checking for required plugins ~
- OK plenary installed.
- OK nvim-treesitter installed.

Checking external dependencies ~
- OK rg: found ripgrep 13.0.0 (rev 604cb8a730)
- OK fd: found fd 8.5.3

===== Installed extensions ===== ~

Telescope Extension: `frecency` ~
- sqlite.lua is required when use_sqlite = true
- OK nvim-web-devicons installed.

Telescope Extension: `fzf` ~
- OK lib working as expected
- OK file_sorter correctly configured
- OK generic_sorter correctly configured

Telescope Extension: `live_grep_args` ~
- No healthcheck provided

==============================================================================
vim.lsp: require("vim.lsp.health").check()

- LSP log level : WARN
- Log path: /home/weissle/.local/state/nvim/lsp.log
- Log size: 11594 KB

vim.lsp: Active Clients ~
- lua_ls (id=1, root_dir=/home/weissle/.config/dotfiles/nvim/lua/)

==============================================================================
vim.treesitter: require("vim.treesitter.health").check()

- Nvim runtime ABI version: 14
- OK Parser: bash       ABI: 14, path: /home/weissle/.local/share/nvim/lazy/nvim-treesitter/parser/bash.so
- OK Parser: c          ABI: 14, path: /home/weissle/.local/share/nvim/lazy/nvim-treesitter/parser/c.so
- OK Parser: cmake      ABI: 14, path: /home/weissle/.local/share/nvim/lazy/nvim-treesitter/parser/cmake.so
- OK Parser: cpp        ABI: 14, path: /home/weissle/.local/share/nvim/lazy/nvim-treesitter/parser/cpp.so
- OK Parser: html       ABI: 14, path: /home/weissle/.local/share/nvim/lazy/nvim-treesitter/parser/html.so
- OK Parser: json       ABI: 14, path: /home/weissle/.local/share/nvim/lazy/nvim-treesitter/parser/json.so
- OK Parser: lua        ABI: 14, path: /home/weissle/.local/share/nvim/lazy/nvim-treesitter/parser/lua.so
- OK Parser: markdown   ABI: 14, path: /home/weissle/.local/share/nvim/lazy/nvim-treesitter/parser/markdown.so
- OK Parser: python     ABI: 14, path: /home/weissle/.local/share/nvim/lazy/nvim-treesitter/parser/python.so
- OK Parser: rust       ABI: 14, path: /home/weissle/.local/share/nvim/lazy/nvim-treesitter/parser/rust.so
- OK Parser: vim        ABI: 14, path: /home/weissle/.local/share/nvim/lazy/nvim-treesitter/parser/vim.so
- OK Parser: xml        ABI: 14, path: /home/weissle/.local/share/nvim/lazy/nvim-treesitter/parser/xml.so
- OK Parser: c          ABI: 14, path: /home/weissle/.local/bin/spec/nvim_v0.9.4/lib/nvim/parser/c.so
- OK Parser: lua        ABI: 14, path: /home/weissle/.local/bin/spec/nvim_v0.9.4/lib/nvim/parser/lua.so
- OK Parser: query      ABI: 14, path: /home/weissle/.local/bin/spec/nvim_v0.9.4/lib/nvim/parser/query.so
- OK Parser: vim        ABI: 14, path: /home/weissle/.local/bin/spec/nvim_v0.9.4/lib/nvim/parser/vim.so
- OK Parser: vimdoc     ABI: 14, path: /home/weissle/.local/bin/spec/nvim_v0.9.4/lib/nvim/parser/vimdoc.so

Minimal vimrc that can reproduce this bug.

vim.opt.termguicolors = true
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({
        "git",
        "clone",
        "--filter=blob:none",
        "https://github.com/folke/lazy.nvim.git",
        "--branch=stable", -- latest stable release
        lazypath,
    })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
    {
        "sainnhe/gruvbox-material",
    },
    {
        "smoka7/hop.nvim",
        version = "*",
        name = "hop",
        opts = {},
    },
})

vim.cmd("colorscheme gruvbox-material")

Steps to reproduce this bug using minimal vimrc

search a word. move the cursor away from it. The searched word is highlighted. run HopWord. The hint in the searched word is invisible.

Expected behavior

"smoka7/hop.nvim"'s default highlight seems better. I deleted the highlight defined in gruvbox then got below highlights. image

Actual behavior

The hint in the searched word is invisible. RRI@K}7_I`E(8E0U0NB59M8

antoineco commented 7 months ago

The Hop plug-in seems to be using quite a few different highlight groups based on their docs. Maybe one of them links to a core highlight group which doesn't work well in this context, or which is set to a color that conflicts with the Gruvbox Material palette.

I need to install the plug-in and optimize it. Meanwhile if you come up with suggestions feel free to share!

Weissle commented 7 months ago

https://github.com/sainnhe/gruvbox-material/blob/7f56d9f9c4860df528031539d321a61f6e081dee/colors/gruvbox-material.vim#L1230 I think gruvbox overrides the highlights in here.

antoineco commented 7 months ago

I just noticed the gradients for multi-letter matches:

image

To better support this and similar plugins, we have to pick colors which:

Purple doesn't look great with CurSearch: image

Yellow doesn't look great with Search: image

Blue doesn't look great with Search: image

Disclaimer: the Everforest colorscheme was used in my screenshots, but both themes have similar color semantics and palette design.

I'm wondering whether we shouldn't instead have an option to reduce the contrast of Search and CurSearch, so that this type of "quick jump" plugins play nicer with search highlights. Something like this was suggested in https://github.com/sainnhe/sonokai/issues/36#issuecomment-1518897205 (see the second set of screenshots with search highlights).

Weissle commented 7 months ago

CurSearch is not important because people use hop to jump to remote places.

antoineco commented 7 months ago

Sure, but so is Search then, isn't it? I could argue that the search results have nothing to do with Hop, and that the easiest "fix" is to clear search results before toggling a hop.

If you search for some characters in Neovim, the match you last jumped to will be highlighted in red, which will inevitably lead to invisible characters as well if not optimized correctly.

Weissle commented 6 months ago

and that the easiest "fix" is to clear search results before toggling a hop.

That's current my solution. Usually, I search for something, run <cmd>noh<cr>, and use hop to jump to there.

If you search for some characters in Neovim, the match you last jumped to will be highlighted in red, which will inevitably lead to invisible characters as well if not optimized correctly.

The hint in CurSearch is not important because our cursor already around there. Right?

antoineco commented 6 months ago

OK fair, thanks for your input! 🙌

I'll submit a PR and tag you on it before merging.

antoineco commented 6 months ago

@Weissle sorry for the delay. I finally found the time to experiment with the plugin a little more.

Here is what a color optimization would look like if we wanted to play nice with Search highlights:

red-orange-purple

I'm not particularly happy about it. This is less visually consistent than our current green-orange defaults (your original screenshot), the only advantage is that the Search edge case is now covered and characters inside searched expressions are visible.

:page_facing_up: Neovim config

```lua -- Apply custom highlights on colorscheme change. -- Must be declared before executing ':colorscheme'. local grpid = vim.api.nvim_create_augroup('custom_highlights_gruvbox_material', {}) vim.api.nvim_create_autocmd('ColorScheme', { group = grpid, pattern = 'gruvbox-material', callback = function() local config = vim.fn['gruvbox_material#get_configuration']() local palette = vim.fn['gruvbox_material#get_palette'](config.background, config.foreground, config.colors_override) local set_hl = vim.fn['gruvbox_material#highlight'] set_hl('HopNextKey', palette.purple, palette.none) set_hl('HopNextKey1', palette.red, palette.none) set_hl('HopNextKey2', palette.orange, palette.none) end }) ```


An alternative I suggested earlier is to instead modify the Search background highlight color to something less contrasted:

search-hl

In my opinion this is a lot nicer than what the above is trying to achieve. By using a less contrasted background color for searched expressions, we have a better guarantee that EasyMotion-like plugins—such as Hop—are not going to interfere with search results.

It would probably be useful if the colorscheme had an option to enable this (search_highlight_contrast, search_highlight_style, etc.), meanwhile I'm including a Neovim snippet that you can try including inside your own config.

Feedback welcome!

:page_facing_up: Neovim config

```lua -- Apply custom highlights on colorscheme change. -- Must be declared before executing ':colorscheme'. local grpid = vim.api.nvim_create_augroup('custom_highlights_gruvbox_material', {}) vim.api.nvim_create_autocmd('ColorScheme', { group = grpid, pattern = 'gruvbox-material', callback = function() local config = vim.fn['gruvbox_material#get_configuration']() local palette = vim.fn['gruvbox_material#get_palette'](config.background, config.foreground, config.colors_override) local set_hl = vim.fn['gruvbox_material#highlight'] set_hl('Search', palette.none, palette.bg_visual_yellow) set_hl('IncSearch', palette.none, palette.bg_visual_red) end }) ```

Weissle commented 6 months ago

thanks. I will try it for few days and write the feedback here.

Weissle commented 5 months ago

I think the first solution would be better. The second solution effects the users who don't use hop.nvim and the search highlight is not so visible. Thanks.