Git Product home page Git Product logo

Comments (11)

jwortmann avatar jwortmann commented on June 19, 2024

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 , and ; and fixed the meta scopes (I think they are not supposed to stack). The adjusted meta scopes will break a lot of syntax tests though.

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

from julia-sublime.

fredcallaway avatar fredcallaway commented on June 19, 2024

Forgive my ignorance, but is there a good way to test these changes? I tried using git apply but it says this is a "corrupt patch"

from julia-sublime.

randy3k avatar randy3k commented on June 19, 2024
+        - match: \;
+          scope: punctuation.separator.semicolon.julia
+          set: function-call-keyword-arguments-only

I don't think it is correct as it pops the current context out. We should only pop it after \).

from julia-sublime.

jwortmann avatar jwortmann commented on June 19, 2024

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 git diff, because I don't have the Julia package git cloned.

An easy way (and what I did) was to create a folder Julia in the Packages directory, create an override for the syntax file by copying it there, and then just copy the file lines from the diff by hand.


I don't think it is correct as it pops the current context out. We should only pop it after ).

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 \).

from julia-sublime.

randy3k avatar randy3k commented on June 19, 2024

Then how's \) be matched?

from julia-sublime.

jwortmann avatar jwortmann commented on June 19, 2024

By the exact same rule as in function-call-arguments-group?

from julia-sublime.

randy3k avatar randy3k commented on June 19, 2024

By the exact same rule as in function-call-arguments-group?

But in

+        - match: \;
+          scope: punctuation.separator.semicolon.julia
+          set: function-call-keyword-arguments-only

The context will be popped, set it sees a semicolon. There is no way that the \) to be matched.

from julia-sublime.

randy3k avatar randy3k commented on June 19, 2024

My bad, I didn't see that there is a match for \) in function-call-keyword-arguments-only.

from julia-sublime.

randy3k avatar randy3k commented on June 19, 2024

But I think a better way is to push and then pop in function-call-keyword-arguments-only when matching (?=\)).
(This may be also true for many of the existing logic. At some point, I'll need to revise the logic in the syntax.)

from julia-sublime.

jwortmann avatar jwortmann commented on June 19, 2024

But I think a better way is to push and then pop in function-call-keyword-arguments-only when matching (?=)).
(This may be also true for many of the existing logic. At some point, I'll need to revise the logic in the syntax.)

Yes this alternative would work too and maybe is a better way. In that case, the new context doesn't need the meta scope.

from julia-sublime.

fredcallaway avatar fredcallaway commented on June 19, 2024

@jwortmann's seems to work in practice, but it breaks a lot of tests, I think all because [meta.function-call.julia] does not match scope [meta.function-call.arguments.julia]

from julia-sublime.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.