From 4008bb543bc112fd4ff284c70d227ced75c162e7 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Tue, 25 Nov 2025 17:58:40 +0100 Subject: [PATCH] vim:looks: Don't hardcode the colorscheme colors --- .config/vim/vimrc.d/50-looks.vim | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/.config/vim/vimrc.d/50-looks.vim b/.config/vim/vimrc.d/50-looks.vim index 5045e4b..76c244b 100644 --- a/.config/vim/vimrc.d/50-looks.vim +++ b/.config/vim/vimrc.d/50-looks.vim @@ -50,14 +50,24 @@ if (get(g:, 'loaded_fzf')) endif endif +" Get red from my colorscheme +let s:red = {} +if exists("*onedark#GetColors") + let s:red = onedark#GetColors()->get("red", {}) +endif +let s:red_cterm = s:red->get("cterm", "red") +let s:red_gui = s:red->get("gui", "red") + " Highlight trailing whitespaces if match(&listchars, 'trail: \@!') > -1 && match(&listchars, '\vtab:( +)@!') > -1 " Use foreground for coloring if tabs and trailing spaces are displayed " as non-space characters - highlight TrailingWhitespace ctermfg=204 guifg=#e06c75 + execute "highlight TrailingWhitespace ctermfg=" .. s:red_cterm + \ .. " guifg=" .. s:red_gui else " Background otherwise - highlight TrailingWhitespace ctermbg=204 guibg=#e06c75 + execute "highlight TrailingWhitespace ctermbg=" .. s:red_cterm + \ .. " guibg=" .. s:red_gui endif augroup HighlightTrailingWhitespace au! @@ -74,8 +84,10 @@ let g:spl_special_chars = { \ 'fr': 'àâæçèéêëîïôœùûüÿÀÂÆÇÈÉÊËÎÏÔŒÙÛÜŸ', \ } -" Highlight non-ASCII characters in the red used by my color scheme "OneDark" -highlight NonASCIIChars ctermfg=white guifg=white ctermbg=204 guibg=#e06c75 +" Highlight non-ASCII characters in red +execute "highlight NonASCIIChars ctermfg=white guifg=white " + \ .. "ctermbg=" .. s:red_cterm .. " guibg=" .. s:red_gui + " Do not highlight special characters that are valid in the respective spelllang function! HighlightNonASCIIChars() if exists('w:non_ascii_match_id')