diff --git a/flake.nix b/flake.nix index 8cba76d..2beb96e 100644 --- a/flake.nix +++ b/flake.nix @@ -384,6 +384,7 @@ artiqpkgs.artiq artiqpkgs.vivado binutils-arm + pre-commit ]; XARGO_RUST_SRC = "${rust}/lib/rustlib/src/rust/library"; CLANG_EXTRA_INCLUDE_DIR = "${llvmPackages_11.clang-unwrapped.lib}/lib/clang/11.1.0/include"; diff --git a/src/.clang-format b/src/.clang-format new file mode 100644 index 0000000..9fc7f42 --- /dev/null +++ b/src/.clang-format @@ -0,0 +1,32 @@ +BasedOnStyle: LLVM + +Language: Cpp +Standard: Cpp11 + +AccessModifierOffset: -1 +AlignEscapedNewlines: Left +AlwaysBreakAfterReturnType: None +AlwaysBreakTemplateDeclarations: Yes +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortFunctionsOnASingleLine: Inline +BinPackParameters: false +BreakBeforeBinaryOperators: NonAssignment +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: AfterColon +BreakInheritanceList: AfterColon +ColumnLimit: 120 +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ContinuationIndentWidth: 4 +DerivePointerAlignment: false +IndentCaseLabels: true +IndentPPDirectives: None +IndentWidth: 4 +MaxEmptyLinesToKeep: 1 +PointerAlignment: Left +ReflowComments: true +SortIncludes: false +SortUsingDeclarations: true +SpaceAfterTemplateKeyword: false +SpacesBeforeTrailingComments: 2 +TabWidth: 4 +UseTab: Never diff --git a/src/.clippy.toml b/src/.clippy.toml new file mode 100644 index 0000000..434d402 --- /dev/null +++ b/src/.clippy.toml @@ -0,0 +1 @@ +doc-valid-idents = ["CPython", "NumPy", ".."] \ No newline at end of file diff --git a/src/.pre-commit-config.yaml b/src/.pre-commit-config.yaml new file mode 100644 index 0000000..1d37807 --- /dev/null +++ b/src/.pre-commit-config.yaml @@ -0,0 +1,24 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks + +default_stages: [commit] + +repos: + - repo: local + hooks: + - id: nac3-cargo-fmt + name: nac3 cargo format + entry: nix + language: system + types: [file, rust] + pass_filenames: false + description: Runs cargo fmt on the codebase. + args: [develop, -c, cargo, fmt, --all] + - id: nac3-cargo-clippy + name: nac3 cargo clippy + entry: nix + language: system + types: [file, rust] + pass_filenames: false + description: Runs cargo clippy on the codebase. + args: [develop, -c, cargo, clippy, --tests]