Skip to content
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

Auto-indentation rules #144

Open
ghost opened this issue Aug 24, 2023 · 4 comments
Open

Auto-indentation rules #144

ghost opened this issue Aug 24, 2023 · 4 comments

Comments

@ghost
Copy link

ghost commented Aug 24, 2023

I've noticed that currently there isn't any auto-indentation rules for Sugarcube 2 at least. Unless I'm wrong and they're in one of the configuration files. I was thinking just for the built in macros that Sugarcube has for now. Since you can add your own, I have my own that I've added in there but I'm not much of regex wizard so the indentation rules are pretty janky but the decrease rules seem to work fairly well.

"indentationRules": { "increaseIndentPattern": "^\\s*<<(capture.*|type.*|if.*|elseif.*|else|for.*|switch.*|button.*|cycle.*|link.*|linkappend.*|linkprepend.*|listbox.*|prepend.*|replace.*|createaudiogroup.*|createplaylist.*|done.*|repeat.*|timed.*|widget.*)>>.*$", "decreaseIndentPattern": "^\\s*<<(\\/.*|elseif|else)>>.*$" },

This is what I have going on so far, I kept matching other non-indentation macros. Which is why the first part is so bad but think this would be a good addition to this awesome extension.

Thanks,
Dz

@Tranberry
Copy link
Contributor

the AI wants to add (?!\\w) to link like so: cycle.*|link(?!\\w).*|linkappend.*.

I wonder if it's dizzy or actually on to something. I mean would VS Code really add multiple indentations due to matching with link and linkappend and linkprepeand? I figure it is dizzy but still worth a thought.

It's also saying that elseif and else should be covered by the <<\\/.*>> pattern but I figured you had to add it while testing.

@ghost
Copy link
Author

ghost commented Aug 24, 2023

the AI wants to add (?!\\w) to link like so: cycle.*|link(?!\\w).*|linkappend.*.

I wonder if it's dizzy or actually on to something. I mean would VS Code really add multiple indentations due to matching with link and linkappend and linkprepeand? I figure it is dizzy but still worth a thought.

It's also saying that elseif and else should be covered by the <<\\/.*>> pattern but I figured you had to add it while testing.

<<\\/.*>> Shouldn't be matching elseif and else. It should just match any macro that closes with / like <</if>>. Know that in the language-configuration file you have to escape a lot of the \ characters for it to be parsed by VSCode. So not sure if the AI is reading the extra \ characters that normal regex usually doesn't need.

Also my regex doesn't account for 1 liners and oops, wrong button when replying.

@ghost ghost closed this as completed Aug 24, 2023
@ghost ghost reopened this Aug 24, 2023
@cyrusfirheir
Copy link
Owner

cyrusfirheir commented Aug 24, 2023

Indentation rules require more investigation. Single regular expressions don't handle all edge cases properly.

Meanwhile, v0.22.0 adds OnEnterRules for SC-2. It will use custom definitions from config files alongside the built-in macro list to indent inside container macros. Hopefully, that is helpful.

Besides, #118 has always been on the todo-list.

@ghost
Copy link
Author

ghost commented Aug 25, 2023

Oh I missed that issue but I'll give the 0.22.0 version a go and if some of them work then I'm good.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants