From 0b0d4cb98240451296f901bbceb900308362f702 Mon Sep 17 00:00:00 2001 From: Rob Loranger Date: Thu, 19 Oct 2023 17:39:57 -0700 Subject: [PATCH 1/3] add formatting doc and pre-commit --- CONTRIBUTING.md | 30 ++++++++++++++++++++++++++++++ pre-commit | 3 +++ 2 files changed, 33 insertions(+) create mode 100644 CONTRIBUTING.md create mode 100755 pre-commit diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..9a080f8 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,30 @@ +# Contribution Guidelines + +## Code Formatting + +We format all Rust code using edition 2021 rules. This edition is defined in our Cargo.toml and most methods below will pick this up automatically. + +### Manual Method + +The most editor agnostic way to format your Rust code is by manually running cargo's fmt sub command. + +To check if your code is formatted without making changes, run `cargo fmt --check`. Then if you want to format your code you can run just `cargo fmt`. + +### VScode + +We recommend the meta extension Rust, which includes rust-analyzer. Then to set your editor to format on save: + +* In Visual Studio Code, press Control + Shift + P or Command + Shift + P (Mac) to open the command palette and type setting and then select Preferences: Open User Settings option. +* Search for format on save setting and check the checkbox. + +You can also set language specific settings as outlined [here](https://code.visualstudio.com/docs/getstarted/settings#_language-specific-editor-settings). You will again want to then search for format on save and check the checkbox. + +### Other Editors + +You will first need to [install rust-analyzer](https://rust-analyzer.github.io/manual.html#installation), then configure your editor and install any needed plugins or extensions as outlined on that page. + +### Pre Commit Hook + +If you want to think about formatting your code less and just have git yell at you whe you try to commit code that is not properly formatted, you can use a simple pre-commit hook. + +After cloning the repo, the file `pre-commit-hook` to `.git/hooks/pre-commit`. That's it. \ No newline at end of file diff --git a/pre-commit b/pre-commit new file mode 100755 index 0000000..07f61e9 --- /dev/null +++ b/pre-commit @@ -0,0 +1,3 @@ +#!/bin/bash + +cargo fmt --check -- 2.30.2 From acfec3b97edbe1dfca6ba482ee023513f0f927a2 Mon Sep 17 00:00:00 2001 From: Rob Loranger Date: Thu, 19 Oct 2023 17:44:01 -0700 Subject: [PATCH 2/3] fix pre-commit filename typo --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9a080f8..f2500a8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,4 +27,4 @@ You will first need to [install rust-analyzer](https://rust-analyzer.github.io/m If you want to think about formatting your code less and just have git yell at you whe you try to commit code that is not properly formatted, you can use a simple pre-commit hook. -After cloning the repo, the file `pre-commit-hook` to `.git/hooks/pre-commit`. That's it. \ No newline at end of file +After cloning the repo, the file `pre-commit` to `.git/hooks/pre-commit`. That's it. \ No newline at end of file -- 2.30.2 From 136da63d0088ced5effdb0b37953899ec2d8e5a9 Mon Sep 17 00:00:00 2001 From: Rob Loranger Date: Sat, 21 Oct 2023 16:25:16 -0700 Subject: [PATCH 3/3] Fix typo and add rust market links Adds links to the rust meta extension and the VScode rust page --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f2500a8..7d318da 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,7 @@ To check if your code is formatted without making changes, run `cargo fmt --chec ### VScode -We recommend the meta extension Rust, which includes rust-analyzer. Then to set your editor to format on save: +We recommend the meta extension [Rust Bundle](https://marketplace.visualstudio.com/items?itemName=1YiB.rust-bundle) , which includes rust-analyzer. ([More info](https://code.visualstudio.com/docs/languages/rust) on Rust with VScode) Then to set your editor to format on save: * In Visual Studio Code, press Control + Shift + P or Command + Shift + P (Mac) to open the command palette and type setting and then select Preferences: Open User Settings option. * Search for format on save setting and check the checkbox. @@ -27,4 +27,4 @@ You will first need to [install rust-analyzer](https://rust-analyzer.github.io/m If you want to think about formatting your code less and just have git yell at you whe you try to commit code that is not properly formatted, you can use a simple pre-commit hook. -After cloning the repo, the file `pre-commit` to `.git/hooks/pre-commit`. That's it. \ No newline at end of file +After cloning the repo, move the file `pre-commit` to `.git/hooks/pre-commit`. That's it. \ No newline at end of file -- 2.30.2