Browse Source

Highlight 'yield from' statement

The 'yield from' statement was introduced in Python 3.3. Reported by
Elizabeth Myers.
Dmitry Vasiliev 10 years ago
parent
commit
453269d0f8
4 changed files with 18 additions and 4 deletions
  1. 5
    0
      CHANGES.txt
  2. 1
    0
      README.rst
  3. 9
    4
      syntax/python.vim
  4. 3
    0
      test.py

+ 5
- 0
CHANGES.txt View File

1
+Revision 3.3.6 (2013-11-18):
2
+
3
+    - Highlight 'yield from' statement introduced in Python 3.3. Reported by
4
+      Elizabeth Myers.
5
+
1
 Revision 3.3.5 (2013-08-31):
6
 Revision 3.3.5 (2013-08-31):
2
 
7
 
3
     - Highlight 'import', 'from' and 'as' as include statements.
8
     - Highlight 'import', 'from' and 'as' as include statements.

+ 1
- 0
README.rst View File

133
 - Andrea Riciputi
133
 - Andrea Riciputi
134
 - Anton Butanaev
134
 - Anton Butanaev
135
 - Caleb Adamantine
135
 - Caleb Adamantine
136
+- Elizabeth Myers
136
 - Jeroen Ruigrok van der Werven
137
 - Jeroen Ruigrok van der Werven
137
 - John Eikenberry
138
 - John Eikenberry
138
 - Marc Weber
139
 - Marc Weber

+ 9
- 4
syntax/python.vim View File

2
 " Language:     Python
2
 " Language:     Python
3
 " Maintainer:   Dmitry Vasiliev <dima at hlabs dot org>
3
 " Maintainer:   Dmitry Vasiliev <dima at hlabs dot org>
4
 " URL:          https://github.com/hdima/python-syntax
4
 " URL:          https://github.com/hdima/python-syntax
5
-" Last Change:  2013-08-31
5
+" Last Change:  2013-11-18
6
 " Filenames:    *.py
6
 " Filenames:    *.py
7
-" Version:      3.3.5
7
+" Version:      3.3.6
8
 "
8
 "
9
 " Based on python.vim (from Vim 6.1 distribution)
9
 " Based on python.vim (from Vim 6.1 distribution)
10
 " by Neil Schemenauer <nas at python dot ca>
10
 " by Neil Schemenauer <nas at python dot ca>
25
 "   Andrea Riciputi
25
 "   Andrea Riciputi
26
 "   Anton Butanaev
26
 "   Anton Butanaev
27
 "   Caleb Adamantine
27
 "   Caleb Adamantine
28
+"   Elizabeth Myers
28
 "   Jeroen Ruigrok van der Werven
29
 "   Jeroen Ruigrok van der Werven
29
 "   John Eikenberry
30
 "   John Eikenberry
30
 "   Marc Weber
31
 "   Marc Weber
148
 syn keyword pythonStatement     exec return
149
 syn keyword pythonStatement     exec return
149
 syn keyword pythonStatement     pass raise
150
 syn keyword pythonStatement     pass raise
150
 syn keyword pythonStatement     global assert
151
 syn keyword pythonStatement     global assert
151
-syn keyword pythonStatement     lambda yield
152
+syn keyword pythonStatement     lambda
152
 syn keyword pythonStatement     with
153
 syn keyword pythonStatement     with
153
 syn keyword pythonStatement     def class nextgroup=pythonFunction skipwhite
154
 syn keyword pythonStatement     def class nextgroup=pythonFunction skipwhite
154
 syn keyword pythonRepeat        for while
155
 syn keyword pythonRepeat        for while
155
 syn keyword pythonConditional   if elif else
156
 syn keyword pythonConditional   if elif else
156
-syn keyword pythonImport        import from
157
+syn keyword pythonImport        import
157
 syn keyword pythonException     try except finally
158
 syn keyword pythonException     try except finally
158
 syn keyword pythonOperator      and in is not or
159
 syn keyword pythonOperator      and in is not or
159
 
160
 
161
+syn match pythonStatement   "\<yield\>" display
162
+syn match pythonImport      "\<from\>" display
163
+
160
 if s:Python2Syntax()
164
 if s:Python2Syntax()
161
   if !s:Enabled("g:python_print_as_function")
165
   if !s:Enabled("g:python_print_as_function")
162
     syn keyword pythonStatement  print
166
     syn keyword pythonStatement  print
165
   syn match   pythonFunction    "[a-zA-Z_][a-zA-Z0-9_]*" display contained
169
   syn match   pythonFunction    "[a-zA-Z_][a-zA-Z0-9_]*" display contained
166
 else
170
 else
167
   syn keyword pythonStatement   as nonlocal None
171
   syn keyword pythonStatement   as nonlocal None
172
+  syn match   pythonStatement   "\<yield\s\+from\>" display
168
   syn keyword pythonBoolean     True False
173
   syn keyword pythonBoolean     True False
169
   syn match   pythonFunction    "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
174
   syn match   pythonFunction    "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
170
 endif
175
 endif

+ 3
- 0
test.py View File

10
 
10
 
11
 with break continue del exec return pass print raise global assert lambda yield
11
 with break continue del exec return pass print raise global assert lambda yield
12
 for while if elif else import from as try except finally and in is not or
12
 for while if elif else import from as try except finally and in is not or
13
+
14
+yield from
15
+
13
 def functionname
16
 def functionname
14
 class Classname
17
 class Classname
15
 def функция
18
 def функция