-
Notifications
You must be signed in to change notification settings - Fork 586
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
[Lua] Add support for a few new syntax features introduced in Lua 5.4 and a couple improvements. #2693
Conversation
Lua 5.4 introduces the concept of `const` & to-be-closed variables. 1. A `const` variable is a variable whos value cannot be changed after initialization. The syntax is a bit weird, though. 2. A to-be-closed variable behaves like a constant local variable, except that its value is closed whenever the variable goes out of scope, including normal block termination, exiting its block by break/goto/return, or exiting by an error. (The definition is taken from the official Lua docs https://www.lua.org/manual/5.4/manual.html#3.3.8)
Previously, the Lua syntax assigned a fourth level scope, true or false to identify between `true` & `false` (`false` again was wrongly scoped as `constant.language.boolean.true.lua`). I don't think it is really beneficial in having a 4th level scope to identify `true` vs `false` since most people will only want to have one color assigned to these boolean constants.
This commit adds the `meta.string` scope as per the scope naming guidelines and also `set`(s) into named string contexts instead of anonymous contexts to enhance debugging experience since it's currently not possible to know the state of anonymous contexts in the `show_scope_name` popup. All the tests have been updated.
Lua 5.4 adds a new API endpoint for the `coruotine` library i.e. `close`. This commit adds support for it.
This commit excludes snippets from being triggered in comments & strings since they are least likely to be used in comments & strings anyways.
I'd just like to apologize for this. |
There was no need for apologizing at all. It's just something I noticed so decided to fix it. |
I believe I have addressed all of the review comments. Let me know if any of them are wrong or more corrections needs to be done. |
Thanks for the review. I have addressed both of the issues. |
Thanks for your fixes here @Ultra-Instinct-05! As always, thank you for the reviews @FichteFoll and @deathaxe! |
This commit adds `boolean` & `null` to the `constant.language` scope data. There were a few PR's regarding this. 1. sublimehq/Packages#2788 2. sublimehq/Packages#2785 3. sublimehq/Packages#2693
This commit adds `boolean` & `null` to the `constant.language` scope data. There were a few PR's regarding this. 1. sublimehq/Packages#2788 2. sublimehq/Packages#2785 3. sublimehq/Packages#2693
… and a couple improvements. (sublimehq#2693) * [Lua] Add support for `const` & to-be-closed variables. Lua 5.4 introduces the concept of `const` & to-be-closed variables. 1. A `const` variable is a variable whos value cannot be changed after initialization. The syntax is a bit weird, though. 2. A to-be-closed variable behaves like a constant local variable, except that its value is closed whenever the variable goes out of scope, including normal block termination, exiting its block by break/goto/return, or exiting by an error. (The definition is taken from the official Lua docs https://www.lua.org/manual/5.4/manual.html#3.3.8) * [Lua] Fix a mistake with scoping boolean language constant. Previously, the Lua syntax assigned a fourth level scope, true or false to identify between `true` & `false` (`false` again was wrongly scoped as `constant.language.boolean.true.lua`). I don't think it is really beneficial in having a 4th level scope to identify `true` vs `false` since most people will only want to have one color assigned to these boolean constants. * [Lua] Add `meta.string` scope and push|set to named contexts. This commit adds the `meta.string` scope as per the scope naming guidelines and also `set`(s) into named string contexts instead of anonymous contexts to enhance debugging experience since it's currently not possible to know the state of anonymous contexts in the `show_scope_name` popup. All the tests have been updated. * [Lua] Add support for `coroutine.close()`. Lua 5.4 adds a new API endpoint for the `coruotine` library i.e. `close`. This commit adds support for it. * [Lua] Exclude snippets from being triggered in comments & strings. This commit excludes snippets from being triggered in comments & strings since they are least likely to be used in comments & strings anyways.
This PR
true
vsfalse
i.e.constant.language.boolean.true
fortrue
&constant.language.boolean.true
forfalse
(which is anyways wrong). Now, it reduces it to onlyconstant.language.boolean
since there is very little value in having the previous scopes.meta.string
scope to strings to comply with the scope naming guidelines. I have also reworked the string contexts to actuallypush
orset
into named contexts instead of anonymous contexts for a better debugging experience (since it is currently not possible to distinguish between anonymous contexts in theshow_scope_name
popup).coroutine.close()
. Support is added for that function.