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

Where are .JuliaFormatter.toml files searched for? #3560

Open
simsurace opened this issue Mar 6, 2024 · 10 comments
Open

Where are .JuliaFormatter.toml files searched for? #3560

simsurace opened this issue Mar 6, 2024 · 10 comments

Comments

@simsurace
Copy link

The docs are slightly unclear about this. They say in the workspace but what if there are several folders? I do have a repo with a toml file in one of my workspaces but the style is not respected --- formatting instead is done with the default very light setting.

@IanButterworth
Copy link

See domluna/JuliaFormatter.jl#771 for a pain point

@pfitzseb
Copy link
Member

pfitzseb commented Mar 7, 2024

They say in the workspace but what if there are several folders?

In any workspace. Basically, if you can open the file from the file explorer in VS Code, we should be able to pick find it.

@IanButterworth
Copy link

IanButterworth commented Mar 7, 2024

I'm not sure I understand the rationale for the current design. AFAIU .JuliaFormatter.toml files are for specifying directory-specific formatting rules, so why would vscode not respect that?

Is it just that it's expected that people only have one folder (repo) open per workspace? I generally have many open.

@simsurace
Copy link
Author

IIUC workspace is the top level in the VSCode explorer. If I have multiple folders open, does the extension look for the TOML in the same folder first?

@pfitzseb
Copy link
Member

pfitzseb commented Mar 7, 2024

It doesn't matter how many workspace folders you have open. We're following the same behaviour as JuliaFormatter, except for never looking at the global config and not veering outside the bounds of the directory you have opened in VS Code (so the theoretically obvious way for adding a global config by creating a /.JuliaFormatter.toml also doesn't work).

The main motivation for that is that all format options need to be inside of your repo for reproducibility (otherwise formatting ends up flipflopping between N different configs). That's a decision we (I?) made a couple years back, but certainly nothing we couldn't revisit.

@IanButterworth
Copy link

not veering outside the bounds of the directory you have opened in VS Code

What if you have multiple directories open?

To be concrete, say I have these folders open in a single workspace:

  • julia
  • MyFoo

where julia doesn't use JuliaFormatter, so formatting on save isn't wanted, but MyFoo does, so formatting on save is wanted.

Currently the system doesn't accommodate this, as far as I know?

@IanButterworth
Copy link

To clarify, what I mean is that say julia had a .JuliaFormatter that disabled JuliaFormatter (which is what I've considered adding to julia)

@pfitzseb
Copy link
Member

pfitzseb commented Mar 7, 2024

We're always searching up from the current file's path, IIRC. So in both cases you should get the appropriate config. If not, then that's a bug

@IanButterworth
Copy link

I confirm the bug then.

Saving .JuliaFormatter.toml in the root of the julia repo with

ignore = [""]

then saving say base/loading.jl will format that file.

@iago-lito
Copy link

iago-lito commented Mar 8, 2024

I'm not sure I exactly confirm this, but since this issue was opened yesterday, I think it's the right place/time to report that julia formatter seems to have stopped respecting the .JuliaFormatter.toml sitting next to my Project.toml at the root of my package folder.. this week. (using native neovim lsp client)
Has anything changed recently regarding this?

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

4 participants