Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
# NextUI clang-format configuration
# Based on the existing code style in the project

BasedOnStyle: LLVM

# Indentation
UseTab: Always
TabWidth: 4
IndentWidth: 4
ContinuationIndentWidth: 4

# Line length
ColumnLimit: 120

# Braces
BreakBeforeBraces: Linux

# Spaces
SpaceAfterCStyleCast: false
SpaceBeforeParens: ControlStatements
SpaceBeforeAssignmentOperators: true
SpaceInEmptyParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpacesInCStyleCastParentheses: false

# Alignment
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true

# Line breaks
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true

# Pointer alignment
PointerAlignment: Right

# Other
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 2
SortIncludes: false
73 changes: 73 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Contributing to NextUI

Thank you for your interest in contributing to NextUI!

## Code Formatting

NextUI uses [clang-format](https://clang.llvm.org/docs/ClangFormat.html) to maintain consistent code formatting across all C/C++ source files.

### Setup

Clang-format is likely already installed on most development systems. You can verify by running:

```bash
clang-format --version
```

If not installed, you can install it:

- **Ubuntu/Debian**: `sudo apt-get install clang-format`
- **macOS**: `brew install clang-format`
- **Windows**: Download from [LLVM releases](https://releases.llvm.org/)

### Formatting Your Code

Before submitting a pull request, please format your code using clang-format:

```bash
# Format a single file
clang-format -i path/to/your/file.c

# Format all C/C++ files in the workspace (excluding _unmaintained)
find workspace -type f \( -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" \) | grep -v "_unmaintained" | xargs clang-format -i
```

### Checking Formatting

To check if your files are properly formatted without modifying them:

```bash
clang-format --dry-run --Werror path/to/your/file.c
```

### Configuration

The clang-format configuration is defined in `.clang-format` at the root of the repository. Key style guidelines:

- **Indentation**: Tabs (4 spaces wide)
- **Brace Style**: Linux style (opening brace on next line for functions)
- **Line Length**: 120 characters maximum
- **Pointer Alignment**: Right-aligned (`char *ptr` not `char* ptr`)
- **Space After Keywords**: `if (condition)` not `if(condition)`

### Editor Integration

Most modern editors and IDEs support clang-format integration:

- **VS Code**: Install the "C/C++" extension
- **Vim**: Use `vim-clang-format` plugin
- **Emacs**: Use `clang-format.el`
- **CLion/IntelliJ**: Built-in support

This ensures your code is automatically formatted as you write it.

## Pull Request Guidelines

1. Format your code using clang-format before submitting
2. Ensure your changes don't break existing functionality
3. Write clear commit messages
4. Update documentation if needed

## Questions?

If you have any questions about contributing, feel free to open an issue or join our [Discord](https://discord.gg/HKd7wqZk3h).
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ Our community has currated a [list of favorite Paks](https://nextui.loveretro.ga

---

## Contributing

We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on:

- Code formatting with clang-format
- Pull request guidelines
- Development setup

---

## Credits

[@josegonzalez](https://github.com/josegonzalez) for [minui-keyboard](https://github.com/josegonzalez/minui-keyboard/t)
Expand Down
Loading
Loading