finale-lua / lua-scripts

A central repository for all Lua scripts for Finale.
https://finalelua.com
Creative Commons Zero v1.0 Universal
15 stars 14 forks source link

Improve automatic formatting #168

Open Nick-Mazuk opened 2 years ago

Nick-Mazuk commented 2 years ago

Creating a new issue based on a conversation in #167. Here's the original message by @ThistleSifter:


I didn't run into any issues setting it up, but I have noticed that occasionally the style fixer does odd things.

Eg The comment in line 242 in mixin/FCMCtrlListBox.lua applies to the else below, so it should only be indented once, not twice.

I'm not a fan of some of the line splitting, although I understand that these boil down to personal preference so I'm not going to quibble about it:

Originally posted by @ThistleSifter in https://github.com/finale-lua/lua-scripts/issues/167#issuecomment-1114501284

Nick-Mazuk commented 2 years ago

@rpatters1's reply:


I tend to agree with @ThistleSifter that I don't like the forced line splitting. In fact, I continue to do most of my editing in ZeroBrane because of the debugging. But it also allows me to fix lint issues found by VSCode without having to take the line splitting on board.

Nick-Mazuk commented 2 years ago

Yeah, this isn't the greatest formatter out there. I think having consistent, automatic formatting is more important than good formatting, but I'm totally open to improving the automated formatting.

Feel free to change the format config at https://github.com/finale-lua/lua-scripts/blob/master/luaconfig.config to something that looks better. Or if you find a better formatter that works with VS Code, we can switch to that.

Though any changes in that formatter should go in a separate PR so we can also reformat the entire repo in that PR. And if/when such a PR is created, we should merge it quickly to reduce merge conflicts with future PRs.

rpatters1 commented 2 years ago

I'm going to piggyback this issue to mention that every time I launch Code it prompts me with some options about the "OpenResty" workspace, none of which is the one I want: to shut and go away for good. I have no idea what's going on, but if I allow it to modify my settings it switches me to LuaJIT, among other things.

Nick-Mazuk commented 2 years ago

Interesting. Is that every time you launch this repo, the /src folder of the repo, or every time you launch VS Code in general?

rpatters1 commented 2 years ago

It's only when I open /src. Maybe it is something to do with the Lua Debugger extension (which I loaded again but still can't get to work.) I currently have

I'm thinking one of those last two may be detritus from trying to get the formatting working. One of them is also what needs the "lua.targetVersion": "5.2" setting.

Nick-Mazuk commented 2 years ago

I don't have these extensions:

The other two I have.

I actually don't personally use debuggers at all, so I'm not sure if it is the debugger or how to help you get the debugger working.

ThistleSifter commented 2 years ago

I'd be okay with removing the limit on line length. Other than that, I don't have any major issues with the formatter.

rpatters1 commented 2 years ago

I concur with removing the limit on line length. The other formatting preferences are fine.

Nick-Mazuk commented 2 years ago

I'm fine with that. I'm not sure if there's a way to disable the line length feature, but you can set it to 9999. I'll approve any PRs changing this.

rpatters1 commented 2 years ago

Does anyone know how to turn off line formatting completely? I expanded the line length to a huge number, but now I can't break of the lines manually.

Nick-Mazuk commented 2 years ago

It looks like you potentially can't turn it off. The code ensures the value exists and that it's an integer. I also tried using -1, but that seemed to disable formatting altogether, not just the line length.

https://github.com/Koihik/LuaFormatter/blob/0ef3575f3695b6553eaede2f7bd6a493ff0c520c/src/Config.cpp#L134

That's unfortunate.

ThistleSifter commented 2 years ago

I guess all we can do is hope that respecting manual line breaks is added someday: https://github.com/Koihik/LuaFormatter/issues/240