typstfmt icon indicating copy to clipboard operation
typstfmt copied to clipboard

Allow setting config options with a typstfmt.toml file in the formatted file folder

Open pachi opened this issue 1 year ago • 2 comments

[ x] I have tested with the master version of typstfmt and not just typst-lsp

Describe the bug

typstfmt doesn't read a config file in the same folder as the formatted document.

To Reproduce Steps to reproduce the behavior:

I create a typstfmt.toml file to apply custom formatting options (for instance, line_wrap = false) alongside my document.typ file.

If I have the standalone CLI in the project folder this works perfectly as it reads its config from there. If I put the typstfmt executable in the parent dir of the project and retry then it ignores those settings.

So... it loads the settings if they're in the same folder as the executable itself, but it doesn't try to read (and use with preference) a config from the project dir (as I would expect).

There's an option to show the global config file, and it's located by default in a user settings folder, but this should be the default settings for that user to override the application default settings.

Proposed behaviour

IMHO, typstfmt should look for, in this order, 1) a config in the formatted document dir, then 2) in the user config dir (that's reported as global config path) then 3) a config besides the CLI and, finally, 3) the default settings.

pachi avatar Jan 16 '24 10:01 pachi