Skip to content

Commit 8db44e7

Browse files
author
Michael Doronin
committed
now from from import in highlighted as import and as keyword in `raise
from`
1 parent 752a19f commit 8db44e7

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

syntax/python.vim

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ syn keyword pythonInstanceVariable self
154154
syn keyword pythonClassVaraible cls
155155
syn keyword pythonStatement break continue del
156156
syn keyword pythonStatement exec return
157-
syn keyword pythonStatement pass raise
157+
syn keyword pythonStatement pass
158+
syn keyword pythonStatement raise nextgroup=pythonIdentifier skipwhite
158159
syn keyword pythonStatement global assert
159160
syn keyword pythonStatement lambda
160161
syn keyword pythonStatement with
@@ -163,14 +164,16 @@ syn keyword pythonRepeat for while
163164
syn keyword pythonConditional if elif else
164165
" The standard pyrex.vim unconditionally removes the pythonInclude group, so
165166
" we provide a dummy group here to avoid crashing pyrex.vim.
166-
syn keyword pythonInclude import
167-
syn keyword pythonImport import
168-
syn keyword pythonImport from
169167
syn keyword pythonException try except finally
170168
syn keyword pythonOperator and in is not or
171169
syn match pythonStatement "\s*\([.,]\)\@<!\<yield\>"
170+
syn keyword pythonInclude import
171+
syn keyword pythonImport import
172+
syn match pythonIdentifier "\v[a-zA-Z_][a-zA-Z0-9_]*" nextgroup=FunctionParameters
173+
syn match pythonRaiseFromStatement "from\>"
174+
syn match pythonImport "\v^\s*\zsfrom\ze\s*[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*)*\s*import"
175+
172176

173-
syn match pythonIdentifier "[a-zA-Z_][a-zA-Z0-9_]*" nextgroup=FunctionParameters
174177

175178
if s:Python2Syntax()
176179
if !s:Enabled("g:python_print_as_function")
@@ -180,7 +183,7 @@ if s:Python2Syntax()
180183
syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" nextgroup=FunctionParameters display contained
181184
else
182185
syn keyword pythonStatement as nonlocal
183-
syn match pythonStatement "\v\s*<yield\s+from>"
186+
syn match pythonStatement "\v\s*<yield\s+from>"
184187
syn match pythonStatement "\v(\.)@<!<await>"
185188
syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" nextgroup=FunctionParameters display contained
186189
syn match pythonStatement "\<async\s\+def\>" nextgroup=pythonFunction skipwhite
@@ -213,8 +216,7 @@ syn region FunctionParameters start='(' end=')' display contains=
213216
\ pythonBytes,
214217
\ pythonBuiltinObj,
215218
\ pythonBuiltinFunc,
216-
\ pythonBoolean
217-
\ nextgroup=OptionalParameters display contained
219+
\ pythonBoolean nextgroup=pythonRaiseFromStatement display contained
218220
syn match OptionalParameters /\i*\ze=/ display contained
219221
"
220222
" Decorators (new in Python 2.4)
@@ -526,6 +528,7 @@ if version >= 508 || !exists("did_python_syn_inits")
526528
endif
527529

528530
HiLink pythonStatement Statement
531+
HiLink pythonRaiseFromStatement Statement
529532
HiLink pythonImport Include
530533
HiLink pythonFunction Function
531534
HiLink pythonConditional Conditional

0 commit comments

Comments
 (0)