hdima / python-syntax

Python syntax highlighting script for Vim
http://www.vim.org/scripts/script.php?script_id=790
MIT License
363 stars 109 forks source link

self isn't highlighted in classes #43

Open purpleP opened 8 years ago

purpleP commented 8 years ago

I've searched and found issues about that https://github.com/hdima/python-syntax/issues/21 https://github.com/hdima/python-syntax/issues/10

And I find you arguments very weak.

So your first argument:

I actually tried it and I don't really like how it looks. It adds too many colors to the code to the point that it's getting harder to follow.

Really? You think that fist example is less readable then the second? I (and obviously a lot of people) don't. I think it's more readable.

screenshot 2016-01-06 22 35 17 screenshot 2016-01-06 22 35 38

If you can easily filter class fields from other variables and stuff it is beneficial. You can't doubt that, don't you? I strongly think if you somehow did it so that when self is highlighted it is harder to you to follow code, you just did something wrong with colors, that's it.

You second argument.

self is actually just a conventional name for the first argument of a method. And if somebody uses for example just s instead it won't be highlighted and just will be confusing.

Well then s is should be highlighted also, or any other name that is the pointer to class instance. And pycharm is actually doing just that. But that's probably involve actually parsing file or something and is harder (or impossible) to do with regexp. If that is so, than you should state so.

You last argument

As it just an argument of a method it also can raise a question "why the other arguments not highlighted?" and also can add to the confusion.

I will answer this 'confusing' question. Well, I've already answered it actually, so I'll just repeat myself. Because it's beneficial to filter class fields from other stuff in methods.

So to state my point again. It is obviously beneficial to filter class field from other stuff. If it's impossible, say so. If it's hard and I you doubt my arguments, so you won't do it yourself, than if you could guide somehow to the solution many will thank you for that (including me). If it's easy, but you won't do it, then again, it would be nice if you could provide help on how to do that.

Aluriak commented 8 years ago

This module implements the self and cls highlighting, which is a good feature. Plus, it can be deactivated using a dedicated option.

Maybe you will found a compromise here.

self is actually just a conventional name for the first argument of a method. And if somebody uses for example just s instead it won't be highlighted and just will be confusing.

Precisely because its conventionnal (and a convention widely accepted), allowing it to be highlighted is a good feature. From experience, it's very appreciable. Using s leads to confusing code, more than any highlighting.

But that's probably involve actually parsing file or something and is harder (or impossible) to do with regexp.

I think its impossible in vim. Needs a static code checker. Jedi could help, but it seems to be a little over-engineered.

sscherfke commented 8 years ago

python-mode also highlights self/cls and maps it to the highlight group pythonSelf. You could make it optional via a config variable.

purpleP commented 8 years ago

@sscherfke I don't use python mode, because I don't like its take it all or leave it approach. I think that that it should be the set of instructions or a script or something else, but not the bunch of packages, that you can't remove if you don't need them. If anyone interested in highlighting self, cls, default arguments and other improvements check out my fork of this project.

sscherfke commented 8 years ago

@purpleP Curretnly moving away from python-mode and missing the highlighted selfand cls … ;-)

purpleP commented 8 years ago

@sscherfke by the way, for easy access here is the link to my fork

nfnty commented 7 years ago

This has been fixed over at the fork vim-python/python-syntax.