Skip to content

Commit aa7aba6

Browse files
committed
Highlight self and cls attributes
1 parent 49fd76c commit aa7aba6

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ Options used by the script
103103
Highlight builtin objects only
104104
``python_highlight_builtin_funcs``
105105
Highlight builtin functions only
106+
``python_highlight_self``
107+
Highlight self and cls attributes
106108
``python_highlight_exceptions``
107109
Highlight standard exceptions
108110
``python_highlight_string_formatting``

syntax.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ Options used by the script
4040
:let python_highlight_builtin_objs = 1
4141
< Highlight builtin functions only >
4242
:let python_highlight_builtin_funcs = 1
43+
< Highlight self and cls attributes >
44+
:let python_highlight_self = 1
4345
< Highlight standard exceptions >
4446
:let python_highlight_exceptions = 1
4547
< Highlight `%` string formatting >

syntax/python.vim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
" objects
7373
" python_highlight_builtin_objs Highlight builtin objects only
7474
" python_highlight_builtin_funcs Highlight builtin functions only
75+
" python_highlight_self Highlight self and cls attributes
7576
" python_highlight_exceptions Highlight standard exceptions
7677
" python_highlight_string_formatting Highlight % string formatting
7778
" python_highlight_string_format Highlight str.format syntax
@@ -139,6 +140,7 @@ if s:Enabled("g:python_highlight_all")
139140
call s:EnableByDefault("g:python_highlight_builtin_objs")
140141
call s:EnableByDefault("g:python_highlight_builtin_funcs")
141142
endif
143+
call s:EnableByDefault("g:python_highlight_self")
142144
call s:EnableByDefault("g:python_highlight_exceptions")
143145
call s:EnableByDefault("g:python_highlight_string_formatting")
144146
call s:EnableByDefault("g:python_highlight_string_format")
@@ -417,6 +419,14 @@ if s:Enabled("g:python_highlight_builtin_objs")
417419
syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__
418420
endif
419421

422+
"
423+
" Self and cls
424+
"
425+
426+
if s:Enabled("g:python_highlight_self")
427+
syn keyword pythonSelf self cls
428+
endif
429+
420430
"
421431
" Builtin functions
422432
"
@@ -573,6 +583,8 @@ if version >= 508 || !exists("did_python_syn_inits")
573583
HiLink pythonBuiltinObj Structure
574584
HiLink pythonBuiltinFunc Function
575585

586+
HiLink pythonSelf Identifier
587+
576588
HiLink pythonExClass Structure
577589

578590
delcommand HiLink

0 commit comments

Comments
 (0)