]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(colors): color names in the v:colornames dict should be lower cased
authorChristian Brabandt <cb@256bit.org>
Mon, 5 Feb 2024 09:30:01 +0000 (10:30 +0100)
committerChristian Brabandt <cb@256bit.org>
Mon, 5 Feb 2024 09:34:26 +0000 (10:34 +0100)
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>
runtime/colors/lists/csscolors.vim
runtime/colors/lists/default.vim
runtime/doc/eval.txt
runtime/doc/syntax.txt

index 74955226c2f7460f286dcc60a2764799a87a49a2..986333d7793bb333897696117d12d2d1f5691b19 100644 (file)
@@ -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
 
index 7d81c6f75e4fb0fb2b5b0254be1a8df4833d117a..073a0da11bafe79ed6012d0c520576719d9aa63e 100644 (file)
@@ -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
 
index 9c12fb8504b0fc86690fcbcb2ffeec51db4dc734..574b9c9dd97fa7157dfc373417674c56f0488cd8 100644 (file)
@@ -1,4 +1,4 @@
-*eval.txt*     For Vim version 9.1.  Last change: 2024 Jan 14
+*eval.txt*     For Vim version 9.1.  Last change: 2024 Feb 05
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -2005,9 +2005,14 @@ v:collate        The current locale setting for collation order of the runtime
                                                                *v:colornames*
 v:colornames    A dictionary that maps color names to hex color strings. These
                color names can be used with the |highlight-guifg|,
-               |highlight-guibg|, and |highlight-guisp| parameters. Updating
-               an entry in v:colornames has no immediate effect on the syntax
-               highlighting. The highlight commands (probably in a
+               |highlight-guibg|, and |highlight-guisp| parameters.
+
+               The key values in the dictionary (the color names) should be
+               lower cased, because Vim looks up a color by its lower case
+               name.
+
+               Updating an entry in v:colornames has no immediate effect on
+               the syntax highlighting. The highlight commands (probably in a
                colorscheme script) need to be re-evaluated in order to use
                the updated color values. For example: >
 
index c4f59aee1b2ae34775387428376ec5d183a4eeeb..1c9f6f2b58e3fe4ab0b8d99a802fb6ed467f97bd 100644 (file)
@@ -1,4 +1,4 @@
-*syntax.txt*   For Vim version 9.1.  Last change: 2024 Jan 24
+*syntax.txt*   For Vim version 9.1.  Last change: 2024 Feb 05
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -5265,7 +5265,8 @@ ctermul={color-nr}                                *highlight-ctermul*
        "cterm=" argument AFTER the "ctermfg=" or "ctermbg=" argument.  Or use
        a number instead of a color name.
 
-       The case of the color names is ignored.
+       The case of the color names is ignored, however Vim will use lower
+       case color names when reading from the |v:colornames| dictionary.
        Note that for 16 color ansi style terminals (including xterms), the
        numbers in the NR-8 column is used.  Here '*' means 'add 8' so that
        Blue is 12, DarkGray is 8 etc.
@@ -5384,8 +5385,8 @@ guisp={color-name}                                        *highlight-guisp*
            :highlight Comment guifg=#11f0c3 guibg=#ff00ff
 <
        If you are authoring a color scheme and use the same hexadecimal value
-       repeatedly, you can define a name for it in |v:colornames|. For
-       example: >
+       repeatedly, you can define a (lower case) name for it in |v:colornames|.
+       For example: >
 
            # provide a default value for this color but allow the user to
            # override it.