-
Notifications
You must be signed in to change notification settings - Fork 11
Style Guide
Xyris uses a modified version of the WebKit style guide, which is also used by SerenityOS. We believe it provides the best looking code while also being the simplest to understand. In order to help new Xyris contributors, a .clang-format
file is provided so that clang-tidy
can be run on Xyris source to have it comply with the style guide.
Please note that not all Xyris source complies with this style guide due to the fact that for a significant amount of time, a style guide was not used. If you are working with non-conforming code, please update it to conform to the style guide.
VSCode and CLion both include extensions (either internal or external) that allow in-IDE formatting of source using clang-tidy
.
---
Language: Cpp
BasedOnStyle: WebKit
SpaceAfterTemplateKeyword: false
AlignEscapedNewlines: Left
AlignTrailingComments: true
BreakBeforeInheritanceComma: true
BreakConstructorInitializers: BeforeComma
IndentPPDirectives: AfterHash
BreakBeforeBraces: Custom
BraceWrapping:
AfterFunction: true
NamespaceIndentation: None
- Visual Studio Code: clang-format
- First time setup:
- Right click within the code editor view to view the context menu.
- Click "Format Document With..."
- Click "Configure Default Formatter..."
- Click "Clang-Format"
- Usage:
- Right click within the code editor view to view the context menu.
- Click "Format Document"
- First time setup:
- Vim Family:
- First time setup:
- Install
clang-tidy
package wget https://raw.githubusercontent.com/llvm/llvm-project/main/clang/tools/clang-format/clang-format.py
mv clang-format.py /usr/local/bin/clang-format.py
- Add the following lines to
.vimrc
map <C-K> :py3f /usr/local/bin/clang-format.py<cr>
imap <C-K> <c-o>:py3f /usr/local/bin/clang-format.py<cr>
- Install
- Usage:
- Format current line with
Ctrl+K
- Format multiple lines with
Ctrl+K
in visual mode - Format entire file with
ggvG<CTRL+K>
- Format current line with
- First time setup:
Copyright the Xyris contributors. All rights reserved.