nordtheme / vim

An arctic, north-bluish clean and elegant Vim theme.
https://www.nordtheme.com/ports/vim
MIT License
2.51k stars 275 forks source link

I'm very confused on how to override default nord colorscheme #259

Closed AlphabetsAlphabets closed 3 years ago

AlphabetsAlphabets commented 3 years ago

I was following this guide on how to override the default nord color scheme, I wanted to try out the frost color palette, and I used the example provided in the guide above.

This is my plugins.vim file and a snippet of it that contains configs related to colorschemes

augroup nord-theme-overrides
  autocmd!
  " Use 'nord7' as foreground color for Vim comment titles.
  autocmd ColorScheme nord highlight vimCommentTitle ctermfg=14 guifg=#8FBCBB
augroup END

colorscheme nord
let g:airline_powerline_fonts = 1
" https://github.com/vim-airline/vim-airline-themes
autocmd VimEnter * ++nested AirlineTheme nord

I've tried many things such as moving colorscheme nord inside the augroup blocks, and using the autocmd VimEnter on it as well. But nothing is changing. I'm relatively new to nvim so there is probably something I'm missing.

After sourcing the file, nothing has changed. I even change the highlight group to Search and the highlight color worked, but I'm not sure why it didn't work for vimCommentTitle

And at this point I'm just trying random things like this:

augroup nord-theme-overrides
  autocmd!
  " Use 'nord7' as foreground color for Vim comment titles.
  autocmd ColorScheme nord highlight vimCommentTitle ctermfg=14 guifg=#88c0d0 guibg=#8FBCBB
augroup END

To get at least some changes from the default but nothing.

arcticicestudio commented 3 years ago

Hi @YJH16120 :wave:

I even change the highlight group to Search and the highlight color worked.

This indicates that youraugroup definition works fine. The vimCommentTitle group is just an example and might not be available when your currently opened file is highlighted by a specific syntax highlighter. For example, if you're editing a HTML file (*.html) a line like TODO: the vimCommentTitle group is not active and responsible for it. A valid HTML comment (<!-- TODO -->) will be colored correctly but using the htmlComment group instead.

This all means that you need to know the highlighting group for a syntax highlighter when you want to customize it instead of using Nords styles. To simplify the development of Nord I've added the following function to my Vim configuration that allows me to press Ctrl+k to print the highlight group(s) of the element under the caret.

" Shows syntax highlighting groups for the current cursor position
nmap <C-S-K> :call <SID>SynStack()<CR>
function! <SID>SynStack()
  if !exists("*synstack")
    return
  endif
  echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc
AlphabetsAlphabets commented 3 years ago

I see so then all I need to do is to just go through each comment group, find out what they are with that code snippet you gave me, then configure it accordingly then?

arcticicestudio commented 3 years ago

Correct, even through most plugins and syntax definitions link to default groups like Comment, but for the ones that do not it requires this small additional snippets.

AlphabetsAlphabets commented 3 years ago

I see, thank you. I've messed around and it started to work.