Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase the contrast for Visual mode selection #36

Open
EdwarDu opened this issue Sep 24, 2021 · 2 comments
Open

Increase the contrast for Visual mode selection #36

EdwarDu opened this issue Sep 24, 2021 · 2 comments
Labels
enhancement New feature or request workaround The issue can be addressed using a workaround

Comments

@EdwarDu
Copy link

EdwarDu commented Sep 24, 2021

Thank you for the very nice color theme.

For me, the contrast in Vim for Visual mode selection is not very good.
I can manually change it as "call sonokai#highlight('Visual', s:palette.none, s:palette.black)" though.

As this is not a bug, I open this as a blank issue.
If further information is required, please let me know.

@rafgugi
Copy link

rafgugi commented Mar 30, 2023

have the same problem. I don't know how to match color but this gives better contrast.
Also, I change a little bit for the highlight color, because red and green just don't make sense imo

-- Patch color palette for sonokai
local configuration = vim.fn['sonokai#get_configuration']()
local palette = vim.fn['sonokai#get_palette'](configuration.style, configuration.colors_override)
vim.fn['sonokai#highlight']('Visual', palette.none, palette.grey_dim)
vim.fn['sonokai#highlight']('IncSearch', palette.bg0, palette.yellow)
vim.fn['sonokai#highlight']('Search', palette.none, palette.diff_yellow)

@antoineco
Copy link
Collaborator

antoineco commented Apr 22, 2023

To illustrate the changes that were suggested above regarding the visual selections (before/after):

image
image

And the search highlights (before/after):

image
image

I get the point, but it really seems to boil down to personal preferences. For instance, I prefer the current selection to the proposed one.

I do like the suggested search highlights though, but using a low contrast for search results also decreases accessibility, and might overlap with highlighted code and/or LSP diagnostics. Not to mention that every one will have their preference of blue, yellow, green, ...

It's normal for users to enjoy tweaking little things in their favourite color scheme, and for this I always recommend using an autocmd to apply those on a per-colorscheme basis:

-- Apply custom highlights on colorscheme change.
-- Must be declared before executing ':colorscheme'.
local grpid = vim.api.nvim_create_augroup('custom_highlights_sonokai', {})
vim.api.nvim_create_autocmd('ColorScheme', {
  group = grpid,
  pattern = 'sonokai',
  callback = function()
    local config = vim.fn['sonokai#get_configuration']()
    local palette = vim.fn['sonokai#get_palette'](config.style, config.colors_override)
    local set_hl = vim.fn['sonokai#highlight']

    set_hl('Visual', palette.none, palette.black)
    set_hl('IncSearch', palette.bg0, palette.yellow)
    set_hl('Search', palette.none, palette.diff_yellow)
  end
})

edit: this type of customizations is now documented.

@antoineco antoineco changed the title To increase the contrast for Visual mode selection in Vim Increase the contrast for Visual mode selection Apr 22, 2023
@antoineco antoineco added the enhancement New feature or request label Aug 3, 2023
@antoineco antoineco added the workaround The issue can be addressed using a workaround label Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request workaround The issue can be addressed using a workaround
Projects
None yet
Development

No branches or pull requests

3 participants