mirror of
https://github.com/vim-python/python-syntax.git
synced 2025-12-08 05:34:46 +08:00
@@ -67,6 +67,7 @@ let g:python_highlight_all = 1
|
||||
| `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_operators` | Highlight all operators | `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` |
|
||||
|
||||
@@ -86,6 +86,9 @@ following command to your `~/.config/nvim/init.vim` or `~/.vimrc`: >
|
||||
`g:python_highlight_class_vars` (default `0`)
|
||||
Highlight class variables `self` and `cls`
|
||||
|
||||
`g:python_highlight_operators` (default `0`)
|
||||
Highlight all operators
|
||||
|
||||
`g:python_highlight_all` (default `0`)
|
||||
Enable all highlight options above, except for previously set.
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ if s:Enabled('g:python_highlight_all')
|
||||
call s:EnableByDefault('g:python_highlight_doctests')
|
||||
call s:EnableByDefault('g:python_print_as_function')
|
||||
call s:EnableByDefault('g:python_highlight_class_vars')
|
||||
call s:EnableByDefault('g:python_highlight_operators')
|
||||
endif
|
||||
|
||||
"
|
||||
@@ -73,7 +74,6 @@ endif
|
||||
syn keyword pythonRepeat for while
|
||||
syn keyword pythonConditional if elif else
|
||||
syn keyword pythonException try except finally
|
||||
syn keyword pythonOperator and in is not or
|
||||
" The standard pyrex.vim unconditionally removes the pythonInclude group, so
|
||||
" we provide a dummy group here to avoid crashing pyrex.vim.
|
||||
syn keyword pythonInclude import
|
||||
@@ -83,7 +83,6 @@ syn match pythonRaiseFromStatement '\<from\>'
|
||||
syn match pythonImport '^\s*\zsfrom\>'
|
||||
|
||||
|
||||
|
||||
if s:Python2Syntax()
|
||||
if !s:Enabled('g:python_print_as_function')
|
||||
syn keyword pythonStatement print
|
||||
@@ -100,6 +99,16 @@ else
|
||||
syn cluster pythonExpression contains=pythonStatement,pythonRepeat,pythonConditional,pythonOperator,pythonNumber,pythonHexNumber,pythonOctNumber,pythonBinNumber,pythonFloat,pythonString,pythonBytes,pythonBoolean,pythonBuiltinObj,pythonBuiltinFunc
|
||||
endif
|
||||
|
||||
|
||||
"
|
||||
" Operators
|
||||
"
|
||||
syn keyword pythonOperator and in is not or
|
||||
if s:Enabled('g:python_highlight_operators')
|
||||
syn match pythonOperator '\V=\|-\|+\|*\|@\|/\|%\|&\||\|^\|~\|<\|>\|!='
|
||||
endif
|
||||
syn match pythonError '[$?]\|\([-+@%&|^~]\)\1\{1,}\|\([=*/<>]\)\2\{2,}\|\([-=+*@/%&|^~<>]\)\3\@![-+*@/%&|^~<>]\|[<!>]\+=\{2,}\|[<!>]\{2,}=\+' display
|
||||
|
||||
"
|
||||
" Decorators (new in Python 2.4)
|
||||
"
|
||||
@@ -127,10 +136,7 @@ syn keyword pythonTodo TODO FIXME XXX contained
|
||||
" Errors
|
||||
"
|
||||
|
||||
syn match pythonError '\<\d\+\D\+\>' display
|
||||
syn match pythonError '[$?]' display
|
||||
syn match pythonError '[&|]\{2,}' display
|
||||
syn match pythonError '[=]\{3,}' display
|
||||
syn match pythonError '\<\d\+[^0-9[:space:]]\+\>' display
|
||||
|
||||
" Mixing spaces and tabs also may be used for pretty formatting multiline
|
||||
" statements
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
# Keywords.
|
||||
|
||||
with break continue del exec return pass print raise global assert lambda yield
|
||||
for while if elif else import as try except finally and in is not or
|
||||
for while if elif else import as try except finally
|
||||
|
||||
from test import var as name
|
||||
|
||||
@@ -66,6 +66,23 @@ RuntimeWarning FutureWarning ImportWarning UnicodeWarning
|
||||
@ декоратор
|
||||
@ декоратор.décorateur
|
||||
|
||||
# Operators
|
||||
|
||||
and or in is not
|
||||
=
|
||||
- + * ** @ / // %
|
||||
& | ^ ~ << >>
|
||||
< <= == != >= >
|
||||
|
||||
# Erroneous operators
|
||||
|
||||
$ ?
|
||||
===
|
||||
-- ++ *** @@ /// %%
|
||||
&& || ^^ ~~ <<< >>>
|
||||
<== <<= !== !!= >== >>=
|
||||
%- +- -+
|
||||
|
||||
# Numbers
|
||||
|
||||
0 1 2 9 10 0x1f .3 12.34 0j 124j 34.2E-3 0b10 0o77 1023434 0x0
|
||||
@@ -141,11 +158,10 @@ f"hello {expr:.2f} yes {(lambda: 0b1)():#03x} lol {var!r}"
|
||||
Test
|
||||
'''
|
||||
|
||||
# Erroneous symbols or bad variable names.
|
||||
# Erroneous variable names
|
||||
|
||||
$ ? 6xav
|
||||
6xav
|
||||
|
||||
&& || ===
|
||||
|
||||
# Indentation errors.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user