Open purpleP opened 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.
python-mode also highlights self
/cls
and maps it to the highlight group pythonSelf. You could make it optional via a config variable.
@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.
@purpleP Curretnly moving away from python-mode and missing the highlighted self
and cls
… ;-)
This has been fixed over at the fork vim-python/python-syntax.
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:
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.
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.
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
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.