From 8abd9ad24f51332e99a08969ed622fb696f62abf Mon Sep 17 00:00:00 2001 From: Eric Leschinski Date: Wed, 25 Dec 2013 13:36:49 -0500 Subject: [PATCH 01/13] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ceb65d7..eb4550a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Pretty Vim Python 0.1 +Pretty Vim Python ===================== ![Imgur](http://i.imgur.com/RQ9mt.png) @@ -8,6 +8,10 @@ This is my attempt to make the python syntax highlighting in Vim look like Textm Important --------- +To deploy this on your system: + + git clone + In the syntax folder is the **python.vim** which does the syntax highlighting for Python. Just replace yours with mine but remember to backup beforehand. From adefec9eeb1ce40bca88c7afe930e46ed2ac7f5d Mon Sep 17 00:00:00 2001 From: Eric Leschinski Date: Wed, 25 Dec 2013 14:39:28 -0500 Subject: [PATCH 02/13] Update README.md --- README.md | 86 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 73 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index eb4550a..efd8ba9 100644 --- a/README.md +++ b/README.md @@ -3,27 +3,87 @@ Pretty Vim Python ![Imgur](http://i.imgur.com/RQ9mt.png) -This is my attempt to make the python syntax highlighting in Vim look like Textmate's. +This is my attempt to make the python syntax highlighting in Vim look like Textmate's. It works on Ubuntu 12.10, for other distributions things may be different. Important --------- -To deploy this on your system: +To deploy this on your system: (I assume your username is 'el', replace it with your username). - git clone + sudo apt-get install git + mkdir /home/el/.vim + git clone https://github.com/sentientmachine/Pretty-Vim-Python.git -In the syntax folder is the **python.vim** which does the syntax highlighting for Python. Just replace yours with mine -but remember to backup beforehand. +That puts a directory called Pretty-Vim-Python in your .vim directory. Got to yank out the files and put them where they belong: -Next I had to add another color definition to the **molokai.vim** stylesheet. This is probably not a very good idea -because the new color definition will not be available for a different color theme. So in your colors folder -add this molokai.vim and remember to select it as your default colorscheme. + mv Pretty-Vim-Python/* . + +Then you can delete the extraneous files (don't run this command unless you know what it does and why it does it) when it doubt do a tutorial. -The changes made in the files are highlighted with comments and begins with **NOTE: @pfdevilliers added this**. + rm -rf Pretty-Vim-Python +Edit your .vimrc: -General -------- + vi /home/el/.vimrc + +Put this code at the bottom of your .vimrc, create it if it doesn't exist: + + colorscheme molokai + highlight Comment cterm=bold + +Restart the terminal so the changes can take effect. Then put this python code in a file called /home/el/mypython.py: + + #!/usr/bin/python -tt + + import subprocess, sys + from django.http import HttpResponse + from pinkie_pie import unit_tests as unit + + twilight_sparkle = {0: '', 1: 'derpy'} + rairnbow_dash = Math.sqrt(1*5) + + #all your base are belong to us now + foo = 'text in single quotes\n' + moo = "unicode \u2713 text in double \t quotes" + print("the aliens are on route, we must prepare") + + class MyClass(penguin): + def __init__(self, *args): + self.x = 10 + + sys.path.append("mypath") + execfile("/home/el/tuvok.py"); + + def drop_the_caffeine_and_crack_pipe_dont_make_me_taze_you(): + pony = {'ls -l', {"time for robohug"} } + for cmd in pony: + p = mycrappyimport.fromulate(cmd, bacon=True, x=@wtf_bro) + if cmd.strip() == "": + raise Http404 + if ("" in goatse): + try: + global epicglobal + except SystemExit: + pass + + def derpyhooves(Thread): + def bonbon(): + romulans = 2 * (4 / 1) + noodley_appendage = 5 % (3 ^ 7) + return romulans + def run(self): + print("fluttershy" + str('666') + str("666")) + + //python syntax error here + + def slug(self): + if self.parent is not None: + yarr(__debug__) + + exit(0) + + +It should look like this, if it doesn't, then you did something wrong. + +![Imgur](http://imgur.com/iL56a1y) -The additions are still very much a hack job and must be improved upon. I think there are still two issues to -sort out to duplicate the functionality of the Textmate highlighting, but I guess it is usable. From 8d03e981c5310885a55334ec93e0e9f0f2e779ed Mon Sep 17 00:00:00 2001 From: Eric Leschinski Date: Wed, 25 Dec 2013 14:40:14 -0500 Subject: [PATCH 03/13] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index efd8ba9..df1d0ac 100644 --- a/README.md +++ b/README.md @@ -85,5 +85,4 @@ Restart the terminal so the changes can take effect. Then put this python code It should look like this, if it doesn't, then you did something wrong. -![Imgur](http://imgur.com/iL56a1y) - +![Imgur](http://imgur.com/iL56a1y.png) From b46b973e2e3fffa7c0f6ac371171897f7d2df931 Mon Sep 17 00:00:00 2001 From: Eric Leschinski Date: Wed, 25 Dec 2013 14:42:26 -0500 Subject: [PATCH 04/13] Update README.md --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index df1d0ac..401c1ab 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ Pretty Vim Python ===================== -![Imgur](http://i.imgur.com/RQ9mt.png) +How to get a vim python colorscheme that doesn't suck. + +![Imgur](http://imgur.com/iL56a1y.png) This is my attempt to make the python syntax highlighting in Vim look like Textmate's. It works on Ubuntu 12.10, for other distributions things may be different. @@ -83,6 +85,6 @@ Restart the terminal so the changes can take effect. Then put this python code exit(0) -It should look like this, if it doesn't, then you did something wrong. +It should look like the image at the top, if it doesn't, then you did something wrong. + -![Imgur](http://imgur.com/iL56a1y.png) From b2ff16be81827e501e6d66ed7d06e34e11a21ef5 Mon Sep 17 00:00:00 2001 From: Eric Leschinski Date: Wed, 25 Dec 2013 14:44:36 -0500 Subject: [PATCH 05/13] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 401c1ab..41a554b 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ Important To deploy this on your system: (I assume your username is 'el', replace it with your username). + + sudo apt-get install vim sudo apt-get install git mkdir /home/el/.vim git clone https://github.com/sentientmachine/Pretty-Vim-Python.git From 5c022178ef06245c2879e815ccbeaf9e062dbae7 Mon Sep 17 00:00:00 2001 From: Eric Leschinski Date: Wed, 25 Dec 2013 14:49:28 -0500 Subject: [PATCH 06/13] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 41a554b..37abcdb 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ Pretty Vim Python How to get a vim python colorscheme that doesn't suck. +If this doesn't work for you or you see any errors, let me know eric.leschinski@hotmail.com and I'll fix it. + ![Imgur](http://imgur.com/iL56a1y.png) This is my attempt to make the python syntax highlighting in Vim look like Textmate's. It works on Ubuntu 12.10, for other distributions things may be different. From 62a41b028b2d7e9e897c2afd242c7c1ab9b59432 Mon Sep 17 00:00:00 2001 From: Eric Leschinski Date: Wed, 25 Dec 2013 15:02:11 -0500 Subject: [PATCH 07/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 37abcdb..24cb0ce 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Pretty Vim Python How to get a vim python colorscheme that doesn't suck. -If this doesn't work for you or you see any errors, let me know eric.leschinski@hotmail.com and I'll fix it. +If this doesn't work for you or you see anything wrong, let me know eric.leschinski@hotmail.com and I'll see if its my fault or your fault. ![Imgur](http://imgur.com/iL56a1y.png) From 912af7decfbcd89302d5782871b801384e0036ec Mon Sep 17 00:00:00 2001 From: Eric Leschinski Date: Wed, 25 Dec 2013 16:29:41 -0500 Subject: [PATCH 08/13] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 24cb0ce..8d3fdf8 100644 --- a/README.md +++ b/README.md @@ -91,4 +91,6 @@ Restart the terminal so the changes can take effect. Then put this python code It should look like the image at the top, if it doesn't, then you did something wrong. +If the colors are not coming through you might have to add this line to the bottom of your /home/el/.profile or your /home/el/.bashrc + TERM=xterm-256color From c72d8cce2c1e4f407bd44eea7e2669a6c10a2f13 Mon Sep 17 00:00:00 2001 From: Eric Leschinski Date: Thu, 26 Dec 2013 14:15:51 -0500 Subject: [PATCH 09/13] Update molokai.vim --- colors/molokai.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/colors/molokai.vim b/colors/molokai.vim index 2ba9c7d..595cca6 100644 --- a/colors/molokai.vim +++ b/colors/molokai.vim @@ -231,3 +231,6 @@ if &t_Co > 255 hi LineNr ctermfg=250 ctermbg=233 hi NonText ctermfg=240 ctermbg=233 end " }}} + +highlight Comment cterm=bold + From d59fb3f6402a4a988655d77598c8f6284edf0ee1 Mon Sep 17 00:00:00 2001 From: Eric Leschinski Date: Thu, 26 Dec 2013 14:19:57 -0500 Subject: [PATCH 10/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d3fdf8..d5430a1 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ How to get a vim python colorscheme that doesn't suck. If this doesn't work for you or you see anything wrong, let me know eric.leschinski@hotmail.com and I'll see if its my fault or your fault. -![Imgur](http://imgur.com/iL56a1y.png) +![Imgur](http://i.imgur.com/W26xaan.png) This is my attempt to make the python syntax highlighting in Vim look like Textmate's. It works on Ubuntu 12.10, for other distributions things may be different. From 4e00a4f32fdcf2b8b4d92bd4a2a45cab3b28d3ff Mon Sep 17 00:00:00 2001 From: ZJ Shen Date: Tue, 15 Dec 2015 16:45:05 +0800 Subject: [PATCH 11/13] fix () in pythonParameters ``` @mock(a=["(aa)"]) def foo(self, str_a='aaa()aaa') ``` think of this case, the old regex `("syn region pythonVars start="(" end=")" contained contains=pythonParameters transparent keepend )` will take ) in aaa() as the end of region pythonVars --- syntax/python.vim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index df100f6..62ad2ce 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -102,8 +102,12 @@ syn match pythonDecorator "@" display nextgroup=pythonFunction skipwhite " This should be improved and simplified. syn match pythonFunction \ "\%(\%(def\s\|class\s\|@\)\s*\)\@<=\h\%(\w\|\.\)*" contained nextgroup=pythonVars -syn region pythonVars start="(" end=")" contained contains=pythonParameters transparent keepend -syn match pythonParameters "[^,]*" contained contains=pythonParam,pythonBrackets skipwhite +" NOTE: @Kamushin fix this +" @mock(a=["(aa)"]) +" def foo(self, str_a='aaa()aaa') + +syn region pythonVars start="(" end=")[\n|:]" contained contains=pythonParameters transparent keepend +syn match pythonParameters "[^,:]*" contained contains=pythonParam,pythonBrackets skipwhite syn match pythonParam "=[^,]*" contained contains=pythonExtraOperator,pythonBuiltin,pythonConstant,pythonStatement,pythonNumber,pythonString skipwhite syn match pythonBrackets "[(|)]" contained skipwhite From b4280f0bcc690e4a83f5bfb584803308684a9618 Mon Sep 17 00:00:00 2001 From: ZJ Shen Date: Tue, 15 Dec 2015 16:53:50 +0800 Subject: [PATCH 12/13] fix ): in args foo(self, str_a='aaa()aaa):') --- syntax/python.vim | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 62ad2ce..d54138e 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -104,9 +104,8 @@ syn match pythonFunction \ "\%(\%(def\s\|class\s\|@\)\s*\)\@<=\h\%(\w\|\.\)*" contained nextgroup=pythonVars " NOTE: @Kamushin fix this " @mock(a=["(aa)"]) -" def foo(self, str_a='aaa()aaa') - -syn region pythonVars start="(" end=")[\n|:]" contained contains=pythonParameters transparent keepend +" def foo(self, str_a='aaa()aaa):') +syn region pythonVars start="(" end="):*\n" contained contains=pythonParameters transparent keepend syn match pythonParameters "[^,:]*" contained contains=pythonParam,pythonBrackets skipwhite syn match pythonParam "=[^,]*" contained contains=pythonExtraOperator,pythonBuiltin,pythonConstant,pythonStatement,pythonNumber,pythonString skipwhite syn match pythonBrackets "[(|)]" contained skipwhite From 896032b9705e142667aafff07ccaed70f471429e Mon Sep 17 00:00:00 2001 From: Exyphrius Date: Thu, 27 Jul 2017 17:18:01 -0700 Subject: [PATCH 13/13] Update python.vim on line 108, added a period (.) after the colon (:) and before the asterisk (*) to make the expression :.* (match anything after the colon) instead of :* (match any number of colons) Previously, this presented an issue where whitespace after a function definition followed by a comment starting with # would cause the entire comment and several following tokens to be classified as identifiers instead of their respective true classes. --- syntax/python.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index d54138e..82f2211 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -105,7 +105,7 @@ syn match pythonFunction " NOTE: @Kamushin fix this " @mock(a=["(aa)"]) " def foo(self, str_a='aaa()aaa):') -syn region pythonVars start="(" end="):*\n" contained contains=pythonParameters transparent keepend +syn region pythonVars start="(" end="):.*\n" contained contains=pythonParameters transparent keepend syn match pythonParameters "[^,:]*" contained contains=pythonParam,pythonBrackets skipwhite syn match pythonParam "=[^,]*" contained contains=pythonExtraOperator,pythonBuiltin,pythonConstant,pythonStatement,pythonNumber,pythonString skipwhite syn match pythonBrackets "[(|)]" contained skipwhite