mirror of
https://github.com/neovim/neovim.git
synced 2026-02-09 13:28:47 +00:00
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
632fd8bb96
Co-authored-by: Rob B <github@0x7e.net>
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user