|
| 1 | +# Contributing to vim-solidity |
| 2 | + |
| 3 | +Thank you for your interest in contributing to vim-solidity! This document provides guidelines and instructions for contributing. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Code of Conduct](#code-of-conduct) |
| 8 | +- [How Can I Contribute?](#how-can-i-contribute) |
| 9 | +- [Development Setup](#development-setup) |
| 10 | +- [Testing](#testing) |
| 11 | +- [Submitting Changes](#submitting-changes) |
| 12 | +- [Style Guidelines](#style-guidelines) |
| 13 | + |
| 14 | +## Code of Conduct |
| 15 | + |
| 16 | +This project follows the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the maintainers. |
| 17 | + |
| 18 | +## How Can I Contribute? |
| 19 | + |
| 20 | +### Reporting Bugs |
| 21 | + |
| 22 | +Before creating a bug report, please check existing issues to avoid duplicates. When creating a bug report, include: |
| 23 | + |
| 24 | +- **Description**: Clear description of the problem |
| 25 | +- **Steps to reproduce**: Minimal steps to reproduce the issue |
| 26 | +- **Expected behavior**: What you expected to happen |
| 27 | +- **Actual behavior**: What actually happened |
| 28 | +- **Environment**: Vim version, OS, terminal emulator |
| 29 | +- **Sample code**: Minimal Solidity code that demonstrates the issue |
| 30 | + |
| 31 | +### Suggesting Enhancements |
| 32 | + |
| 33 | +Enhancement suggestions are welcome! Please provide: |
| 34 | + |
| 35 | +- **Use case**: Why is this enhancement useful? |
| 36 | +- **Proposed solution**: How would you like it to work? |
| 37 | +- **Alternatives**: Other approaches you've considered |
| 38 | +- **Examples**: Code examples if applicable |
| 39 | + |
| 40 | +### Pull Requests |
| 41 | + |
| 42 | +1. Fork the repository |
| 43 | +2. Create a feature branch (`git checkout -b feature/amazing-feature`) |
| 44 | +3. Make your changes |
| 45 | +4. Add tests if applicable |
| 46 | +5. Run the test suite |
| 47 | +6. Commit your changes (see commit guidelines below) |
| 48 | +7. Push to your branch |
| 49 | +8. Open a Pull Request |
| 50 | + |
| 51 | +## Development Setup |
| 52 | + |
| 53 | +### Prerequisites |
| 54 | + |
| 55 | +- Vim 8.0+ or Neovim |
| 56 | +- Git |
| 57 | +- [vader.vim](https://github.com/junegunn/vader.vim) for testing |
| 58 | + |
| 59 | +### Clone and Setup |
| 60 | + |
| 61 | +```bash |
| 62 | +# Clone your fork |
| 63 | +git clone https://github.com/YOUR_USERNAME/vim-solidity.git |
| 64 | +cd vim-solidity |
| 65 | + |
| 66 | +# Clone vader.vim for testing |
| 67 | +git clone https://github.com/junegunn/vader.vim.git test/vader.vim |
| 68 | +``` |
| 69 | + |
| 70 | +### File Structure |
| 71 | + |
| 72 | +``` |
| 73 | +vim-solidity/ |
| 74 | +├── ftdetect/ # File type detection |
| 75 | +├── ftplugin/ # File type plugin settings |
| 76 | +├── indent/ # Indentation logic |
| 77 | +├── syntax/ # Syntax highlighting |
| 78 | +├── test/ # Test suite |
| 79 | +│ ├── vader/ # Vader test files |
| 80 | +│ ├── fixtures/ # Test Solidity files |
| 81 | +│ └── vimrc # Test configuration |
| 82 | +└── README.md |
| 83 | +``` |
| 84 | + |
| 85 | +## Testing |
| 86 | + |
| 87 | +### Running Tests Locally |
| 88 | + |
| 89 | +```bash |
| 90 | +# Run all tests |
| 91 | +vim -Nu test/vimrc -c 'Vader! test/vader/*.vader' |
| 92 | + |
| 93 | +# Run specific test file |
| 94 | +vim -Nu test/vimrc -c 'Vader! test/vader/syntax.vader' |
| 95 | + |
| 96 | +# Run interactively (for debugging) |
| 97 | +vim -Nu test/vimrc -c 'Vader test/vader/syntax.vader' |
| 98 | +``` |
| 99 | + |
| 100 | +### Writing Tests |
| 101 | + |
| 102 | +We use [vader.vim](https://github.com/junegunn/vader.vim) for testing. Tests are located in `test/vader/`. |
| 103 | + |
| 104 | +**Example syntax test:** |
| 105 | +```vader |
| 106 | +Given solidity (test description): |
| 107 | + contract Test { |
| 108 | + uint256 value; |
| 109 | + } |
| 110 | +
|
| 111 | +Execute (check syntax highlighting): |
| 112 | + normal! /uint256 |
| 113 | + let l:group = synIDattr(synID(line('.'), col('.'), 1), 'name') |
| 114 | + AssertEqual 'solBuiltinType', l:group |
| 115 | +``` |
| 116 | + |
| 117 | +**Example indentation test:** |
| 118 | +```vader |
| 119 | +Given solidity (unindented code): |
| 120 | + contract Test { |
| 121 | + function foo() { |
| 122 | + return 1; |
| 123 | + } |
| 124 | + } |
| 125 | +
|
| 126 | +Execute (indent buffer): |
| 127 | + normal! gg=G |
| 128 | +
|
| 129 | +Expect solidity (properly indented): |
| 130 | + contract Test { |
| 131 | + function foo() { |
| 132 | + return 1; |
| 133 | + } |
| 134 | + } |
| 135 | +``` |
| 136 | + |
| 137 | +### Manual Testing |
| 138 | + |
| 139 | +Use the test fixtures to manually verify changes: |
| 140 | + |
| 141 | +```bash |
| 142 | +# Open a test file |
| 143 | +vim test/fixtures/modern.sol |
| 144 | + |
| 145 | +# Check syntax highlighting |
| 146 | +:syn list |
| 147 | + |
| 148 | +# Test indentation |
| 149 | +gg=G |
| 150 | + |
| 151 | +# Test folding |
| 152 | +:set foldmethod=syntax |
| 153 | +zM |
| 154 | +zR |
| 155 | +``` |
| 156 | + |
| 157 | +## Submitting Changes |
| 158 | + |
| 159 | +### Commit Messages |
| 160 | + |
| 161 | +Follow these guidelines for commit messages: |
| 162 | + |
| 163 | +``` |
| 164 | +Add brief summary (50 characters or less) |
| 165 | +
|
| 166 | +More detailed explanation if needed. Wrap at 72 characters. |
| 167 | +
|
| 168 | +- Use bullet points for multiple changes |
| 169 | +- Reference issues: "Fixes #123" or "Closes #456" |
| 170 | +- Explain the why, not just the what |
| 171 | +
|
| 172 | +Co-Authored-By: Name <email@example.com> |
| 173 | +``` |
| 174 | + |
| 175 | +**Examples:** |
| 176 | +``` |
| 177 | +Add transient keyword support (0.8.24+) |
| 178 | +
|
| 179 | +- Add transient to solKeyword list |
| 180 | +- Update syntax tests |
| 181 | +- Add test fixture with transient storage |
| 182 | +
|
| 183 | +Fixes #45 |
| 184 | +``` |
| 185 | + |
| 186 | +### Pull Request Guidelines |
| 187 | + |
| 188 | +- **One feature per PR**: Keep PRs focused on a single feature or fix |
| 189 | +- **Update tests**: Add or update tests for your changes |
| 190 | +- **Update documentation**: Update README.md if adding user-facing features |
| 191 | +- **Update CHANGELOG**: Add an entry to CHANGELOG.md under "Unreleased" |
| 192 | +- **Pass CI**: Ensure GitHub Actions tests pass |
| 193 | +- **Clean history**: Rebase and squash commits if needed |
| 194 | + |
| 195 | +### PR Template |
| 196 | + |
| 197 | +Your PR description should include: |
| 198 | + |
| 199 | +```markdown |
| 200 | +## Description |
| 201 | +Brief description of the changes |
| 202 | + |
| 203 | +## Motivation |
| 204 | +Why is this change needed? |
| 205 | + |
| 206 | +## Changes |
| 207 | +- List of specific changes |
| 208 | +- What was added/modified/removed |
| 209 | + |
| 210 | +## Testing |
| 211 | +- How was this tested? |
| 212 | +- Which test cases were added/updated? |
| 213 | + |
| 214 | +## Checklist |
| 215 | +- [ ] Tests pass locally |
| 216 | +- [ ] Added/updated tests for changes |
| 217 | +- [ ] Updated CHANGELOG.md |
| 218 | +- [ ] Updated README.md if needed |
| 219 | +- [ ] Follows style guidelines |
| 220 | +``` |
| 221 | + |
| 222 | +## Style Guidelines |
| 223 | + |
| 224 | +### VimL Style |
| 225 | + |
| 226 | +- **Indentation**: 4 spaces (no tabs) |
| 227 | +- **Line length**: 80 characters where reasonable |
| 228 | +- **Comments**: Use `"` for comments, be descriptive |
| 229 | +- **Variables**: Use descriptive names (`l:` for local, `b:` for buffer) |
| 230 | +- **Functions**: PascalCase for user functions, snake_case for private |
| 231 | + |
| 232 | +**Example:** |
| 233 | +```vim |
| 234 | +" Check if current line is a function definition |
| 235 | +function! s:is_function_line(lnum) |
| 236 | + let l:line = getline(a:lnum) |
| 237 | + return l:line =~# '^\s*function\>' |
| 238 | +endfunction |
| 239 | +``` |
| 240 | + |
| 241 | +### Syntax Highlighting Rules |
| 242 | + |
| 243 | +- **Keyword groups**: Use `solKeyword`, `solConstant`, `solBuiltinType` |
| 244 | +- **Regions**: Use `fold` option for foldable blocks |
| 245 | +- **Contains**: Be specific about what regions can contain |
| 246 | +- **Highlighting**: Link to standard highlight groups when possible |
| 247 | + |
| 248 | +### Test Style |
| 249 | + |
| 250 | +- **Descriptive names**: Test names should clearly state what they test |
| 251 | +- **One concept per test**: Each test should verify one thing |
| 252 | +- **Fixtures**: Add complex test cases to `test/fixtures/` |
| 253 | +- **Comments**: Explain non-obvious test logic |
| 254 | + |
| 255 | +## Solidity Version Support |
| 256 | + |
| 257 | +vim-solidity aims to support: |
| 258 | + |
| 259 | +- **Current**: Latest stable Solidity version (currently 0.8.x) |
| 260 | +- **Recent**: Previous minor versions still in common use |
| 261 | +- **Future**: New features added as they're released |
| 262 | + |
| 263 | +When adding support for new Solidity features: |
| 264 | + |
| 265 | +1. Reference the Solidity version in comments |
| 266 | +2. Add test cases using the new feature |
| 267 | +3. Update CHANGELOG with version info |
| 268 | +4. Consider backward compatibility |
| 269 | + |
| 270 | +## Getting Help |
| 271 | + |
| 272 | +- **Questions**: Open a GitHub Discussion |
| 273 | +- **Bugs**: Open an issue with the bug template |
| 274 | +- **Features**: Open an issue with the feature template |
| 275 | +- **Chat**: Mention @thesis/vim-solidity maintainers |
| 276 | + |
| 277 | +## Recognition |
| 278 | + |
| 279 | +Contributors are recognized in several ways: |
| 280 | + |
| 281 | +- Mentioned in commit messages (Co-Authored-By) |
| 282 | +- Listed in All Contributors (see README) |
| 283 | +- Highlighted in release notes for major contributions |
| 284 | + |
| 285 | +Thank you for contributing to vim-solidity! |
0 commit comments