dblume commited on 2024-03-21 08:57:40
Showing 1 changed files, with 7 additions and 8 deletions.
This way: wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh sudo ./llvm.sh 17 sudo apt install clang-format-17 Requires you to specify binary clang-format-17 sometimes.
... | ... |
@@ -67,12 +67,11 @@ Use clang-format. Install the distro's version with: |
67 | 67 |
|
68 | 68 |
sudo apt install clang-format |
69 | 69 |
|
70 |
-Or install a newer one (replace 17 with whatever's current now) with: |
|
70 |
+Or install a newer one with: |
|
71 | 71 |
|
72 |
- wget https://apt.llvm.org/llvm.sh |
|
73 |
- chmod +x llvm.sh |
|
74 |
- sudo ./llvm.sh 17 |
|
75 |
- sudo apt install clang-format-17 |
|
72 |
+ pipx install clang-format |
|
73 |
+ |
|
74 |
+And move $HOME/.local/bin ahead of /usr/bin in your $PATH. |
|
76 | 75 |
|
77 | 76 |
Then, after making your edits, use the [vim integration](https://clang.llvm.org/docs/ClangFormat.html#vim-integration) |
78 | 77 |
or manually format in one of a couple of ways: |
... | ... |
@@ -83,18 +82,18 @@ or manually format in one of a couple of ways: |
83 | 82 |
into the unstaged area. |
84 | 83 |
|
85 | 84 |
1. Stage the files you want to format. |
86 |
-2. Run `git-clang-format --binary=clang-format-17 --style=file`, and it'll leave unstaged formatting changes. |
|
85 |
+2. Run `git-clang-format --style=file`, and it'll leave unstaged formatting changes. |
|
87 | 86 |
3. Review with `git difftool` and accept the desired changes or unstage. |
88 | 87 |
|
89 | 88 |
### Manually clang-format |
90 | 89 |
|
91 | 90 |
git status --porcelain | \ |
92 | 91 |
awk 'match($1, "M|A") && match($2, "(c|h)(pp)?$"){print $2}' | \ |
93 |
- xargs clang-format-17 -style=file -i |
|
92 |
+ xargs clang-format -style=file -i |
|
94 | 93 |
|
95 | 94 |
Or, shorter but less comprehensive: |
96 | 95 |
|
97 |
- git ls-files -m | egrep ".(c|h)(pp)?$" | xargs clang-format-17 -style=file -i |
|
96 |
+ git ls-files -m | egrep ".(c|h)(pp)?$" | xargs clang-format -style=file -i |
|
98 | 97 |
|
99 | 98 |
## Current Features |
100 | 99 |
|
101 | 100 |