Patch: python syntax highlighting string match groups

43 views
Skip to first unread message

Zvezdan Petkovic

unread,
May 18, 2015, 6:56:43 PM5/18/15
to vim...@vim.org
diff --git a/runtime/syntax/python.vim b/runtime/syntax/python.vim
--- a/runtime/syntax/python.vim
+++ b/runtime/syntax/python.vim
@@ -1,7 +1,7 @@
" Vim syntax file
" Language: Python
" Maintainer: Neil Schemenauer <n...@python.ca>
-" Last Change: 2014 Jul 16
+" Last Change: 2015 May 17
" Credits: Zvezdan Petkovic <zpet...@acm.org>
" Neil Schemenauer <n...@python.ca>
" Dmitry Vasiliev
@@ -95,16 +95,16 @@
syn keyword pythonTodo FIXME NOTE NOTES TODO XXX contained

" Triple-quoted strings can contain doctests.
-syn region pythonString
+syn region pythonString matchgroup=pythonQuotes
\ start=+[uU]\=\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1"
\ contains=pythonEscape,@Spell
-syn region pythonString
+syn region pythonString matchgroup=pythonTripleQuotes
\ start=+[uU]\=\z('''\|"""\)+ end="\z1" keepend
\ contains=pythonEscape,pythonSpaceError,pythonDoctest,@Spell
-syn region pythonRawString
+syn region pythonRawString matchgroup=pythonQuotes
\ start=+[uU]\=[rR]\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1"
\ contains=@Spell
-syn region pythonRawString
+syn region pythonRawString matchgroup=pythonTripleQuotes
\ start=+[uU]\=[rR]\z('''\|"""\)+ end="\z1" keepend
\ contains=pythonSpaceError,pythonDoctest,@Spell

@@ -113,7 +113,7 @@
syn match pythonEscape "\\x\x\{2}" contained
syn match pythonEscape "\%(\\u\x\{4}\|\\U\x\{8}\)" contained
" Python allows case-insensitive Unicode IDs: http://www.unicode.org/charts/
-syn match pythonEscape "\\N{.\{-}}" contained
+syn match pythonEscape "\\N{\a\+\%(\s\a\+\)*}" contained
syn match pythonEscape "\\$"

if exists("python_highlight_all")
@@ -274,6 +274,8 @@
HiLink pythonTodo Todo
HiLink pythonString String
HiLink pythonRawString String
+ HiLink pythonQuotes String
+ HiLink pythonTripleQuotes pythonQuotes
HiLink pythonEscape Special
if !exists("python_no_number_highlight")
HiLink pythonNumber Number

Bram Moolenaar

unread,
May 21, 2015, 11:05:49 PM5/21/15
to Zvezdan Petkovic, vim...@vim.org

Zvezdan Petkovic wrote:

> diff --git a/runtime/syntax/python.vim b/runtime/syntax/python.vim
> --- a/runtime/syntax/python.vim
> +++ b/runtime/syntax/python.vim
> @@ -1,7 +1,7 @@
> " Vim syntax file
> " Language: Python
> " Maintainer: Neil Schemenauer <n...@python.ca>

I would prefer Neil to send me the updated version. Otherwise his next
update might not include this patch.

--
Don't believe everything you hear or anything you say.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages