Skip to content

Commit

Permalink
Add option variable for class variables
Browse files Browse the repository at this point in the history
  • Loading branch information
monkoose authored and nfnty committed Feb 23, 2017
1 parent 4eee0bd commit 5ffc69c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ let g:python_highlight_all = 1
| `g:python_highlight_indent_errors` | Highlight indentation errors | `0` |
| `g:python_highlight_space_errors` | Highlight trailing spaces | `0` |
| `g:python_highlight_doctests` | Highlight doc-tests | `0` |
| `g:python_highlight_class_vars` | Highlight class variables `self` and `cls` | `0` |
| `g:python_highlight_all` | Enable all highlight options above, except for previously set. | `0` |
| `g:python_highlight_file_headers_as_comments` | Highlight shebang and coding headers as comments | `0` |
| `g:python_slow_sync` | Disable for slow machines | `1` |
Expand Down
3 changes: 3 additions & 0 deletions doc/python-syntax.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ following command to your `~/.config/nvim/init.vim` or `~/.vimrc`: >
`g:python_highlight_doctests` (default `0`)
Highlight doc-tests

`g:python_highlight_class_vars` (default `0`)
Highlight class variables `self` and `cls`

`g:python_highlight_all` (default `0`)
Enable all highlight options above, except for previously set.

Expand Down
16 changes: 8 additions & 8 deletions syntax/python.vim
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,13 @@ if s:Enabled('g:python_highlight_all')
call s:EnableByDefault('g:python_highlight_space_errors')
call s:EnableByDefault('g:python_highlight_doctests')
call s:EnableByDefault('g:python_print_as_function')
call s:EnableByDefault('g:python_highlight_class_vars')
endif

"
" Keywords
"

syn keyword pythonInstanceVariable self
syn keyword pythonClassVariable cls
syn keyword pythonStatement break continue del
syn keyword pythonStatement exec return
syn keyword pythonStatement pass yield
Expand All @@ -68,6 +67,9 @@ syn keyword pythonStatement global assert
syn keyword pythonStatement lambda
syn keyword pythonStatement with
syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite
if s:Enabled('g:python_highlight_class_vars')
syn keyword pythonClassVar self cls
endif
syn keyword pythonRepeat for while
syn keyword pythonConditional if elif else
syn keyword pythonException try except finally
Expand Down Expand Up @@ -102,8 +104,7 @@ syn region FunctionParameters start='(\zs' end='\ze)' display contains=
\ FunctionParameters,
\ OptionalParameters,
\ pythonRepeat,
\ pythonInstanceVariable,
\ pythonClassVariable,
\ pythonClassVar,
\ pythonConditional,
\ pythonComment,
\ pythonOperator,
Expand All @@ -125,7 +126,7 @@ syn region FunctionParameters start='(\zs' end='\ze)' display contains=
\ pythonNone,
\ pythonBuiltinFunc,
\ pythonBoolean nextgroup=pythonRaiseFromStatement display contained
syn match OptionalParameters /\i*\ze=/ display contained
syn match OptionalParameters /\i\+\ze=/ display contained
"
" Decorators (new in Python 2.4)
"
Expand Down Expand Up @@ -486,9 +487,8 @@ if v:version >= 508 || !exists('did_python_syn_inits')
HiLink pythonBuiltinFunc Function

HiLink pythonExClass Structure
HiLink pythonInstanceVariable htmlTagN
HiLink pythonClassVariable htmlTagN
HiLink OptionalParameters htmlTagN
HiLink pythonClassVar Identifier
HiLink OptionalParameters Identifier

delcommand HiLink
endif
Expand Down

0 comments on commit 5ffc69c

Please sign in to comment.