|
| 1 | +# Contributing to Marksman.nvim |
| 2 | + |
| 3 | +Thank you for your interest in contributing to Marksman.nvim! This document provides guidelines for contributing to this project. |
| 4 | + |
| 5 | +## Getting Started |
| 6 | + |
| 7 | +1. **Fork the repository** and clone your fork locally |
| 8 | +2. **Create a new branch** for your feature or bug fix |
| 9 | +3. **Test your changes** thoroughly |
| 10 | +4. **Submit a pull request** with a clear description |
| 11 | + |
| 12 | +## Development Setup |
| 13 | + |
| 14 | +### Prerequisites |
| 15 | +- Neovim >= 0.8.0 |
| 16 | +- Git |
| 17 | +- Lua 5.1+ (for testing outside Neovim) |
| 18 | + |
| 19 | +### Code Quality Tools |
| 20 | +```bash |
| 21 | +# Install luacheck for linting |
| 22 | +luarocks install luacheck |
| 23 | + |
| 24 | +# Install stylua for formatting |
| 25 | +cargo install stylua |
| 26 | + |
| 27 | +# Run linting |
| 28 | +luacheck lua/ |
| 29 | + |
| 30 | +# Run formatting |
| 31 | +stylua lua/ |
| 32 | +``` |
| 33 | + |
| 34 | +## Code Style |
| 35 | + |
| 36 | +### Lua Style Guidelines |
| 37 | +- Use **snake_case** for functions and variables |
| 38 | +- Use **PascalCase** for classes/modules |
| 39 | +- **Indent with tabs** (width: 4) |
| 40 | +- **Line length**: 100 characters max |
| 41 | +- **Use meaningful variable names** |
| 42 | + |
| 43 | +### Documentation |
| 44 | +- Add **JSDoc-style comments** for public functions |
| 45 | +- Include **@param** and **@return** annotations |
| 46 | +- Document **complex logic** with inline comments |
| 47 | + |
| 48 | +Example: |
| 49 | +```lua |
| 50 | +---Add a mark at the current cursor position |
| 51 | +---@param name string|nil Optional mark name (auto-generated if nil) |
| 52 | +---@param description string|nil Optional mark description |
| 53 | +---@return table result Result with success, message, and mark_name |
| 54 | +function M.add_mark(name, description) |
| 55 | + -- Implementation here |
| 56 | +end |
| 57 | +``` |
| 58 | + |
| 59 | +## Project Structure |
| 60 | + |
| 61 | +``` |
| 62 | +lua/marksman/ |
| 63 | +├── init.lua -- Main plugin entry point |
| 64 | +├── storage.lua -- Mark persistence and project management |
| 65 | +├── ui.lua -- Floating window and interface |
| 66 | +└── utils.lua -- Utilities and validation |
| 67 | +``` |
| 68 | + |
| 69 | +## Contribution Types |
| 70 | + |
| 71 | +### Bug Fixes |
| 72 | +1. **Create an issue** describing the bug |
| 73 | +2. **Include reproduction steps** and expected behavior |
| 74 | +3. **Write a test case** if applicable |
| 75 | +4. **Fix the bug** and ensure tests pass |
| 76 | + |
| 77 | +### New Features |
| 78 | +1. **Discuss the feature** in an issue first |
| 79 | +2. **Ensure it aligns** with the plugin's focused scope |
| 80 | +3. **Write comprehensive documentation** |
| 81 | +4. **Add configuration options** if needed |
| 82 | + |
| 83 | +### Documentation |
| 84 | +- **Fix typos** and improve clarity |
| 85 | +- **Add examples** for complex features |
| 86 | +- **Update README** with new functionality |
| 87 | + |
| 88 | +## Testing Guidelines |
| 89 | + |
| 90 | +### Manual Testing |
| 91 | +- Test with **multiple projects** |
| 92 | +- Verify **mark persistence** across sessions |
| 93 | +- Test **edge cases** (empty files, special characters) |
| 94 | +- Check **memory usage** with large mark sets |
| 95 | + |
| 96 | +### Test Scenarios |
| 97 | +1. **Basic Operations**: |
| 98 | + - Add/delete/rename marks |
| 99 | + - Jump to marks |
| 100 | + - Search functionality |
| 101 | + |
| 102 | +2. **Project Switching**: |
| 103 | + - Marks isolated per project |
| 104 | + - Correct project detection |
| 105 | + |
| 106 | +3. **Error Handling**: |
| 107 | + - Invalid file paths |
| 108 | + - Corrupted storage files |
| 109 | + - Memory limits |
| 110 | + |
| 111 | +4. **UI Testing**: |
| 112 | + - Window sizing and positioning |
| 113 | + - Keyboard navigation |
| 114 | + - Search and filtering |
| 115 | + |
| 116 | +## Performance Considerations |
| 117 | + |
| 118 | +### Memory Efficiency |
| 119 | +- **Lazy load modules** when possible |
| 120 | +- **Clean up resources** on plugin disable |
| 121 | +- **Cache strategically** with expiration |
| 122 | +- **Debounce operations** to reduce I/O |
| 123 | + |
| 124 | +### Code Patterns |
| 125 | +```lua |
| 126 | +-- Good: Lazy loading |
| 127 | +local function get_storage() |
| 128 | + if not storage then |
| 129 | + storage = require("marksman.storage") |
| 130 | + end |
| 131 | + return storage |
| 132 | +end |
| 133 | + |
| 134 | +-- Good: Error handling |
| 135 | +local ok, result = pcall(function() |
| 136 | + -- Potentially failing operation |
| 137 | +end) |
| 138 | +if not ok then |
| 139 | + notify("Operation failed: " .. tostring(result), vim.log.levels.ERROR) |
| 140 | + return false |
| 141 | +end |
| 142 | +``` |
| 143 | + |
| 144 | +## Error Handling |
| 145 | + |
| 146 | +### Guidelines |
| 147 | +- **Always handle errors** gracefully |
| 148 | +- **Provide meaningful messages** to users |
| 149 | +- **Log technical details** for debugging |
| 150 | +- **Fallback to safe defaults** when possible |
| 151 | + |
| 152 | +### Error Message Format |
| 153 | +```lua |
| 154 | +-- User-facing: Clear and actionable |
| 155 | +notify("Cannot add mark: file is not readable", vim.log.levels.WARN) |
| 156 | + |
| 157 | +-- Debug: Technical details |
| 158 | +notify("Failed to save marks: " .. tostring(err), vim.log.levels.ERROR) |
| 159 | +``` |
| 160 | + |
| 161 | +## Configuration Design |
| 162 | + |
| 163 | +### Principles |
| 164 | +- **Sensible defaults** that work out of the box |
| 165 | +- **Granular options** for customization |
| 166 | +- **Backward compatibility** when possible |
| 167 | +- **Validation** for user inputs |
| 168 | + |
| 169 | +### Example Configuration |
| 170 | +```lua |
| 171 | +require("marksman").setup({ |
| 172 | + -- Core functionality |
| 173 | + max_marks = 100, |
| 174 | + auto_save = true, |
| 175 | + |
| 176 | + -- UI preferences |
| 177 | + minimal = false, |
| 178 | + silent = false, |
| 179 | + |
| 180 | + -- Performance tuning |
| 181 | + debounce_ms = 500, |
| 182 | + |
| 183 | + -- Customization |
| 184 | + keymaps = { ... }, |
| 185 | + highlights = { ... }, |
| 186 | +}) |
| 187 | +``` |
| 188 | + |
| 189 | +## Pull Request Process |
| 190 | + |
| 191 | +### Before Submitting |
| 192 | +1. **Test thoroughly** on your system |
| 193 | +2. **Run linting** and fix issues |
| 194 | +3. **Update documentation** if needed |
| 195 | +4. **Rebase on main** branch |
| 196 | + |
| 197 | +### PR Description Template |
| 198 | +```markdown |
| 199 | +## Description |
| 200 | +Brief description of changes |
| 201 | + |
| 202 | +## Type of Change |
| 203 | +- [ ] Bug fix |
| 204 | +- [ ] New feature |
| 205 | +- [ ] Documentation update |
| 206 | +- [ ] Refactoring |
| 207 | + |
| 208 | +## Testing |
| 209 | +Describe how you tested the changes |
| 210 | + |
| 211 | +## Breaking Changes |
| 212 | +List any breaking changes (if applicable) |
| 213 | + |
| 214 | +## Checklist |
| 215 | +- [ ] Code follows style guidelines |
| 216 | +- [ ] Self-review completed |
| 217 | +- [ ] Documentation updated |
| 218 | +- [ ] Tests pass |
| 219 | +``` |
| 220 | + |
| 221 | +## Review Process |
| 222 | + |
| 223 | +### What We Look For |
| 224 | +- **Code quality** and maintainability |
| 225 | +- **Performance impact** |
| 226 | +- **User experience** improvements |
| 227 | +- **Documentation completeness** |
| 228 | +- **Test coverage** |
| 229 | + |
| 230 | +### Response Time |
| 231 | +- Initial review: 2-3 business days |
| 232 | +- Follow-up reviews: 1-2 business days |
| 233 | +- Simple fixes: Same day |
| 234 | + |
| 235 | +## Getting Help |
| 236 | + |
| 237 | +### Communication Channels |
| 238 | +- **GitHub Issues**: Bug reports and feature requests |
| 239 | +- **GitHub Discussions**: Questions and general discussion |
| 240 | +- **Pull Request Comments**: Code-specific discussions |
| 241 | + |
| 242 | +### Response Guidelines |
| 243 | +- Be **respectful** and constructive |
| 244 | +- **Ask questions** if requirements are unclear |
| 245 | +- **Provide context** for your suggestions |
| 246 | + |
| 247 | +## Recognition |
| 248 | + |
| 249 | +Contributors are recognized in: |
| 250 | +- **README.md** contributors section |
| 251 | +- **Release notes** for significant contributions |
| 252 | +- **GitHub repository** contributor graphs |
| 253 | + |
| 254 | +Thank you for helping make Marksman.nvim better! 🚀 |
0 commit comments