Skip to content

Commit

Permalink
Fix clang-format script (#90)
Browse files Browse the repository at this point in the history
* clang-format: handle -- argument in script

* clang-format: change syntax highlighting language

bash => sh

* clang-format: clarify help

file => config file
  • Loading branch information
Layerex authored Jun 9, 2022
1 parent b32b5f5 commit 73c4628
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion programs/clang-format.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"path": "$HOME/.clang-format",
"movable": false,
"help": "Providing exact path to file via _--style_ (_-style_) flag is supported since version 14, but some repositories (Arch Linux repositories, for example) still don't have that version.\n\nWith version 14 or higher move file to _\"$XDG_CONFIG_HOME\"/clang-format_ and place this shell script with name \"clang-format\" to some directory in _\"$PATH\"_, preceding _/usr/bin/_ (I suggest _\"$HOME\"/.local/bin/_ or _/usr/local/bin/_):\n```bash\n#!/usr/bin/env sh\n\nCONFIG_FILE_PATH=\"$XDG_CONFIG_HOME\"/clang-format\n\nstyle_arg_set() {\n for arg in \"$@\"\n do\n case \"$arg\" in\n -style*|--style*)\n return 0\n esac\n done\n return 1\n}\n\nif style_arg_set \"$@\"\nthen\n /usr/bin/clang-format \"$@\"\nelse\n /usr/bin/clang-format --style=file:\"$CONFIG_FILE_PATH\" \"$@\"\nfi\n```\n\n_Note: .clang-format file is recognized by clang-format if it is located in any of the parent directories of the source file, not just \"$HOME\". This feature of the program may also be used._"
"help": "Providing path to config file via _--style_ (_-style_) flag is supported since version 14, but some repositories (Arch Linux repositories, for example) still don't have that version.\n\nWith version 14 or higher move config file to _\"$XDG_CONFIG_HOME\"/clang-format_ and place this shell script with name \"clang-format\" to some directory in _\"$PATH\"_, preceding _/usr/bin/_ (I suggest _\"$HOME\"/.local/bin/_ or _/usr/local/bin/_):\n```sh\n#!/usr/bin/env sh\n\nCONFIG_FILE_PATH=\"$XDG_CONFIG_HOME\"/clang-format\n\nstyle_arg_set() {\n for arg in \"$@\"\n do\n case \"$arg\" in\n -style*|--style*)\n return 0\n ;;\n --)\n return 1\n esac\n done\n return 1\n}\n\nif style_arg_set \"$@\"\nthen\n /usr/bin/clang-format \"$@\"\nelse\n /usr/bin/clang-format --style=file:\"$CONFIG_FILE_PATH\" \"$@\"\nfi\n```\n\n_Note: .clang-format file is recognized by clang-format if it is located in any of the parent directories of the source file, not just \"$HOME\". This feature of the program may also be used._"
}
],
"name": "clang-format"
Expand Down

0 comments on commit 73c4628

Please sign in to comment.