diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2026-01-27 07:13:57 +0800 |
|---|---|---|
| committer | zeertzjq <zeertzjq@outlook.com> | 2026-01-27 07:20:41 +0800 |
| commit | 6543217afc0203f5edafc6c696a70be1ac7f4923 (patch) | |
| tree | d587ffa22c969168287b1466adc01c770b1d39b0 /runtime/syntax/python.vim | |
| parent | d6fc5cbf55977eb6af9bfa8075b6e6a26be19e83 (diff) | |
| download | rneovim-6543217afc0203f5edafc6c696a70be1ac7f4923.tar.gz rneovim-6543217afc0203f5edafc6c696a70be1ac7f4923.tar.bz2 rneovim-6543217afc0203f5edafc6c696a70be1ac7f4923.zip | |
vim-patch:632fd8b: runtime(python): Highlight built-in constants in Python
Also add syntax tests for those newly constants.
closes: vim/vim#17788
closes: vim/vim#18922
https://github.com/vim/vim/commit/632fd8bb968b029d0a7c40a00101008ea5200b91
Co-authored-by: Rob B <github@0x7e.net>
Diffstat (limited to 'runtime/syntax/python.vim')
| -rw-r--r-- | runtime/syntax/python.vim | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/runtime/syntax/python.vim b/runtime/syntax/python.vim index 27eaeb1571..1e7bf3cd07 100644 --- a/runtime/syntax/python.vim +++ b/runtime/syntax/python.vim @@ -4,6 +4,7 @@ " Last Change: 2025 Sep 08 " 2025 Sep 25 by Vim Project: fix wrong type highlighting #18394 " 2025 Dec 03 by Vim Project: highlight t-strings #18679 +" 2026 Jan 26 by Vim Project: highlight constants #18922 " Credits: Neil Schemenauer <nas@python.ca> " Dmitry Vasiliev " Rob B @@ -34,6 +35,7 @@ " let python_no_exception_highlight = 1 " let python_no_number_highlight = 1 " let python_space_error_highlight = 1 +" let python_constant_highlight = 1 " " All the options above can be switched on together. " @@ -85,6 +87,7 @@ if exists("python_highlight_all") unlet python_no_number_highlight endif let python_space_error_highlight = 1 + let python_constant_highlight = 1 endif " Keep Python keywords in alphabetical order inside groups for easy @@ -97,7 +100,8 @@ endif " " python3 -c 'import keyword, pprint; pprint.pprint(keyword.kwlist + keyword.softkwlist, compact=True)' " -syn keyword pythonStatement False None True +syn keyword pythonBoolean False True +syn keyword pythonConstant None syn keyword pythonStatement as assert break continue del global syn keyword pythonStatement lambda nonlocal pass return with yield syn keyword pythonStatement class nextgroup=pythonClass skipwhite @@ -296,8 +300,8 @@ endif if !exists("python_no_builtin_highlight") " built-in constants " 'False', 'True', and 'None' are also reserved words in Python 3 - syn keyword pythonBuiltin False True None - syn keyword pythonBuiltin NotImplemented Ellipsis __debug__ + syn keyword pythonBoolean False True + syn keyword pythonConstant None NotImplemented Ellipsis __debug__ " constants added by the `site` module syn keyword pythonBuiltin quit exit copyright credits license " built-in functions @@ -391,6 +395,8 @@ endif syn sync match pythonSync grouphere NONE "^\%(def\|class\|async\s\+def\)\s\+\h\w*\s*[(:]" " The default highlight links. Can be overridden later. +hi def link pythonBoolean Statement +hi def link pythonConstant Statement hi def link pythonStatement Statement hi def link pythonConditional Conditional hi def link pythonRepeat Repeat @@ -421,6 +427,8 @@ if !exists("python_no_number_highlight") hi def link pythonNumber Number endif if !exists("python_no_builtin_highlight") + hi! def link pythonBoolean Function + hi! def link pythonConstant Function hi def link pythonBuiltin Function hi def link pythonEllipsis pythonBuiltin endif @@ -434,6 +442,10 @@ if !exists("python_no_doctest_highlight") hi def link pythonDoctest Special hi def link pythonDoctestValue Define endif +if exists("python_constant_highlight") + hi! def link pythonBoolean Boolean + hi! def link pythonConstant Constant +endif let b:current_syntax = "python" |