shaunsingh / nord.nvim

Neovim theme based off of the Nord Color Palette, written in lua with tree sitter support
GNU General Public License v2.0
803 stars 107 forks source link

Manually set highlight colors #107

Closed manuelcattelan closed 2 years ago

manuelcattelan commented 2 years ago

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!

antoineco commented 2 years ago

@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:

:page_facing_up: .vimrc (Vim)

```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 ```

:page_facing_up: init.lua (Neovim)

```lua -- 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' ```

:art: Result

![image](https://user-images.githubusercontent.com/3299086/188594532-5de67c2c-7b16-4997-b41d-c830524852b3.png)

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

manuelcattelan commented 2 years ago

@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.

antoineco commented 2 years ago

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
manuelcattelan commented 2 years ago

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