sainnhe / sonokai

High Contrast & Vivid Color Scheme based on Monokai Pro
MIT License
1.68k stars 120 forks source link

Increase the contrast for Visual mode selection #36

Open EdwarDu opened 3 years ago

EdwarDu commented 3 years ago

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 commented 1 year ago

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 commented 1 year ago

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.