Skip to content

Commit

Permalink
Merge pull request #390 from phip1611/cmake-format
Browse files Browse the repository at this point in the history
hooks: init cmake-format
  • Loading branch information
domenkozar authored Jan 12, 2024
2 parents e944c85 + 59ed918 commit 274ae39
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,21 @@ use nix
- [mkdocs-linkcheck](https://github.com/byrnereese/linkchecker-mkdocs)
- [headache](https://github.com/frama-c/headache)
- [crystal](https://crystal-lang.org/reference/man/crystal#crystal-tool-format)
- [cmake-format](https://cmake-format.readthedocs.io/en/latest/)

You must configure which languages should be formatted by `clang_format` using
`clang-format.types_or`. For example to check both C and C++ files:
You may restrict which languages should be formatted by `clang-format` using
`clang-format.types_or`. For example to check only C and C++ files:

```nix
clang-format = {
enable = true;
types_or = [ "c" "c++" ];
types_or = lib.mkForce [ "c" "c++" ];
};
```

Otherwise, the default internal list is used which includes everything that
clang-format supports.

## Git

- [commitizen](https://github.com/commitizen-tools/commitizen)
Expand Down
24 changes: 24 additions & 0 deletions modules/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ in
default = false;
};
};
cmake-format =
{
configPath = mkOption {
type = types.str;
description = lib.mdDoc "Path to the configuration file (.json,.python,.yaml)";
default = "";
example = ".cmake-format.json";
};
};
credo = {
strict =
mkOption {
Expand Down Expand Up @@ -1367,6 +1376,21 @@ in
entry = "${tools.cljfmt}/bin/cljfmt fix";
types_or = [ "clojure" "clojurescript" "edn" ];
};
cmake-format =
{
name = "cmake-format";
description = "A tool for formatting CMake-files.";
entry =
let
maybeConfigPath =
if settings.cmake-format.configPath == ""
# Searches automatically for the config path.
then ""
else "-C ${settings.cmake-format.configPath}";
in
"${tools.cmake-format}/bin/cmake-format --check ${maybeConfigPath}";
files = "\\.cmake$|CMakeLists.txt";
};
commitizen =
{
name = "commitizen check";
Expand Down

0 comments on commit 274ae39

Please sign in to comment.