-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Rename go_highlight_methods to go_highlight_function_calls #1557
Conversation
I also wonder if |
I see your reasoning here, but I've always understood Assuming that's the case, the problem identified in #1500 may simply be that:
|
I don't know either, but this is how it has actually works right now and thus far no one complained. It just wasn't documented as such :-) |
As I mentioned in #1557 (comment), I think this change is a departure from how it currently behaves, and only @fatih can resolve the conflicts in our understanding. How would you feel about trying what I suggested to simply resolve the highlighting instead of changing the meaning of the variables? |
I should point out that back when |
Could it be that it might be regressed while we refactored it? I always remember it was working fine. 3 years ago when I started this project, the method setting was one of the first added. It made it really easy to see methods and distinguish them from ordinary functions (as methods are grouped together). I'm all good to fix it, but we shouldn't remove or change the meaning. Functions and methods are two different things in the spec. |
Thanks @fatih! I layed out a possible root cause in #1557 (comment) |
I guess the confusion started when someone added Highlighting method calls separate from function calls is impossible, since we can't disambiguate between calling a function on another package, and calling a method; not with Vim's regexp engine anyway. This feature has never worked quite right in that sense. So; regardless of what it was in the past, which settings do we want to have? At the very minimum the documentation should be clarified. To me, it still seems to make sense to group
I'm not sure if I understand how this will fix the issue in PR, as such? Either way, it would not be a good idea as it will mean all those regexps will be run for everyone, even people who haven't enabled the setting. That will be a severe performance hit, especially on slightly older systems (e.g. my 2005 OpenBSD laptop still works kind of okay :-)) |
Oh I see, yeah function calls and declarations are two different things. My comment was about function and method declarations, not calls. I'm ok to have a single setting for function calls. I'm just not sure if someone would want to have two different highlights for the |
Codecov Report
@@ Coverage Diff @@
## master #1557 +/- ##
=========================================
Coverage ? 14.79%
=========================================
Files ? 53
Lines ? 4150
Branches ? 0
=========================================
Hits ? 614
Misses ? 3536
Partials ? 0
Continue to review full report at Codecov.
|
Separating method calls from calls on a package is not easy with the current regexp based syntax highlighting. Is `fmt.Println` a method call or function call? This fixes #1500 by clarifying what the setting is supposed to do. I think this makes sense, because people who want to highlight function declarations probably want to do this for both functions and methods, and people who want to highlight function calls want to do this for functions and methods, too.
No, nothing changes for declarations. Sorry for the confusion.
Ehm, probably not. We could also maybe just remove |
Why is
Which he confirmed was about declarations in #1557 (comment), I thought the highlighting of methods should be fixed... 🤷♂️ |
So to recap, currently we have the following settings:
This is imho broken. Because Martin's PR changes the name to make it clearer but also changes the meaning of
The meaning of This is of course, at least better compared to the current situation. So the question, Having said that, I suggest something else. I vote to change the current intepration to this, just for now:
So we're going to fix This is the first step, the second step would be then to introduce these new
We could do this in two separate steps or just in one single step and be done |
TL;DR:
I think the That also means, of course, that your first suggestion in your recent comment to
is impossible for similar reasons. In any case, I'm mostly fine with this PR as is, but if we want to allow highlighting of function and method declarations separately, then instead of the two settings in this PR, we'd need these three settings:
To prepare for that eventuality, let's rename |
Maybe not now, but if we switch to a Go parser with type informations attached to the AST, then it would be easy to identify (because we would know if In this case I think this PR in its current state is good to go, so:
I think we should open the door for future improvements and introduce the |
SGTM |
vim-go renamed go_highlight_methods to go_highlight_function_calls recently to address confusion with the way the existing variable names behaved [1]. This change will re-enable the higlighting of function and method _invocations_. [1] fatih/vim-go#1557 (comment)
Separating method calls from calls on a package is not easy with the
current regexp based syntax highlighting. Is
fmt.Println
a method callor function call?
This fixes #1500 by clarifying what the setting is supposed to do. I
think this makes sense, because people who want to highlight function
declarations probably want to do this for both functions and methods,
and people who want to highlight function calls want to do this for
functions and methods, too.