viluon / LuaExtended

An improved ST3 Lua syntax definition.
MIT License
19 stars 11 forks source link

Issue with new function scope #10

Closed hbomb79 closed 7 years ago

hbomb79 commented 7 years ago

The new function scope merged from #9 seems to work great for functions, however my custom syntax pack no longer works as a result of the main scope not being used.

If a function definition precedes my class declaration, my syntax theme fails to pick it up - this is not the case with traditional Lua (hence I believe it is a LuaExtended issue, and not something I am doing incorrectly).

This is my syntax context:

  main:
    - match: "\\b(class|extends|mixin|alias)\\b"
      scope: keyword
      push: class-string-declaration

    - match: "\\b(abstract)\\b\\s+(?=class)\\b"
      scope: keyword

    - match: "\\b(configureConstructor)\\b(?=(\\w+))"
      scope: keyword

    - include: Packages/LuaExtended/LuaExtended.sublime-syntax

This does not work if a function is defined above the class declaration. Replacing 'LuaExtended' with 'Lua', fixes the issue but at the expense of losing the benefits of LuaExtended.

Screenshots:

Doesn't work

Does work

InternetUnexplorer commented 7 years ago

@hbomb79 I included the following in the main context in LuaExtended.sublime-syntax for testing:

- match: "\\b(class|extends|mixin|alias)\\b"
  scope: keyword
  # push: class-string-declaration ### I don't have your whole syntax file, so I can't use this part.

- match: "\\b(abstract)\\b\\s+(?=class)\\b"
  scope: keyword

- match: "\\b(configureConstructor)\\b(?=(\\w+))"
  scope: keyword

For some reason, it works perfectly for me:

Could you include your whole syntax file, so I can experiment further?

hbomb79 commented 7 years ago

That is interesting - Right now I am using the 'Lua' include, instead of 'LuaExtended' without issues.

This is the full syntax file:

%YAML 1.2
---
name: Titanium
comment: "A syntax package for users writing class code for Titanium. Uses LuaExtended"
file_extensions:
  - ti
scope: source.titanium

contexts:
  main:
    - match: "\\b(class|extends|mixin|alias)\\b"
      scope: keyword
      push: class-string-declaration

    - match: "\\b(abstract)\\b\\s+(?=class)\\b"
      scope: keyword

    - match: "\\b(configureConstructor)\\b(?=(\\w+))"
      scope: keyword

    - include: Packages/LuaExtended/LuaExtended.sublime-syntax

  class-string-declaration:
    - match: "[\"'\\s]*(\\w*)[\"'\\s]*"
      scope: string.class.titanium
      pop: true
viluon commented 7 years ago

@InternetUnexplorer thanks for the work! I'll be actually away for the weekend, so if you want to carry on, fine with me :smile: Otherwise I'll get to it once I'm back, sorry @hbomb79 :confused:

InternetUnexplorer commented 7 years ago

@hbomb79 @viluon Sorry for not responding earlier, I was asleep. Thanks for the full syntax file, I should have time to work on it tonight.