Compare commits

..

18 Commits

Author SHA1 Message Date
fe3333eaa1
wip
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-01 11:25:36 +01:00
5a72d99669
doc: refine quick start content
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-01 11:25:35 +01:00
b8824641c8
fix: devshell commands for docs
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-01 11:25:35 +01:00
e5905fc091
doc: fix docs package build
Vitepress cli does some funky stuff with the tty.

Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-01 11:25:35 +01:00
0d8d8fbbd1
doc: add some devshell helpers
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-01 11:25:35 +01:00
928650565b
wip: add focs package
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-01 11:25:35 +01:00
3d65d6d61a
doc: move assets into public folder
Fixes issues with built version of the site

Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-01 11:25:35 +01:00
6bdfb8b000
doc: fix bad formatter spec link
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-01 11:25:35 +01:00
b702d90cad
doc: add footer
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-01 11:25:34 +01:00
5175d34837
doc: some initial experiments with colors
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-01 11:25:34 +01:00
a5f347c0e5
doc: remove features on home page
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-01 11:25:34 +01:00
cc2b0f618b
doc: update github link
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-01 11:25:34 +01:00
e09573ba32
doc: port existing content
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-01 11:25:34 +01:00
d8214c5a91
doc: configure hero and logo
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-01 11:25:34 +01:00
2ef5caebc8
fix: nix filter for package
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-01 11:25:33 +01:00
d3cdb698e4 Merge pull request 'feat/configure-treefmt-pipeline' (#32) from feat/configure-treefmt-pipeline into main
Reviewed-on: #32
2024-05-01 10:20:10 +00:00
757d5e746a
feat: configure a pipeline for formatting nix code
Relies on a fork of treefmt-nix until it can be merged.

Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-01 09:12:01 +01:00
3000c65ead
fix: nix-filter config for package
Signed-off-by: Brian McGee <brian@bmcgee.ie>
2024-05-01 09:11:27 +01:00
4 changed files with 68 additions and 31 deletions

View File

@ -1,32 +1,50 @@
# 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,15 +208,16 @@
]
},
"locked": {
"lastModified": 1707300477,
"narHash": "sha256-qQF0fEkHlnxHcrKIMRzOETnRBksUK048MXkX0SOmxvA=",
"owner": "numtide",
"lastModified": 1714382886,
"narHash": "sha256-+gooxbbYcP+MORKQ7W/C2ATvlonW+dyHgCUPnu5dfco=",
"owner": "brianmcgee",
"repo": "treefmt-nix",
"rev": "ac599dab59a66304eb511af07b3883114f061b9d",
"rev": "535e6904c34964ce56d8c092835c11fe6341acc8",
"type": "github"
},
"original": {
"owner": "numtide",
"owner": "brianmcgee",
"ref": "feat/pipelines",
"repo": "treefmt-nix",
"type": "github"
}

View File

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

View File

@ -22,20 +22,37 @@
statix.enable = true;
};
settings.formatter.prettier = {
options = ["--tab-width" "4"];
includes = [
"*.css"
"*.html"
"*.js"
"*.json"
"*.jsx"
"*.md"
"*.mdx"
"*.scss"
"*.ts"
"*.yaml"
];
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"
];
};
};
};