Skip to content

Commit 1ee1d9b

Browse files
jparisechrisbra
authored andcommitted
runtime(python): highlight "self" and "cls" in syntax script
These are special names by convention, and giving them distinct highlighting is a nice visual clue (using Identifier by default). This group is named "pythonClassVar" to match the name used by python-syntax. Some third-party color schemes are aware of this name and customized their colors accordingly. closes: #17968 Signed-off-by: Jon Parise <[email protected]> Signed-off-by: Zvezdan Petkovic <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent dd9ed09 commit 1ee1d9b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

runtime/syntax/python.vim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" Vim syntax file
22
" Language: Python
33
" Maintainer: Zvezdan Petkovic <[email protected]>
4-
" Last Change: 2025 Aug 11
4+
" Last Change: 2025 Aug 13
55
" Credits: Neil Schemenauer <[email protected]>
66
" Dmitry Vasiliev
77
" Rob B
@@ -113,6 +113,10 @@ syn keyword pythonAsync async await
113113
syn match pythonConditional "^\s*\zscase\%(\s\+.*:.*$\)\@="
114114
syn match pythonConditional "^\s*\zsmatch\%(\s\+.*:\s*\%(#.*\)\=$\)\@="
115115

116+
" These names are special by convention. While they aren't real keywords,
117+
" giving them distinct highlighting provides a nice visual cue.
118+
syn keyword pythonClassVar self cls
119+
116120
" Decorators
117121
" A dot must be allowed because of @MyClass.myfunc decorators.
118122
syn match pythonDecorator "@" display contained
@@ -378,6 +382,7 @@ hi def link pythonOperator Operator
378382
hi def link pythonException Exception
379383
hi def link pythonInclude Include
380384
hi def link pythonAsync Statement
385+
hi def link pythonClassVar Identifier
381386
hi def link pythonDecorator Define
382387
hi def link pythonDecoratorName Function
383388
hi def link pythonClass Structure

0 commit comments

Comments
 (0)