rokucommunity / brightscript-formatter

This project is no longer maintained. Its successor is brighterscript-formatter
https://github.com/RokuCommunity/brighterscript-formatter
Apache License 2.0
5 stars 5 forks source link

Allow case override #16

Closed triwav closed 5 years ago

triwav commented 5 years ago

Currently the only options for keywordCase are: "lower", "upper", "title", null. For the most part I like lower case but I like keeping the Object types as upper case. This is obviously a very individualistic thing so don't think the formatter should try to figure this out. I think the simple thing is in addition to: "brightscript.format.keywordCase": "lower"

we could add:

"brightscript.format.keywordCaseOverride": {
    "<TokenType>": "lower|upper|title"|null
}

with TokenType taken from here: https://github.com/TwitchBronBron/brightscript-parser/blob/master/src/BrightScriptLexer.ts#L160 so for my config I might put:

"brightscript.format.keywordCase": "lower",
"brightscript.format.keywordCaseOverride": {
    "string": "title",
    "float": "title",
    "double": "title",
    "object": "title"
}

This allows maximum flexibility for the user with a simple implantation in the formatter that doesn't require us making choices for the user. This is something I feel confident I could handle (probably with some help getting setup) but I wanted to get buy in that this seems like the right way to go before proceeding.

TwitchBronBron commented 5 years ago

I'm cool with this approach! Let me know if you run into any issues getting set up.

TwitchBronBron commented 5 years ago

brightscript-formatter@1.5.0 includes this fix.