-
Notifications
You must be signed in to change notification settings - Fork 34
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
Recognizing keyword argument in f(x; kwd) #114
Comments
Maybe this works? I don't know if I missed the branching stuff. --- Installed Packages/Julia/Julia.sublime-syntax
+++ Packages/Julia/Julia.sublime-syntax
@@ -1034,15 +1034,32 @@
pop: true
- include: main
+ function-call-keyword-arguments-only:
+ - meta_content_scope: meta.function-call.arguments.julia
+ - match: \)
+ scope: punctuation.section.arguments.end.julia
+ set: after-expression
+ - match: \,
+ scope: punctuation.separator.comma.julia
+ - include: function-call-keyword-arguments
+ - match: '{{symb_id}}(?=\s*(?:\,|\)|\.{3}))'
+ scope: variable.parameter.julia
+ push: after-expression
+ - include: main
+
function-call-arguments-group:
- match: \(
scope: punctuation.section.arguments.begin.julia
set:
- - meta_scope: meta.function-call.julia
- - meta_content_scope: meta.function-call.arguments.julia
+ - meta_scope: meta.function-call.arguments.julia
- match: \)
scope: punctuation.section.arguments.end.julia
set: after-expression
+ - match: \,
+ scope: punctuation.separator.comma.julia
+ - match: \;
+ scope: punctuation.separator.semicolon.julia
+ set: function-call-keyword-arguments-only
- include: function-call-keyword-arguments
- include: main I've also added punctuation scopes for plot(x, y; width)
# ^^^^^ variable.parameter.julia
plot(x, y, width=width)
# ^^^^^ variable.parameter.julia
# ^^^^^ - variable.parameter
plot(x, y; width=width)
# ^^^^^ variable.parameter.julia
# ^^^^^ - variable.parameter
plot(x, y; :width => width)
# ^^^^^^ constant.other.symbol.julia
plot(x, y; width=options.width)
# ^^^^^ variable.parameter.julia
plot(x, y; options.width)
# ^^^^^^^^^^^^^ - variable.parameter
plot(x, y; width, kws...)
# ^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.julia - meta.function-call meta.function-call
# ^^^^^ variable.parameter.julia
# ^^^ variable.parameter.julia
# ^^^ keyword.operator.splat.julia
# ^ punctuation.separator.comma.julia
# ^ punctuation.separator.semicolon.julia
# ^ punctuation.separator.comma.julia |
Forgive my ignorance, but is there a good way to test these changes? I tried using |
I don't think it is correct as it pops the current context out. We should only pop it after |
If the Julia package is installed via Package Control, then it can't work because the syntax is within a zip file in the Installed Packages folder. If you have the package git cloned, then the diff above probably has the wrong paths or it doesn't work because there are no commit hashes? I didn't create the diff via An easy way (and what I did) was to create a folder
Not sure why that would be a problem. The meta scope is applied in the new context too, and this new context also pops after |
Then how's |
By the exact same rule as in |
But in
The context will be popped, set it sees a semicolon. There is no way that the |
My bad, I didn't see that there is a match for |
But I think a better way is to |
Yes this alternative would work too and maybe is a better way. In that case, the new context doesn't need the meta scope. |
@jwortmann's seems to work in practice, but it breaks a lot of tests, I think all because |
It would be great to tag
kwd
in thef(x; kwd)
be tagged withvariable.parameter.julia
. I thought it would be pretty simple to recognize the first semicolon and then push a new context which is identical tofunction-parameters
, but where anything tagged as an argument is also tagged as a parameter. But there's some fancy branching stuff going on here that I couldn't grok so I couldn't make it work myself.Here's a test (which fails)
I'm not sure whether
kws
should be a parameter as well. It is acting as a keyword argument, but it's not actually the name of a parameter. I think it's technically more correct to not tag it, but it would be more practically useful to tag it because from a user perspective, we really just want to know whether the variables are getting passed as keyword arguments or regular arguments.The text was updated successfully, but these errors were encountered: