summaryrefslogtreecommitdiffstats
path: root/runtime/colors
diff options
context:
space:
mode:
authorChristian Brabandt <cb@256bit.org>2024-02-05 10:30:01 +0100
committerChristian Brabandt <cb@256bit.org>2024-02-05 10:34:26 +0100
commit0f4054feb66ea55414f97add63b3070d7d7b5295 (patch)
tree4b632c5a1ef083d216d8fe3daf35f201748bb1f2 /runtime/colors
parentde7f5bde6c598d4da4ce5b30328eb458962ba60a (diff)
runtime(colors): color names in the v:colornames dict should be lower cased
Vim will lookup color names from the v:colornames dictionary by its lower case color name. So when sourcing the v:colornames dictionary, make sure to convert upper case color names to lower case. Also, while at it, mention in the documentation, that the dictionary should contain lower case names only. fixes: #13976 Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'runtime/colors')
-rw-r--r--runtime/colors/lists/csscolors.vim12
-rw-r--r--runtime/colors/lists/default.vim10
2 files changed, 21 insertions, 1 deletions
diff --git a/runtime/colors/lists/csscolors.vim b/runtime/colors/lists/csscolors.vim
index 74955226c2..986333d779 100644
--- a/runtime/colors/lists/csscolors.vim
+++ b/runtime/colors/lists/csscolors.vim
@@ -4,6 +4,9 @@
" Similar in spirit to rgb.txt, this plugin establishes a human-friendly name
" for every color listed in the CSS standard:
"
+" Note: the color names should be in lower case, because Vim will lookup the
+" a color by its lower case name.
+"
" https://www.w3.org/TR/css-color-3/
let s:keepcpo= &cpo
@@ -26,7 +29,6 @@ call extend(v:colornames, {
\ 'css_blue': '#0000FF',
\ 'css_teal': '#008080',
\ 'css_aqua': '#00FFFF',
- \
\ 'css_aliceblue': '#f0f8ff',
\ 'css_antiquewhite': '#faebd7',
\ 'css_aquamarine': '#7fffd4',
@@ -160,6 +162,14 @@ call extend(v:colornames, {
\ 'css_yellowgreen': '#9acd32',
\ }, 'keep')
+" all keys should be in lower case, convert keys that are not yet
+for [key, val] in items(filter(copy(v:colornames), { key -> key =~ '\u'}))
+ call remove(v:colornames, key)
+ if !has_key(v:colornames, tolower(key))
+ call extend(v:colornames, {tolower(key): val}, 'keep')
+ endif
+endfor
+
let &cpo= s:keepcpo
unlet s:keepcpo
diff --git a/runtime/colors/lists/default.vim b/runtime/colors/lists/default.vim
index 7d81c6f75e..073a0da11b 100644
--- a/runtime/colors/lists/default.vim
+++ b/runtime/colors/lists/default.vim
@@ -6,6 +6,8 @@
" time the highlight command fails to recognize a gui color. You can override
" these colors by introducing a new colors/lists/default.vim file earlier in
" the runtimepath.
+" Note: the color names should be in lower case, because Vim will lookup the
+" a color by its lower case name.
" make sure line continuation works
let s:keepcpo = &cpo
@@ -802,6 +804,14 @@ call extend(v:colornames, {
\ 'teal': '#008080'
\ }, 'keep')
+" all keys should be in lower case, convert keys that are not yet
+for [key, val] in items(filter(copy(v:colornames), { key -> key =~ '\u'}))
+ call remove(v:colornames, key)
+ if !has_key(v:colornames, tolower(key))
+ call extend(v:colornames, {tolower(key): val}, 'keep')
+ endif
+endfor
+
let &cpo = s:keepcpo
unlet s:keepcpo