Compare commits

..

14 Commits

Author SHA1 Message Date
422bc1be2a
doc: refine quick start content
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-01 09:26:27 +01:00
83de5b485e
fix: devshell commands for docs
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-01 09:14:43 +01:00
6049472610
doc: fix docs package build
Vitepress cli does some funky stuff with the tty.

Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-04-30 12:47:33 +01:00
1e6a0ad963
doc: add some devshell helpers
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-04-29 15:44:45 +01:00
1b62b19f21
wip: add focs package
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-04-29 15:37:37 +01:00
b83c13852e
doc: move assets into public folder
Fixes issues with built version of the site

Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-04-29 14:46:53 +01:00
1aac5ffda8
doc: fix bad formatter spec link
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-04-29 14:42:01 +01:00
eaa5088eba
doc: add footer
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-04-29 14:40:36 +01:00
b5b616ceb6
doc: some initial experiments with colors
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-04-29 14:35:19 +01:00
8bfe968645
doc: remove features on home page
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-04-29 12:41:25 +01:00
bdd76f8c42
doc: update github link
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-04-29 12:33:53 +01:00
435abb9537
doc: port existing content
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-04-29 12:32:13 +01:00
40221a6d61
doc: configure hero and logo
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-04-29 12:02:29 +01:00
8d5cf63440
fix: nix filter for package
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-04-29 11:43:44 +01:00
4 changed files with 31 additions and 68 deletions

View File

@ -1,50 +1,32 @@
# About the project
`treefmt` is a formatting tool that saves you time: it provides developers with a universal way to trigger all
formatters needed for the project in one place.
`treefmt` is a formatting tool that saves you time: it provides developers with a universal way to trigger all formatters needed for the project in one place.
## Background
Typically, each project has its own code standards enforced by the project's owner. Any code contributions must match
that given standard, i.e. be formatted in a specific manner.
Typically, each project has its own code standards enforced by the project's owner. Any code contributions must match that given standard, i.e. be formatted in a specific manner.
At first glance, the task of code formatting may seem trivial: the formatter can be automatically triggered when you
save a file in your IDE. Indeed, formatting doesn't take much effort if you're working on a single project long term:
setting up the formatters in your IDE won't take much of your time, and then you're ready to go.
At first glance, the task of code formatting may seem trivial: the formatter can be automatically triggered when you save a file in your IDE. Indeed, formatting doesn't take much effort if you're working on a single project long term: setting up the formatters in your IDE won't take much of your time, and then you're ready to go.
Contrary to that, if you're working on multiple projects at the same time, you may have to update your formatter
configs in the IDE each time you switch between the projects. This is because formatter settings aren't
project-specific --- they are set up globally for all projects.
Contrary to that, if you're working on multiple projects at the same time, you may have to update your formatter configs in the IDE each time you switch between the projects. This is because formatter settings aren't project-specific --- they are set up globally for all projects.
Alternatively, you can trigger formatters manually, one-by-one or in a script. Actually, for bigger projects, it's
common to have a script that runs over your project's directories and calls formatters consequently. But it takes time
to iterate through all the files.
Alternatively, you can trigger formatters manually, one-by-one or in a script. Actually, for bigger projects, it's common to have a script that runs over your project's directories and calls formatters consequently. But it takes time to iterate through all the files.
All the solutions take up a significant amount of time which a developer could spend doing the actual work. They also
require you to remember which formatters and options are used by each project you are working on.
All the solutions take up a significant amount of time which a developer could spend doing the actual work. They also require you to remember which formatters and options are used by each project you are working on.
`treefmt` solves these issues.
## Why treefmt?
`treefmt`'s configuration is project-specific, so you don't need to re-configure formatters each time you switch
between projects, like you have to when working with formatters in the IDE.
`treefmt`'s configuration is project-specific, so you don't need to re-configure formatters each time you switch between projects, like you have to when working with formatters in the IDE.
Contrary to calling formatters from the command line, there's no need to remember all the specific formatters required
for each project. Once you set up the config, you can run the tool in any of your project's folders without any
additional flags or options.
Contrary to calling formatters from the command line, there's no need to remember all the specific formatters required for each project. Once you set up the config, you can run the tool in any of your project's folders without any additional flags or options.
Typically, formatters have different ways to say there was a specific error. With `treefmt`, you get a standardized
output which is easier to understand than the variegated outputs of different formatters, so it takes less time to
grasp what's wrong.
Typically, formatters have different ways to say there was a specific error. With `treefmt`, you get a standardized output which is easier to understand than the variegated outputs of different formatters, so it takes less time to grasp what's wrong.
In addition, `treefmt` works faster than the custom script solution because the changed files are cached and the
formatters run only against them. Moreover, formatters are run in parallel, which makes the tool even faster.
In addition, `treefmt` works faster than the custom script solution because the changed files are cached and the formatters run only against them. Moreover, formatters are run in parallel, which makes the tool even faster.
The difference may not be significant for smaller projects, but it gets quite visible as the project grows. For
instance, take the caching optimization.
It takes 9 seconds to traverse a project of 1507 files and no changes without caching:
The difference may not be significant for smaller projects, but it gets quite visible as the project grows. For instance, take the caching optimization. It takes 9 seconds to traverse a project of 1507 files and no changes without caching:
```
traversed 1507 files

View File

@ -208,16 +208,15 @@
]
},
"locked": {
"lastModified": 1714382886,
"narHash": "sha256-+gooxbbYcP+MORKQ7W/C2ATvlonW+dyHgCUPnu5dfco=",
"owner": "brianmcgee",
"lastModified": 1707300477,
"narHash": "sha256-qQF0fEkHlnxHcrKIMRzOETnRBksUK048MXkX0SOmxvA=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "535e6904c34964ce56d8c092835c11fe6341acc8",
"rev": "ac599dab59a66304eb511af07b3883114f061b9d",
"type": "github"
},
"original": {
"owner": "brianmcgee",
"ref": "feat/pipelines",
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}

View File

@ -7,8 +7,7 @@
flake-parts.url = "github:hercules-ci/flake-parts";
flake-root.url = "github:srid/flake-root";
treefmt-nix = {
# todo switch back to numtide/treefmt-nix once merged
url = "github:brianmcgee/treefmt-nix/feat/pipelines";
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
devshell = {

View File

@ -22,37 +22,20 @@
statix.enable = true;
};
settings.formatter = {
deadnix = {
pipeline = "nix";
priority = 1;
};
statix = {
pipeline = "nix";
priority = 2;
};
alejandra = {
pipeline = "nix";
priority = 3;
};
prettier = {
options = ["--tab-width" "4"];
includes = [
"*.css"
"*.html"
"*.js"
"*.json"
"*.jsx"
"*.md"
"*.mdx"
"*.scss"
"*.ts"
"*.yaml"
];
};
settings.formatter.prettier = {
options = ["--tab-width" "4"];
includes = [
"*.css"
"*.html"
"*.js"
"*.json"
"*.jsx"
"*.md"
"*.mdx"
"*.scss"
"*.ts"
"*.yaml"
];
};
};