Browse Source

Highlight 'yield from' statement

The 'yield from' statement was introduced in Python 3.3. Reported by
Elizabeth Myers.
Dmitry Vasiliev 5 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,3 +1,8 @@
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 6
 Revision 3.3.5 (2013-08-31):
2 7
 
3 8
     - Highlight 'import', 'from' and 'as' as include statements.

+ 1
- 0
README.rst View File

@@ -133,6 +133,7 @@ List of the contributors in alphabetical order:
133 133
 - Andrea Riciputi
134 134
 - Anton Butanaev
135 135
 - Caleb Adamantine
136
+- Elizabeth Myers
136 137
 - Jeroen Ruigrok van der Werven
137 138
 - John Eikenberry
138 139
 - Marc Weber

+ 9
- 4
syntax/python.vim View File

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

+ 3
- 0
test.py View File

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