doc: refine installation

Signed-off-by: Brian McGee <brian@bmcgee.ie>
This commit is contained in:
Brian McGee 2024-05-01 14:20:32 +01:00
parent 6070b6f6e4
commit 8e840a9a96
Signed by: brianmcgee
GPG Key ID: D49016E76AD1E8C0
2 changed files with 17 additions and 10 deletions

View File

@ -16,6 +16,7 @@ export default defineConfig({
sidebar: [
{ text: 'Quick Start', link: '/quick-start' },
{ text: 'Installation', link: '/installation' },
{ text: 'Overview', link: '/overview' },
{ text: 'Usage', link: '/usage' },
{ text: 'Formatter Specification', link: '/formatter-spec' },

View File

@ -4,7 +4,10 @@ outline: deep
# Installation
There are two options to install `treefmt`: by downloading the latest binary, or by compiling and building the tool from source.
There are two options to install `treefmt`:
1. Downloading the latest binary
2. Compiling and building it from source.
## Installing with a binary file
@ -12,31 +15,34 @@ You can find the list of the latest binaries [here](https://github.com/numtide/t
## Building from source
There are several ways to build `treefmt` from source. Your choice will depend on whether you're a [nix](https://github.com/NixOS/nix) user.
There are several ways to build `treefmt` from source. Your choice will depend on whether you're a [nix](https://github.com/NixOS/nix) user or
not.
### Non-Nix User
To try the project without building it, run:
```
$ cargo run -- --help
$ go run main.go --help
```
The command will output the manual. You can run the tool in this manner with any other flag or option to format your project.
The command will output the manual. You can run the tool in this manner with any other flag or option to format your
project.
To build a binary, you need to have rust installed. You can install it with [rustup](https://rustup.rs/). Now, if you want to build the project, switch to the project root folder and run:
To build a binary, you need to have `go 1.22` installed. You can find instructions [here](https://go.dev/doc/install).
Now, if you want to build the project, switch to the project root folder and run:
```
$ cargo build
$ go build
```
After the successful execution of the cargo build command, you will find the `treefmt` binary in the target folder.
After the successful execution of the build command, you will find the `treefmt` binary in the project root folder.
### Nix User
[Nix](https://github.com/NixOS/nix) is a package manager foundational for NixOS. You can use it in NixOS and in any other OS equally.
If you're using both `treefmt` and `nix`, you can go for [`treefmt-nix`](https://github.com/numtide/treefmt-nix), a special tool that makes installation and configuration of `treefmt` with `nix` easier.
If you're using both `treefmt` and `nix`, you can go for [`treefmt-nix`](https://github.com/numtide/treefmt-nix), a wrapper that makes installation and
configuration of `treefmt` with `nix` easier.
**Non-flake user**