瀏覽代碼

Fix highlighting dotted names in type annotations.

Joongi Kim 7 年之前
父節點
當前提交
4f194e7731
共有 2 個檔案被更改,包括 5 行新增4 行删除
  1. 3
    3
      syntax/python.vim
  2. 2
    1
      test.py

+ 3
- 3
syntax/python.vim 查看文件

@@ -166,7 +166,7 @@ syn keyword pythonImport        import
166 166
 syn match   pythonIdentifier    "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" nextgroup=pythonFuncArgs,pythonTypeAnno display
167 167
 syn keyword pythonException     try except finally
168 168
 syn keyword pythonOperator      and in is not or
169
-syn match pythonLambdaExpr   "\<lambda[^:]*:"he=s+6 display contains=@pythonExpression nextgroup=@pythonExpression
169
+syn match pythonLambdaExpr   "\<lambda[^:]*:"he=s+6 contains=@pythonExpression nextgroup=@pythonExpression
170 170
 
171 171
 syn region pythonDictSetExpr matchgroup=pythonDictSetExpr start='{' end='}' contains=@pythonExpression
172 172
 syn region pythonListSliceExpr matchgroup=pythonListSliceExpr start='\[' end='\]' contains=@pythonExpression
@@ -174,8 +174,8 @@ syn region pythonFuncArgs    matchgroup=pythonFuncArgs    start='(' end=')' cont
174 174
 
175 175
 if !s:Python2Syntax()
176 176
   if s:Enabled("g:python_highlight_type_annotations")
177
-    syn match pythonTypeAnno @:\s*['"]\?\([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\([^[:cntrl:][:punct:][:space:]]\|_\)*['"]\?@hs=s+1 display contained contains=pythonType,pythonString nextgroup=pythonTypeArgs
178
-    syn match pythonTypeAnnoReturn @->\s*['"]\?\([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\([^[:cntrl:][:punct:][:space:]]\|_\)*['"]\?@ display contains=pythonType,pythonString nextgroup=pythonTypeArgs
177
+    syn match pythonTypeAnno @:\s*['"]\?\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\)*['"]\?@hs=s+1 display contained contains=pythonType,pythonString nextgroup=pythonTypeArgs
178
+    syn match pythonTypeAnnoReturn @->\s*['"]\?\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\)*['"]\?@ display contains=pythonType,pythonString nextgroup=pythonTypeArgs
179 179
     syn region pythonTypeArgs matchgroup=pythonTypeArgs start='\[' end='\]' display contained contains=pythonType,pythonString,pythonTypeArgs
180 180
     syn keyword pythonType Any AnyStr Callable ClassVar Tuple Union Optional Type TypeVar None contained
181 181
     syn keyword pythonType AbstractSet MutableSet Mapping MutableMapping Sequence MutableSequence ByteString Deque List contained

+ 2
- 1
test.py 查看文件

@@ -29,7 +29,8 @@ async for
29 29
 # Type annotations
30 30
 
31 31
 def myfunc(a: str, something_other,
32
-           b: Callable[[str, str], int]) -> 'runtime_resolved_type':
32
+           b: Callable[[str, str], int],
33
+           c: mypkg.MyType) -> 'runtime_resolved_type':
33 34
     myval: float
34 35
     mygood: Optional[int, Any] = b('wow', 'oops')
35 36
     myarr: Sequence[int] = origarr[aa:bb] + (lambda: x)()