You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In other words, null-ls expects formatters to obey treefmt's formatter specification. (On a related note, I've tried to clarify this here: #434). I'd argue that treefmt itself doesn't follow its own formatter specification, because it won't format untracked tempfiles.
(I am aware of treefmt's --walk=filesystem parameter, but that would require my null-ls plugin to somehow know that it's invoking treefmt, when all it really knows is that it's invoking nix fmt.)
Expected behavior
I'd like for treefmt's default behavior to be to format files passed explicitly on the command line, even if those files are not tracked by git. If folders are passed, or if --walk=git is used, it's fine to apply the normal filesystem walking rules.
The text was updated successfully, but these errors were encountered:
Changes how we handle paths which are provided as arguments:
- if it's a file, we attempt to format it based on the matching options
- if it's a directory, we traverse it using the provided walk type
This is more consistent with what a user expects and makes it easier to integrate with tools such as `none-ls`.
Close#435
Thanks, @brianmcgee! Unfortunately, it turns out that none-ls passes absolute paths to the formatter, which doesn't seem to work. I filed #442 and put out #445 with a fix.
Context
I believe treefmt 1.x was totally ignorant of VCS/git, and would happily format all files it could find (including stuff the
.git
directory!).It's great that treefmt 2+ doesn't do this: it's default filesystem walker ("auto") detects when we're in a git repo and ignores untracked files.
Describe the bug
The problem is that treefmt no longer formats files that are explicitly passed as arguments.
This breaks my "generic nix fmt" formatter I wrote for null-ls/none-ls. See https://github.com/jfly/snow/blob/835b3765b2fa18768ccebb474b292c061ba47752/pkgs/neovim/vimrc#L332-L342. Much like treefmt itself, under the hood, null-ls generates tempfiles and passes them as command line parameters to the formatter. It expects the formatter to format these files, even though they're not tracked by git.
In other words, null-ls expects formatters to obey treefmt's formatter specification. (On a related note, I've tried to clarify this here: #434). I'd argue that treefmt itself doesn't follow its own formatter specification, because it won't format untracked tempfiles.
(I am aware of treefmt's
--walk=filesystem
parameter, but that would require my null-ls plugin to somehow know that it's invoking treefmt, when all it really knows is that it's invokingnix fmt
.)Expected behavior
I'd like for treefmt's default behavior to be to format files passed explicitly on the command line, even if those files are not tracked by git. If folders are passed, or if
--walk=git
is used, it's fine to apply the normal filesystem walking rules.The text was updated successfully, but these errors were encountered: