Skip to content

Commit 18fe49b

Browse files
committed
allow to disable async/await hightlighting
1 parent 0c3b469 commit 18fe49b

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

doc/pymode.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,10 @@ Highlight "print" as a function *'g:pymode_syntax_print_as_function'*
628628
>
629629
let g:pymode_syntax_print_as_function = 0
630630
631+
Highlight "async/await" keywords *'g:pymode_syntax_highlight_async_await'*
632+
>
633+
let g:pymode_syntax_highlight_async_await = g:pymode_syntax_all
634+
631635
Highlight '=' operator *'g:pymode_syntax_highlight_equal_operator'*
632636
>
633637
let g:pymode_syntax_highlight_equal_operator = g:pymode_syntax_all

syntax/python.vim

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ call pymode#default('g:pymode_syntax_all', 1)
1616

1717
" Highlight 'print' as function
1818
call pymode#default("g:pymode_syntax_print_as_function", 0)
19+
"
20+
" Highlight 'async/await' keywords
21+
call pymode#default("g:pymode_syntax_highlight_async_await", g:pymode_syntax_all)
1922

2023
" Highlight '=' operator
2124
call pymode#default('g:pymode_syntax_highlight_equal_operator', g:pymode_syntax_all)
@@ -75,12 +78,8 @@ endif
7578
syn keyword pythonStatement yield
7679
syn keyword pythonLambdaExpr lambda
7780
syn keyword pythonStatement with as
78-
syn keyword pythonStatement async await
7981

8082
syn keyword pythonStatement def nextgroup=pythonFunction skipwhite
81-
syn match pythonStatement "\<async\s\+def\>" nextgroup=pythonFunction skipwhite
82-
syn match pythonStatement "\<async\s\+with\>" display
83-
syn match pythonStatement "\<async\s\+for\>" nextgroup=pythonRepeat skipwhite
8483
syn match pythonFunction "\%(\%(def\s\|@\)\s*\)\@<=\h\%(\w\|\.\)*" contained nextgroup=pythonVars
8584
syn region pythonVars start="(" skip=+\(".*"\|'.*'\)+ end=")" contained contains=pythonParameters transparent keepend
8685
syn match pythonParameters "[^,]*" contained contains=pythonParam skipwhite
@@ -105,6 +104,13 @@ endif
105104
syn keyword pythonStatement print
106105
endif
107106

107+
if g:pymode_syntax_highlight_async_await
108+
syn keyword pythonStatement async await
109+
syn match pythonStatement "\<async\s\+def\>" nextgroup=pythonFunction skipwhite
110+
syn match pythonStatement "\<async\s\+with\>" display
111+
syn match pythonStatement "\<async\s\+for\>" nextgroup=pythonRepeat skipwhite
112+
endif
113+
108114
if g:pymode_syntax_highlight_equal_operator
109115
syn match pythonExtraOperator "\%(=\)"
110116
endif

t/syntax.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ describe 'pymode-syntax'
1313
Expect g:pymode_syntax == 1
1414
Expect g:pymode_syntax_all == 1
1515
Expect g:pymode_syntax_print_as_function == 0
16+
Expect g:pymode_syntax_highlight_async_await == 1
1617
Expect g:pymode_syntax_highlight_equal_operator == 1
1718
Expect g:pymode_syntax_highlight_stars_operator == 1
1819
Expect g:pymode_syntax_highlight_self == 1

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy