-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
Allow for saving arguments in a config file #354
Comments
This seems like a good idea but I personally don't have any aspirations of pursuing this. ff.bat: So when I format from a prompt I do As for editors, both Rider and vscode have a settings section already available. So I'm not entirely convinced that we should introduce a |
@nojaf do we want to do this or not? If so, I wouldn't mind submitting a PR to get my feet wet into the repo |
@prosconi I would like to see a more fleshed out suggested approach for this feature first. |
I was thinking the format would be JSON. As far as where the file lives, that is a tricky one since there are a lot of ways to invoke fantomas
|
I am in favor of this. Agree with format JSON, maybe some auto (de)serializing library will be best. Anyway, it should be fail-safe, missing field in config file should be replaced by default option, and extra field (option that not exist in Fantomas) should not break loading of config (but it should emit some warning on stdout). Regarding location of config file, I would prefer unified behavior, where config file is applied to whole subdirectory - so we will look for config file in target dir and in all parent dirs. API should not look for config file, but we could make API for load config from file. AFAIK all API calls take config as explicit parameter. |
Hello, I saw this issue poping on twitter and read the thread.
This description looks really similar to what I am doing for Nacara config file where I am using
It's easy to map missing field via
type Config =
{ NpmURL : string option
GithubURL : string option
Url : string
BaseUrl : string
Title : string
Version : string
Source : string
Output : string
IsDebug : bool
Changelog : string option
Navbar : NavbarConfig option
MenuConfig : MenuConfig option
LightnerConfig : LightnerConfig option }
static member Decoder =
Decode.object (fun get ->
{ NpmURL = get.Optional.Field "npmURL" Decode.string
GithubURL = get.Optional.Field "githubURL" Decode.string
Url = get.Required.Field "url" Decode.string
BaseUrl = get.Required.Field "baseUrl" Decode.string
Title = get.Required.Field "title" Decode.string
Version = get.Required.Field "version" Decode.string
Source = get.Optional.Field "source" Decode.string
|> Option.defaultValue "docsrc"
Output = get.Optional.Field "output" Decode.string
|> Option.defaultValue "docs"
IsDebug = get.Optional.Field "debug" Decode.bool
|> Option.defaultValue false
Changelog = get.Optional.Field "changelog" Decode.string
Navbar = get.Optional.Field "navbar" NavbarConfig.Decoder
MenuConfig = get.Optional.Field "menu" menuConfigDecoder
LightnerConfig = get.Optional.Field "lightner" LightnerConfig.Decoder }
) |
Hey, we would need that for FSAC/Ionide - instead of “polluting” Ionide’s setting with all Fantomas setting and keeping them in sync regarding new options and default settings I’d rather have users use Fantomas specific config file maintained here. In regards of where to place file I think we may try to replicate FSharpLint behavior (consistency in ecosystem) - read more in Configuration Files section on http://fsprojects.github.io/FSharpLint/ From the API perspective I guess all we’d need is a function that will read config file for given location and return Fantomas’ config object |
I'll take a shot at this during the holidays. I'm not a fan of using the JSON format as I don't want the dependency to NewtonSoft.Json or anything else. For example:
Maybe logic from Fantomas-UI can be re-used. |
Fantomas should allow for inputting formatting arguments via a config file, like
.fantomas-config
. This config file could be located by convention or by an explicit CLI flag. Having such a file would allow for settings to be tracked in source control, applied without the user having to remember many cli flags, and make it easier to run formatting via shell utilities, FAKE, various editor toolings, etc.The text was updated successfully, but these errors were encountered: