mirror of
https://github.com/gryf/python-syntax.git
synced 2025-12-19 20:38:07 +01:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10d2c07687 | ||
|
|
d948f835b4 | ||
|
|
4d925a99dd | ||
|
|
44f1855902 | ||
|
|
716ded1d56 | ||
|
|
878e75cf90 | ||
|
|
9209dd0c02 | ||
|
|
ea215a9085 | ||
|
|
9dc6765ad1 | ||
|
|
453269d0f8 | ||
|
|
efe8499cfb | ||
|
|
69f8e12a46 | ||
|
|
21a2e84df6 | ||
|
|
9ccbd6196b |
23
CHANGES.txt
23
CHANGES.txt
@@ -1,3 +1,26 @@
|
|||||||
|
Revision 3.5.0 (2015-06-10):
|
||||||
|
|
||||||
|
- Add support for 'async ...' and 'await' keywords introduced in
|
||||||
|
Python 3.5. Patch by Ihor Gorobets
|
||||||
|
|
||||||
|
Revision 3.3.7 (2014-12-27):
|
||||||
|
|
||||||
|
- Add support for Python 3 non-ASCII decorator names.
|
||||||
|
Patch by Victor Salgado
|
||||||
|
|
||||||
|
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 David Briscoe
|
||||||
|
- Added new option 'python_highlight_file_headers_as_comments' (disabled by
|
||||||
|
default) to highlight shebang and coding file headers as comments.
|
||||||
|
Proposed by David Briscoe.
|
||||||
|
|
||||||
Revision 3.3.4 (2013-08-11):
|
Revision 3.3.4 (2013-08-11):
|
||||||
|
|
||||||
- Highlight True and False as booleans. Patch by Yuri Habrusiev.
|
- Highlight True and False as booleans. Patch by Yuri Habrusiev.
|
||||||
|
|||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2002-2014 Dmitry Vasiliev <dima@hlabs.org>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
22
README.rst
22
README.rst
@@ -81,7 +81,7 @@ Option and commands to select Python version
|
|||||||
|
|
||||||
``python_version_2``
|
``python_version_2``
|
||||||
Enable highlighting for Python 2 (Python 3 highlighting is enabled by
|
Enable highlighting for Python 2 (Python 3 highlighting is enabled by
|
||||||
default). Can also be set as a local to buffer ``b:python_version_2``
|
default). Also can be set as a local to buffer ``b:python_version_2``
|
||||||
variable.
|
variable.
|
||||||
|
|
||||||
The following local to buffer commands can be used to switch between two
|
The following local to buffer commands can be used to switch between two
|
||||||
@@ -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*
|
||||||
@@ -128,12 +130,16 @@ Contributors
|
|||||||
|
|
||||||
List of the contributors in alphabetical order:
|
List of the contributors in alphabetical order:
|
||||||
|
|
||||||
- Andrea Riciputi
|
- `Andrea Riciputi <https://github.com/mrrech>`_
|
||||||
- Anton Butanaev
|
- Anton Butanaev
|
||||||
- Caleb Adamantine
|
- Caleb Adamantine
|
||||||
- Jeroen Ruigrok van der Werven
|
- `David Briscoe <https://github.com/idbrii>`_
|
||||||
- John Eikenberry
|
- `Elizabeth Myers <https://github.com/Elizafox>`_
|
||||||
- Marc Weber
|
- `Ihor Gorobets <https://github.com/iho>`_
|
||||||
- Pedro Algarvio
|
- `Jeroen Ruigrok van der Werven <https://github.com/ashemedai>`_
|
||||||
- Will Gray
|
- `John Eikenberry <https://github.com/eikenb>`_
|
||||||
- Yuri Habrusiev
|
- `Marc Weber <https://github.com/MarcWeber>`_
|
||||||
|
- `Pedro Algarvio <https://github.com/s0undt3ch>`_
|
||||||
|
- `Victor Salgado <https://github.com/mcsalgado>`_
|
||||||
|
- `Will Gray <https://github.com/graywh>`_
|
||||||
|
- `Yuri Habrusiev <https://github.com/yuriihabrusiev>`_
|
||||||
|
|||||||
4
TODO.txt
4
TODO.txt
@@ -1,6 +1,10 @@
|
|||||||
Now
|
Now
|
||||||
===
|
===
|
||||||
|
|
||||||
|
- It seems python.vim doesn't highlight special characters inside strings by
|
||||||
|
default but only when reloaded? Or maybe only when set to Python 2
|
||||||
|
by default?
|
||||||
|
|
||||||
- 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
|
||||||
|
|
||||||
|
|||||||
65
syntax.txt
Normal file
65
syntax.txt
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
PYTHON *python.vim* *ft-python-syntax*
|
||||||
|
|
||||||
|
There are two commands to enable or disable an option for python.vim
|
||||||
|
|
||||||
|
Enable option: >
|
||||||
|
:let option_name = 1
|
||||||
|
<
|
||||||
|
Disable option: >
|
||||||
|
:let option_name = 0
|
||||||
|
<
|
||||||
|
For example to enable all syntax highlighting features you can place the
|
||||||
|
following command in your `~/.vimrc` script: >
|
||||||
|
|
||||||
|
let python_highlight_all = 1
|
||||||
|
<
|
||||||
|
Option and commands to select Python version: >
|
||||||
|
|
||||||
|
:let python_version_2 = 1
|
||||||
|
<
|
||||||
|
Enable highlighting for Python 2 (Python 3 highlighting is enabled by
|
||||||
|
default). Also can be set as a local to buffer `b:python_version_2`
|
||||||
|
variable.
|
||||||
|
|
||||||
|
The following local to buffer commands can be used to switch between two
|
||||||
|
highlighting modes:
|
||||||
|
|
||||||
|
Switch to Python 2 highlighting mode >
|
||||||
|
:Python2Syntax
|
||||||
|
<
|
||||||
|
Switch to Python 3 highlighting mode >
|
||||||
|
:Python3Syntax
|
||||||
|
<
|
||||||
|
Options used by the script
|
||||||
|
|
||||||
|
Highlight builtin functions and objects >
|
||||||
|
:let python_highlight_builtins = 1
|
||||||
|
< Highlight builtin objects only >
|
||||||
|
:let python_highlight_builtin_objs = 1
|
||||||
|
< Highlight builtin functions only >
|
||||||
|
:let python_highlight_builtin_funcs = 1
|
||||||
|
< Highlight standard exceptions >
|
||||||
|
:let python_highlight_exceptions = 1
|
||||||
|
< Highlight `%` string formatting >
|
||||||
|
:let python_highlight_string_formatting = 1
|
||||||
|
< Highlight syntax of `str.format` syntax >
|
||||||
|
:let python_highlight_string_format = 1
|
||||||
|
< Highlight syntax of `string.Template` >
|
||||||
|
:let python_highlight_string_templates = 1
|
||||||
|
< Highlight indentation errors >
|
||||||
|
:let python_highlight_indent_errors = 1
|
||||||
|
< Highlight trailing spaces >
|
||||||
|
:let python_highlight_space_errors = 1
|
||||||
|
< Highlight doc-tests >
|
||||||
|
:let python_highlight_doctests = 1
|
||||||
|
< Highlight `print` statement as function for Python 2 >
|
||||||
|
:let python_print_as_function = 1
|
||||||
|
< Highlight shebang and coding headers as comments >
|
||||||
|
:let python_highlight_file_headers_as_comments = 1
|
||||||
|
< Enable all the options above. NOTE: This option don't override any
|
||||||
|
previously set options >
|
||||||
|
:let python_highlight_all = 1
|
||||||
|
< Can be set to 0 for slow machines >
|
||||||
|
:let python_slow_sync = 1
|
||||||
|
<
|
||||||
|
vim:tw=78:sw=4:ts=8:ft=help:norl:
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
" Vim syntax file
|
" Vim syntax file
|
||||||
" Language: Python
|
" Language: Python
|
||||||
" Maintainer: Dmitry Vasiliev <dima at hlabs dot org>
|
" Current Maintainer: Dmitry Vasiliev <dima at hlabs dot org>
|
||||||
|
" Previous Maintainer: Neil Schemenauer <nas at python dot ca>
|
||||||
" URL: https://github.com/hdima/python-syntax
|
" URL: https://github.com/hdima/python-syntax
|
||||||
" Last Change: 2013-08-11
|
" Last Change: 2015-06-10
|
||||||
" Filenames: *.py
|
" Filenames: *.py
|
||||||
" Version: 3.3.4
|
" Version: 3.5.0
|
||||||
"
|
"
|
||||||
" 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>
|
||||||
@@ -25,10 +26,14 @@
|
|||||||
" Andrea Riciputi
|
" Andrea Riciputi
|
||||||
" Anton Butanaev
|
" Anton Butanaev
|
||||||
" Caleb Adamantine
|
" Caleb Adamantine
|
||||||
|
" David Briscoe
|
||||||
|
" Elizabeth Myers
|
||||||
|
" Ihor Gorobets
|
||||||
" Jeroen Ruigrok van der Werven
|
" Jeroen Ruigrok van der Werven
|
||||||
" John Eikenberry
|
" John Eikenberry
|
||||||
" Marc Weber
|
" Marc Weber
|
||||||
" Pedro Algarvio
|
" Pedro Algarvio
|
||||||
|
" Victor Salgado
|
||||||
" Will Gray
|
" Will Gray
|
||||||
" Yuri Habrusiev
|
" Yuri Habrusiev
|
||||||
"
|
"
|
||||||
@@ -72,6 +77,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
|
||||||
@@ -144,25 +152,34 @@ 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 None
|
syn keyword pythonStatement as nonlocal None
|
||||||
|
syn match pythonStatement "\<yield\s\+from\>" display
|
||||||
syn keyword pythonBoolean True False
|
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
|
||||||
|
syn keyword pythonStatement await
|
||||||
|
syn match pythonStatement "\<async\s\+def\>" display
|
||||||
|
syn match pythonStatement "\<async\s\+with\>" display
|
||||||
|
syn match pythonStatement "\<async\s\+for\>" display
|
||||||
|
syn match pythonStatement "\<async\s\+with\>" display
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"
|
"
|
||||||
@@ -170,7 +187,11 @@ endif
|
|||||||
"
|
"
|
||||||
|
|
||||||
syn match pythonDecorator "@" display nextgroup=pythonDottedName skipwhite
|
syn match pythonDecorator "@" display nextgroup=pythonDottedName skipwhite
|
||||||
|
if s:Python2Syntax()
|
||||||
syn match pythonDottedName "[a-zA-Z_][a-zA-Z0-9_]*\%(\.[a-zA-Z_][a-zA-Z0-9_]*\)*" display contained
|
syn match pythonDottedName "[a-zA-Z_][a-zA-Z0-9_]*\%(\.[a-zA-Z_][a-zA-Z0-9_]*\)*" display contained
|
||||||
|
else
|
||||||
|
syn match pythonDottedName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\)*" display contained
|
||||||
|
endif
|
||||||
syn match pythonDot "\." display containedin=pythonDottedName
|
syn match pythonDot "\." display containedin=pythonDottedName
|
||||||
|
|
||||||
"
|
"
|
||||||
@@ -178,8 +199,10 @@ syn match pythonDot "\." display containedin=pythonDottedName
|
|||||||
"
|
"
|
||||||
|
|
||||||
syn match pythonComment "#.*$" display contains=pythonTodo,@Spell
|
syn match pythonComment "#.*$" display contains=pythonTodo,@Spell
|
||||||
|
if !s:Enabled("g:python_highlight_file_headers_as_comments")
|
||||||
syn match pythonRun "\%^#!.*$"
|
syn match pythonRun "\%^#!.*$"
|
||||||
syn match pythonCoding "\%^.*\%(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$"
|
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
|
||||||
|
|
||||||
"
|
"
|
||||||
@@ -469,7 +492,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
|
||||||
@@ -481,8 +504,10 @@ if version >= 508 || !exists("did_python_syn_inits")
|
|||||||
HiLink pythonDot Normal
|
HiLink pythonDot Normal
|
||||||
|
|
||||||
HiLink pythonComment Comment
|
HiLink pythonComment Comment
|
||||||
|
if !s:Enabled("g:python_highlight_file_headers_as_comments")
|
||||||
HiLink pythonCoding Special
|
HiLink pythonCoding Special
|
||||||
HiLink pythonRun Special
|
HiLink pythonRun Special
|
||||||
|
endif
|
||||||
HiLink pythonTodo Todo
|
HiLink pythonTodo Todo
|
||||||
|
|
||||||
HiLink pythonError Error
|
HiLink pythonError Error
|
||||||
|
|||||||
5
test.py
5
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 функция
|
||||||
@@ -48,6 +51,8 @@ RuntimeWarning FutureWarning ImportWarning UnicodeWarning
|
|||||||
|
|
||||||
@ decoratorname
|
@ decoratorname
|
||||||
@ object.__init__(arg1, arg2)
|
@ object.__init__(arg1, arg2)
|
||||||
|
@ декоратор
|
||||||
|
@ декоратор.décorateur
|
||||||
|
|
||||||
# Numbers
|
# Numbers
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user