shaunsingh / nord.nvim

Neovim theme based off of the Nord Color Palette, written in lua with tree sitter support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Manually set highlight colors

manuelcattelan opened this issue · comments

Hi @shaunsingh and thanks for your hard work, this colorscheme is lovely!

I was wondering if there's any way to manually change highlight colors. When installed with the default config, the theme comes with a lighter shade of grey as a background color when compared to the README screenshot and I don't really know how to change that.

Thanks in advance and keep up the great work!

@manuelcattelan not the author, but this theme doesn't (yet?) include a helper for overriding highlight groups. Luckily, Vim can do that using autocmd, and the method has the advantage to work with any color scheme:

📄 .vimrc (Vim)

" Apply custom highlights on colorscheme change.
" Must be declared before executing ':colorscheme'.
augroup custom_highlights_nord
  autocmd!
  " default background
  autocmd ColorScheme nord 
  \       hi Normal  guibg=#1C2434 |
  \       hi NonText guibg=#1C2434
augroup END

colorscheme nord

📄 init.lua (Neovim)

-- Apply custom highlights on colorscheme change.
-- Must be declared before executing ':colorscheme'.
grpid = vim.api.nvim_create_augroup('custom_highlights_nord', {})
vim.api.nvim_create_autocmd('ColorScheme', {
  group = grpid,
  pattern = 'nord',
  command = -- default background
            'hi Normal  guibg=#1C2434 |' ..
            'hi NonText guibg=#1C2434'
})

vim.cmd'colorscheme nord'

🎨 Result

image


With that being said, I didn't notice that behaviour myself. I used the color picker on the screenshot, and it does have the same background color as what's defined in the color scheme (see screenshot below).

Could it be that you're running Vim in a terminal that doesn't support 24-bit True Colors, or that you didn't add set termguicolors to your Vim config prior to calling colorscheme nord?

image

@antoineco thanks for the useful info! I'm currently using Kitty (which supports 24-bit true colors) and I did add set termguicolors. I'm guessing I just see the colors of my screen (MacBook Air M1) differently from the screenshot provided in the repo's README.

Glad it helped! I'm also using Kitty on that type of MacBook, so yeah, the issue is probably about expectations and preferences.

The trick I shared is fine for a few overrides, but in practice the background color is applied to many highlight groups in most color schemes, so here is a more sustainable approach:

  1. Create a directory called lua/nord inside your Neovim config path (default: ~/.config/nvim)
  2. Inside this directory, create a copy of the lua/nord/named_colors.lua file found inside this repo
  3. Adjust the palette to your liking
  4. Open Neovim and verify that the modified colors were applied

Thanks a lot for the suggestion, will definitely try it!