Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

self isn't highlighted in classes #43

Open
purpleP opened this issue Jan 6, 2016 · 6 comments
Open

self isn't highlighted in classes #43

purpleP opened this issue Jan 6, 2016 · 6 comments

Comments

@purpleP
Copy link

purpleP commented Jan 6, 2016

I've searched and found issues about that
#21
#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
Copy link

Aluriak commented Apr 13, 2016

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
Copy link

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

@purpleP
Copy link
Author

purpleP commented Jun 27, 2016

@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
Copy link

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

@purpleP
Copy link
Author

purpleP commented Jun 27, 2016

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

@nfnty
Copy link

nfnty commented Mar 3, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants