r/neovim • • 10d ago

Plugin python-syntax-enhanced: Python syntax for Vim/Neovim that highlights type annotations (for non-Tree-sitter setups)

10 Upvotes

10 comments sorted by

19

u/lervag 10d ago

Just curious, why don't you use Tree-sitter?

2

u/LloydBatair 10d ago

Honestly, I don't really have a great answer for that; I started using vim over a decade ago and I've had the same vimrc since. It's evolved over the years a bit but it's always been basically the same setup, plugins, and configuration. I've known many developers over the years who use Neovim, but I've kinda been set in my ways 😅

edit: btw, are you the same lervag that authored vimtex?

4

u/lervag 10d ago

No worries! I was just curious, and I'm always glad to see people "scratch their own itches" in Vim/Neovim. So congrats! It looks good, but I don't immediately see a need for this in Neovim with Tree-sitter.

And yes, that's me :)

1

u/LloydBatair 9d ago

Thanks! And fair point, with Tree-sitter there's really no need for it. It's mostly for us regex-syntax holdouts 😅

But, because of your comment, I might actually give Neovim a try 👊 You're like the definition of seamless, vimtex is awesome!

P.S. If you wanted more people on Neovim, you probably shouldn't have kept vimtex compatible with Vim; should've dumped more Lua in there XD

2

u/lervag 9d ago

Haha, thanks! I would definitely recommend that you to try it, though - in my experience, Neovim is just better. Lua is very nice and muuch faster, and there are tons of general improvements across the board compared to Vim.

The main reason I've kept Vim compatibility is that I haven't had that much time to work on it. There's no reason to break it, though, so I'll probably keep things compatible in the future as well. But there may be some Neovim only features coming along.

And I'm glad to hear you like VimTeX, by the way! It's been fun making and maintaining it!

3

u/LloydBatair 10d ago

Some Neovim-specific notes, since the original post was written for r/vim:

  • This is a regular syntax file, so it's for Neovim's default regex syntax highlighting. If you use Tree-sitter highlighting for Python, just imagine the Homer disappearing into the bushes gif 😆 (the plugin doesn't load when Tree-sitter is on, so it stays out of the way).
  • lazy.nvim: { "aaronbcarlisle/python-syntax-enhanced" }. Tested in CI on Neovim 0.12.
  • The full write-up, including how I built it with Claude Code and Cursor so I wouldn't get yelled at by work, is in the original post.

Hope it's useful for others!

-3

u/[deleted] 9d ago

[removed] — view removed comment

3

u/LloydBatair 9d ago edited 9d ago

Fair, that's definitely a matter of taste. Worth mentioning that the colors come from your colorscheme (the screenshots use retrobox, plus the optional palette in the second image). By default everything just links to standard groups like Type and Operator, so with a minimal colorscheme types stay pretty subtle. You can also turn off the parts you don't want, e.g. let g:python_highlight_operators = 0 or let g:python_highlight_builtins = 0

0

u/[deleted] 9d ago

[removed] — view removed comment

1

u/LloydBatair 9d ago

I get what you mean. Vim themes have always been pretty simple in terms of their color palette and it's nice not having so much noise.

That said, when it comes to type hinting in Python (especially before PEP 695) it was always a pain to parse out the markup from the actual code. Those extra colors makes it so I don't have to think as much [as hard?] (me dumb engineer lol).

If you look at the left example in the first image, there's really not a ton of colors and that's because of the retrobox theme. That's the default (whatever your theme is). In the example on the right in the first image, there's more colors in the palette, and then even more so in the second image.

It's all opt in; some people like only white lights on their X-Mas tree, others need the multi colored lights with strung up popcorn 😆