mirror of
https://github.com/gryf/python-syntax.git
synced 2025-12-19 12:28:13 +01:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
453269d0f8 | ||
|
|
efe8499cfb | ||
|
|
69f8e12a46 | ||
|
|
21a2e84df6 | ||
|
|
9ccbd6196b | ||
|
|
6f6f10ff54 | ||
|
|
a0d21acc1c | ||
|
|
ebbdd093b7 | ||
|
|
fc6a66bf80 | ||
|
|
e344f212b6 | ||
|
|
91eaa32bea |
30
CHANGES.txt
30
CHANGES.txt
@@ -1,3 +1,33 @@
|
|||||||
|
Revision 3.3.6 (2013-11-18):
|
||||||
|
|
||||||
|
- Highlight 'yield from' statement introduced in Python 3.3. Reported by
|
||||||
|
Elizabeth Myers.
|
||||||
|
|
||||||
|
Revision 3.3.5 (2013-08-31):
|
||||||
|
|
||||||
|
- Highlight 'import', 'from' and 'as' as include statements.
|
||||||
|
Patch by pydave at GitHub.
|
||||||
|
- Added new option 'python_highlight_file_headers_as_comments' (disabled by
|
||||||
|
default) to highlight shebang and coding file headers as comments.
|
||||||
|
Proposed by pydave at GitHub.
|
||||||
|
|
||||||
|
Revision 3.3.4 (2013-08-11):
|
||||||
|
|
||||||
|
- Highlight True and False as booleans. Patch by Yuri Habrusiev.
|
||||||
|
|
||||||
|
Revision 3.3.3 (2013-06-02):
|
||||||
|
|
||||||
|
- More lightweight syntax reloading. Patch by Will Gray.
|
||||||
|
|
||||||
|
Revision 3.3.2 (2013-06-01):
|
||||||
|
|
||||||
|
- Fixed behaviour of b:python_version_2 variable. Reported by Will Gray.
|
||||||
|
|
||||||
|
Revision 3.3.1 (2013-05-12):
|
||||||
|
|
||||||
|
- The script was moved to its own repository at
|
||||||
|
https://github.com/hdima/python-syntax
|
||||||
|
|
||||||
Revision 3.3.0 (2013-03-10):
|
Revision 3.3.0 (2013-03-10):
|
||||||
|
|
||||||
- Merge Python 2 and Python 3 script versions into the single python.vim
|
- Merge Python 2 and Python 3 script versions into the single python.vim
|
||||||
|
|||||||
16
README.rst
16
README.rst
@@ -117,6 +117,8 @@ Options used by the script
|
|||||||
Highlight doc-tests
|
Highlight doc-tests
|
||||||
``python_print_as_function``
|
``python_print_as_function``
|
||||||
Highlight ``print`` statement as function for Python 2
|
Highlight ``print`` statement as function for Python 2
|
||||||
|
``python_highlight_file_headers_as_comments``
|
||||||
|
Highlight shebang and coding headers as comments
|
||||||
``python_highlight_all``
|
``python_highlight_all``
|
||||||
Enable all the options above. *NOTE: This option don't override any
|
Enable all the options above. *NOTE: This option don't override any
|
||||||
previously set options*
|
previously set options*
|
||||||
@@ -126,10 +128,16 @@ Options used by the script
|
|||||||
Contributors
|
Contributors
|
||||||
------------
|
------------
|
||||||
|
|
||||||
- Jeroen Ruigrok van der Werven
|
List of the contributors in alphabetical order:
|
||||||
- Pedro Algarvio
|
|
||||||
- John Eikenberry
|
|
||||||
- Caleb Adamantine
|
|
||||||
- Andrea Riciputi
|
- Andrea Riciputi
|
||||||
- Anton Butanaev
|
- Anton Butanaev
|
||||||
|
- Caleb Adamantine
|
||||||
|
- Elizabeth Myers
|
||||||
|
- Jeroen Ruigrok van der Werven
|
||||||
|
- John Eikenberry
|
||||||
- Marc Weber
|
- Marc Weber
|
||||||
|
- Pedro Algarvio
|
||||||
|
- pydave at GitHub
|
||||||
|
- Will Gray
|
||||||
|
- Yuri Habrusiev
|
||||||
|
|||||||
3
TODO.txt
3
TODO.txt
@@ -1,6 +1,9 @@
|
|||||||
Now
|
Now
|
||||||
===
|
===
|
||||||
|
|
||||||
|
- It seems python.vim doesn't highlight special characters inside strings by
|
||||||
|
default but only when it reloaded?
|
||||||
|
|
||||||
- Add support for slice syntax:
|
- Add support for slice syntax:
|
||||||
http://img155.imageshack.us/img155/7767/screenshotgs.png
|
http://img155.imageshack.us/img155/7767/screenshotgs.png
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
" Language: Python
|
" Language: Python
|
||||||
" Maintainer: Dmitry Vasiliev <dima at hlabs dot org>
|
" Maintainer: Dmitry Vasiliev <dima at hlabs dot org>
|
||||||
" URL: https://github.com/hdima/python-syntax
|
" URL: https://github.com/hdima/python-syntax
|
||||||
" Last Change: 2013-05-12
|
" Last Change: 2013-11-18
|
||||||
" Filenames: *.py
|
" Filenames: *.py
|
||||||
" Version: 3.3.1
|
" Version: 3.3.6
|
||||||
"
|
"
|
||||||
" Based on python.vim (from Vim 6.1 distribution)
|
" Based on python.vim (from Vim 6.1 distribution)
|
||||||
" by Neil Schemenauer <nas at python dot ca>
|
" by Neil Schemenauer <nas at python dot ca>
|
||||||
@@ -20,13 +20,19 @@
|
|||||||
" Contributors
|
" Contributors
|
||||||
" ============
|
" ============
|
||||||
"
|
"
|
||||||
" Jeroen Ruigrok van der Werven
|
" List of the contributors in alphabetical order:
|
||||||
" Pedro Algarvio
|
"
|
||||||
" John Eikenberry
|
|
||||||
" Caleb Adamantine
|
|
||||||
" Andrea Riciputi
|
" Andrea Riciputi
|
||||||
" Anton Butanaev
|
" Anton Butanaev
|
||||||
|
" Caleb Adamantine
|
||||||
|
" Elizabeth Myers
|
||||||
|
" Jeroen Ruigrok van der Werven
|
||||||
|
" John Eikenberry
|
||||||
" Marc Weber
|
" Marc Weber
|
||||||
|
" Pedro Algarvio
|
||||||
|
" pydave at GitHub
|
||||||
|
" Will Gray
|
||||||
|
" Yuri Habrusiev
|
||||||
"
|
"
|
||||||
" Options
|
" Options
|
||||||
" =======
|
" =======
|
||||||
@@ -68,6 +74,9 @@
|
|||||||
" python_highlight_doctests Highlight doc-tests
|
" python_highlight_doctests Highlight doc-tests
|
||||||
" python_print_as_function Highlight 'print' statement as
|
" python_print_as_function Highlight 'print' statement as
|
||||||
" function for Python 2
|
" function for Python 2
|
||||||
|
" python_highlight_file_headers_as_comments
|
||||||
|
" Highlight shebang and coding
|
||||||
|
" headers as comments
|
||||||
"
|
"
|
||||||
" python_highlight_all Enable all the options above
|
" python_highlight_all Enable all the options above
|
||||||
" NOTE: This option don't override
|
" NOTE: This option don't override
|
||||||
@@ -87,8 +96,8 @@ endif
|
|||||||
"
|
"
|
||||||
" Commands
|
" Commands
|
||||||
"
|
"
|
||||||
command! -buffer Python2Syntax let b:python_version_2 = 1 | if exists("g:syntax_on") | syn off | endif | syn enable
|
command! -buffer Python2Syntax let b:python_version_2 = 1 | let &syntax=&syntax
|
||||||
command! -buffer Python3Syntax let b:python_version_2 = 0 | if exists("g:syntax_on") | syn off | endif | syn enable
|
command! -buffer Python3Syntax let b:python_version_2 = 0 | let &syntax=&syntax
|
||||||
|
|
||||||
" Enable option if it's not defined
|
" Enable option if it's not defined
|
||||||
function! s:EnableByDefault(name)
|
function! s:EnableByDefault(name)
|
||||||
@@ -99,12 +108,15 @@ endfunction
|
|||||||
|
|
||||||
" Check if option is enabled
|
" Check if option is enabled
|
||||||
function! s:Enabled(name)
|
function! s:Enabled(name)
|
||||||
return exists(a:name) && {a:name} != 0
|
return exists(a:name) && {a:name}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Is it Python 2 syntax?
|
" Is it Python 2 syntax?
|
||||||
function! s:Python2Syntax()
|
function! s:Python2Syntax()
|
||||||
return s:Enabled("b:python_version_2") || s:Enabled("g:python_version_2")
|
if exists("b:python_version_2")
|
||||||
|
return b:python_version_2
|
||||||
|
endif
|
||||||
|
return s:Enabled("g:python_version_2")
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"
|
"
|
||||||
@@ -137,23 +149,28 @@ syn keyword pythonStatement break continue del
|
|||||||
syn keyword pythonStatement exec return
|
syn keyword pythonStatement exec return
|
||||||
syn keyword pythonStatement pass raise
|
syn keyword pythonStatement pass raise
|
||||||
syn keyword pythonStatement global assert
|
syn keyword pythonStatement global assert
|
||||||
syn keyword pythonStatement lambda yield
|
syn keyword pythonStatement lambda
|
||||||
syn keyword pythonStatement with
|
syn keyword pythonStatement with
|
||||||
syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite
|
syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite
|
||||||
syn keyword pythonRepeat for while
|
syn keyword pythonRepeat for while
|
||||||
syn keyword pythonConditional if elif else
|
syn keyword pythonConditional if elif else
|
||||||
syn keyword pythonPreCondit import from
|
syn keyword pythonImport import
|
||||||
syn keyword pythonException try except finally
|
syn keyword pythonException try except finally
|
||||||
syn keyword pythonOperator and in is not or
|
syn keyword pythonOperator and in is not or
|
||||||
|
|
||||||
|
syn match pythonStatement "\<yield\>" display
|
||||||
|
syn match pythonImport "\<from\>" display
|
||||||
|
|
||||||
if s:Python2Syntax()
|
if s:Python2Syntax()
|
||||||
if !s:Enabled("g:python_print_as_function")
|
if !s:Enabled("g:python_print_as_function")
|
||||||
syn keyword pythonStatement print
|
syn keyword pythonStatement print
|
||||||
endif
|
endif
|
||||||
syn keyword pythonPreCondit as
|
syn keyword pythonImport as
|
||||||
syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" display contained
|
syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" display contained
|
||||||
else
|
else
|
||||||
syn keyword pythonStatement as nonlocal False None True
|
syn keyword pythonStatement as nonlocal None
|
||||||
|
syn match pythonStatement "\<yield\s\+from\>" display
|
||||||
|
syn keyword pythonBoolean True False
|
||||||
syn match pythonFunction "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
|
syn match pythonFunction "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -170,8 +187,10 @@ syn match pythonDot "\." display containedin=pythonDottedName
|
|||||||
"
|
"
|
||||||
|
|
||||||
syn match pythonComment "#.*$" display contains=pythonTodo,@Spell
|
syn match pythonComment "#.*$" display contains=pythonTodo,@Spell
|
||||||
syn match pythonRun "\%^#!.*$"
|
if !s:Enabled("g:python_highlight_file_headers_as_comments")
|
||||||
syn match pythonCoding "\%^.*\%(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$"
|
syn match pythonRun "\%^#!.*$"
|
||||||
|
syn match pythonCoding "\%^.*\%(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$"
|
||||||
|
endif
|
||||||
syn keyword pythonTodo TODO FIXME XXX contained
|
syn keyword pythonTodo TODO FIXME XXX contained
|
||||||
|
|
||||||
"
|
"
|
||||||
@@ -364,7 +383,8 @@ syn match pythonFloat "\<\d\+\.\d*\%([eE][+-]\=\d\+\)\=[jJ]\=" display
|
|||||||
|
|
||||||
if s:Enabled("g:python_highlight_builtin_objs")
|
if s:Enabled("g:python_highlight_builtin_objs")
|
||||||
if s:Python2Syntax()
|
if s:Python2Syntax()
|
||||||
syn keyword pythonBuiltinObj True False None
|
syn keyword pythonBuiltinObj None
|
||||||
|
syn keyword pythonBoolean True False
|
||||||
endif
|
endif
|
||||||
syn keyword pythonBuiltinObj Ellipsis NotImplemented
|
syn keyword pythonBuiltinObj Ellipsis NotImplemented
|
||||||
syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__
|
syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__
|
||||||
@@ -460,7 +480,7 @@ if version >= 508 || !exists("did_python_syn_inits")
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
HiLink pythonStatement Statement
|
HiLink pythonStatement Statement
|
||||||
HiLink pythonPreCondit Statement
|
HiLink pythonImport Include
|
||||||
HiLink pythonFunction Function
|
HiLink pythonFunction Function
|
||||||
HiLink pythonConditional Conditional
|
HiLink pythonConditional Conditional
|
||||||
HiLink pythonRepeat Repeat
|
HiLink pythonRepeat Repeat
|
||||||
@@ -472,8 +492,10 @@ if version >= 508 || !exists("did_python_syn_inits")
|
|||||||
HiLink pythonDot Normal
|
HiLink pythonDot Normal
|
||||||
|
|
||||||
HiLink pythonComment Comment
|
HiLink pythonComment Comment
|
||||||
HiLink pythonCoding Special
|
if !s:Enabled("g:python_highlight_file_headers_as_comments")
|
||||||
HiLink pythonRun Special
|
HiLink pythonCoding Special
|
||||||
|
HiLink pythonRun Special
|
||||||
|
endif
|
||||||
HiLink pythonTodo Todo
|
HiLink pythonTodo Todo
|
||||||
|
|
||||||
HiLink pythonError Error
|
HiLink pythonError Error
|
||||||
@@ -517,6 +539,8 @@ if version >= 508 || !exists("did_python_syn_inits")
|
|||||||
HiLink pythonHexError Error
|
HiLink pythonHexError Error
|
||||||
HiLink pythonBinError Error
|
HiLink pythonBinError Error
|
||||||
|
|
||||||
|
HiLink pythonBoolean Boolean
|
||||||
|
|
||||||
HiLink pythonBuiltinObj Structure
|
HiLink pythonBuiltinObj Structure
|
||||||
HiLink pythonBuiltinFunc Function
|
HiLink pythonBuiltinFunc Function
|
||||||
|
|
||||||
|
|||||||
3
test.py
3
test.py
@@ -10,6 +10,9 @@
|
|||||||
|
|
||||||
with break continue del exec return pass print raise global assert lambda yield
|
with break continue del exec return pass print raise global assert lambda yield
|
||||||
for while if elif else import from as try except finally and in is not or
|
for while if elif else import from as try except finally and in is not or
|
||||||
|
|
||||||
|
yield from
|
||||||
|
|
||||||
def functionname
|
def functionname
|
||||||
class Classname
|
class Classname
|
||||||
def функция
|
def функция
|
||||||
|
|||||||
Reference in New Issue
Block a user