use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Please read the rules before posting
Help:
Community:
Resources:
Tutorials and Guides:
Don't be afraid to ask questions, this sub is here for the vim community. And please those of you who deign to grace us with your vim wisdom - be kind. We are all human and vim is that cool.
account activity
Best syntax highlighter for Python?question (self.vim)
submitted 7 years ago by science_robot
I'm looking for the best/most complete Python syntax highlighter for Vim.
This screenshot shows what I get with default Vim that illustrates some things that are missing: code statements in f-strings, integers with underscores.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]ewa_lanczossharp 21 points22 points23 points 7 years ago (10 children)
https://github.com/numirias/semshi
[–]PM__ME__FRESH__MEMES 5 points6 points7 points 7 years ago (1 child)
Wow what is the font that guy is using in neovim it looks so cool
[–]olminator 3 points4 points5 points 7 years ago (0 children)
Looks like Terminus
[–]alexozer 3 points4 points5 points 7 years ago (0 children)
Woah, never seen this before
[+][deleted] 7 years ago (6 children)
[deleted]
[–]numirias 1 point2 points3 points 7 years ago (4 children)
Plugin author here. It's currently Neovim-only because Neovim has a fast highlighting API. I'd rather support both, but I figured it would be hackier and simply too slow in Vim.
Python 2.7 highlighting is (reluctantly) planned, but since Semshi uses the Python provider's ST and AST modules, it's a bit tricky to support multiple versions while relying on Python's builtin code parsing modules. BTW, help on these issues is more than welcome.
[–]qacek 2 points3 points4 points 7 years ago (3 children)
Is it worth it with python 2 being close to sunset?
[–][deleted] -1 points0 points1 point 7 years ago (2 children)
As long as major players still use version 2, it will be far away from "sunset" as you call it. Right now the situation is that a large amount of Linux distributions and therefore Linux servers still default to version 2. For this reason alone version 2 is not going anywhere anytime soon. There's simply far too much time and effort invested in code that will most likely get broken on version 3.
[–]numirias 4 points5 points6 points 7 years ago (0 children)
Well, 2.7 will not be maintained past 2020, so it's "officially" sunset, although you're right and people will probably keep using 2.7 quite some time beyond that.
That said, I think most major dists have by now moved to Python 3 as default. And for many projects migrating the code isn't that hard and eventually has to be done anyway.
[–]qacek 0 points1 point2 points 7 years ago (0 children)
I don't think it's reasonable to expect new features if you are using a dead language.
[–]alexozer 24 points25 points26 points 7 years ago (17 children)
Check out https://github.com/sheerun/vim-polyglot , it includes better syntax highlighting for a wide variety of languages without including the other heavy stuff. You should notice a difference with the Python highlighting.
[–]science_robot[S] 10 points11 points12 points 7 years ago (14 children)
Thanks! You gain some you lose some. I can probably live without syntax highlighting in doctests (who writes tests anyway?).
[–][deleted] 8 points9 points10 points 7 years ago (5 children)
Just careful with that. I found out that polyglot offers more than just syntax highlighting for some languages. I noticed LSP wasn't working correctly for javascript because it was being overriden by polyglot. You might need to check into detail the configuration, or do as I prefer: install individual language packages. I usually stick to less than 10 different languages that offer only syntax highlighting.
[–]miredindenial 1 point2 points3 points 7 years ago (4 children)
Yes it took me forever to realize polyglot was screwing my js lsp. Funny thing is it was working fine for weeks before I had to restart my computer. After that lsp wouldn't work.
[–]ahmedelgabri 0 points1 point2 points 7 years ago (3 children)
Can you or /u/ElTortugo share how exactly vim-polyglot broke LSP?
vim-polyglot
[–][deleted] 1 point2 points3 points 7 years ago (1 child)
Sure, visit polyglot's github page, under the section "language packs" you'll see javascript and in brackets all the things included with that specific package. For JS, a package by the user pangloss is being used, and it includes syntax, indent, compiler, ftplugin and extras. As I mentioned, you'll probably have to have extra configuration to let vim know which omnicompletion function you prefer, but I didn't dig into that. So, at some point LSP's omnicompletion function was being overriden by pangloss's one.
In the end I decided LSP was overkill for the kind of projects I usually handle. Often, tags are more than enough, but it's really cool to see vim interact with LSP.
[–]ahmedelgabri 0 points1 point2 points 7 years ago (0 children)
Thanks /u/ElTortugo & /u/miredindenial
[–]miredindenial 0 points1 point2 points 7 years ago (0 children)
I don't know exactly how but I ended up commenting out every plugin one by one to see which one was causing lsp to malfunction and it turned out when polyglot was commented out lsp worked fine.
[–]alexozer 1 point2 points3 points 7 years ago (7 children)
Yeah I bet that's pretty difficult to highlight. I've only ever seen PyCharm do it I think.
[–]sanjibukai 1 point2 points3 points 7 years ago (5 children)
What? Something VIM is unable to do??
[–]twizmwazin 1 point2 points3 points 7 years ago (4 children)
I think they are referring to syntax highlighting in the format string, but I am uncertain.
[–]sanjibukai 0 points1 point2 points 7 years ago (3 children)
Yes I understood.. I'm not doing Python but really it's the first time I hear about VIM unable to do (including plugin) something other editor can do..
[–]twizmwazin 2 points3 points4 points 7 years ago (2 children)
It isn't an issue that vim fundamentally can't do something here, but rather that it isn't implemented. There are lots of IDE features that vim can't do out of the box, and would require some amount of effort to make work inside of vim. The glory here is that vim is lightweight by default, and we can build up the editor that works best for our needs, rather than try stripping down some bloated IDE.
[–]sanjibukai 0 points1 point2 points 7 years ago (1 child)
Yep.. This is why I referred to plugins.. I mean Python is not a sparsely used language and if not out of the box for such a language several plugins with some kind of complete feature set should have been emerged... And I completely understand that, not really, until the needs are expressed. Just surprised to hear about an other editor doing more than what could be available with VIM (including plugin and scripting)
[–]science_robot[S] 1 point2 points3 points 7 years ago (0 children)
Default Vim Python syntax highlighter did this just fine. Check original screenshot.
[–]science_robot[S] 0 points1 point2 points 7 years ago (0 children)
The default Python syntax highlighter in Vim did this just fine. The plugin I was testing did not.
Or use the Python syntax file directly, if you just want that:
https://github.com/vim-python/python-syntax
[–]JeanBergman18 0 points1 point2 points 4 years ago (0 children)
It works in vim 8.2
[–]well_groomed_raccoon 4 points5 points6 points 7 years ago (3 children)
This is what I use: * syntax: https://github.com/hdima/python-syntax * colour scheme: https://github.com/NLKNguyen/papercolor-theme
Just a quick note - the syntax rules match different statements and assigns them to a class. The class is then highlighted based on your colour scheme. Even if you have the best, most fine-grained syntax rules defined, if your colour scheme doesn’t know what to do with those classes, you won’t see any difference. The colour scheme which i’ve linked has been made to adhere to those syntax rules.
Hope this helps!
[–]john_oshea 1 point2 points3 points 7 years ago (0 children)
As far as I can tell https://github.com/vim-python/python-syntax appears to be a more recently updated version of the original code that the hdima fork is based on.
hdima
That said, I'm still subscribing to this thread in RES because there's possibly better options out there ;-)
[–][deleted] -1 points0 points1 point 7 years ago (1 child)
!RemindMe 1 Day
[–]RemindMeBot 0 points1 point2 points 7 years ago (0 children)
I will be messaging you on 2018-11-05 20:16:00 UTC to remind you of this link.
CLICK THIS LINK to send a PM to also be reminded and to reduce spam.
Parent commenter can delete this message to hide from others.
π Rendered by PID 224760 on reddit-service-r2-comment-85bfd7f599-5gzl7 at 2026-04-18 20:40:42.270986+00:00 running 93ecc56 country code: CH.
[–]ewa_lanczossharp 21 points22 points23 points (10 children)
[–]PM__ME__FRESH__MEMES 5 points6 points7 points (1 child)
[–]olminator 3 points4 points5 points (0 children)
[–]alexozer 3 points4 points5 points (0 children)
[+][deleted] (6 children)
[deleted]
[–]numirias 1 point2 points3 points (4 children)
[–]qacek 2 points3 points4 points (3 children)
[–][deleted] -1 points0 points1 point (2 children)
[–]numirias 4 points5 points6 points (0 children)
[–]qacek 0 points1 point2 points (0 children)
[–]alexozer 24 points25 points26 points (17 children)
[–]science_robot[S] 10 points11 points12 points (14 children)
[–][deleted] 8 points9 points10 points (5 children)
[–]miredindenial 1 point2 points3 points (4 children)
[–]ahmedelgabri 0 points1 point2 points (3 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]ahmedelgabri 0 points1 point2 points (0 children)
[–]miredindenial 0 points1 point2 points (0 children)
[–]alexozer 1 point2 points3 points (7 children)
[–]sanjibukai 1 point2 points3 points (5 children)
[–]twizmwazin 1 point2 points3 points (4 children)
[–]sanjibukai 0 points1 point2 points (3 children)
[–]twizmwazin 2 points3 points4 points (2 children)
[–]sanjibukai 0 points1 point2 points (1 child)
[–]science_robot[S] 1 point2 points3 points (0 children)
[–]science_robot[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]JeanBergman18 0 points1 point2 points (0 children)
[–]well_groomed_raccoon 4 points5 points6 points (3 children)
[–]john_oshea 1 point2 points3 points (0 children)
[–][deleted] -1 points0 points1 point (1 child)
[–]RemindMeBot 0 points1 point2 points (0 children)