|
| 1 | +# CLAUDE.md - lumos-mode |
| 2 | + |
| 3 | +**Repository**: https://github.com/getlumos/lumos-mode |
| 4 | +**Purpose**: Emacs major mode for LUMOS schema language |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## Quick Reference |
| 9 | + |
| 10 | +For complete ecosystem context, see: **[lumos/CLAUDE.md](https://github.com/getlumos/lumos/blob/main/CLAUDE.md)** |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +## What is lumos-mode? |
| 15 | + |
| 16 | +Emacs major mode for editing `.lumos` files with syntax highlighting, smart indentation, and LSP integration via `lumos-lsp`. |
| 17 | + |
| 18 | +**Status**: v0.1.0 development |
| 19 | +**Target**: Emacs 26.1+ |
| 20 | +**Dependencies**: lsp-mode (optional), lumos-lsp server |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## Key Files |
| 25 | + |
| 26 | +| File | Purpose | |
| 27 | +|------|---------| |
| 28 | +| `lumos-mode.el` | Main mode implementation (syntax, indent, LSP) | |
| 29 | +| `lumos-mode-test.el` | Test suite (14 tests) | |
| 30 | +| `README.md` | Installation and usage guide | |
| 31 | +| `.github/workflows/ci.yml` | CI testing across Emacs 27.2, 28.2, 29.1, snapshot | |
| 32 | +| `Makefile` | Test and compile commands | |
| 33 | +| `lumos-mode-recipe.el` | MELPA recipe file | |
| 34 | + |
| 35 | +--- |
| 36 | + |
| 37 | +## Features Implemented |
| 38 | + |
| 39 | +- ✅ Syntax highlighting (keywords, types, attributes, comments) |
| 40 | +- ✅ Smart indentation (context-aware, configurable offset) |
| 41 | +- ✅ LSP integration (auto-completion, diagnostics, hover, etc.) |
| 42 | +- ✅ Comment support (line and block) |
| 43 | +- ✅ File type auto-detection (`.lumos` → lumos-mode) |
| 44 | +- ✅ Customizable variables (indent-offset, lsp-server-command) |
| 45 | +- ✅ Test suite (14 tests covering mode, syntax, indent, comments) |
| 46 | + |
| 47 | +--- |
| 48 | + |
| 49 | +## Installation |
| 50 | + |
| 51 | +### MELPA (when published) |
| 52 | + |
| 53 | +```elisp |
| 54 | +(use-package lumos-mode |
| 55 | + :ensure t |
| 56 | + :hook (lumos-mode . lsp-deferred)) |
| 57 | +``` |
| 58 | + |
| 59 | +### Manual |
| 60 | + |
| 61 | +```elisp |
| 62 | +(add-to-list 'load-path "~/.emacs.d/lisp/lumos-mode") |
| 63 | +(require 'lumos-mode) |
| 64 | +(add-hook 'lumos-mode-hook #'lsp-deferred) |
| 65 | +``` |
| 66 | + |
| 67 | +--- |
| 68 | + |
| 69 | +## Testing |
| 70 | + |
| 71 | +```bash |
| 72 | +# Run all tests |
| 73 | +make test |
| 74 | + |
| 75 | +# Byte compile |
| 76 | +make compile |
| 77 | + |
| 78 | +# Clean compiled files |
| 79 | +make clean |
| 80 | +``` |
| 81 | + |
| 82 | +**Test Coverage**: 14 tests |
| 83 | +- Mode loading and derivation |
| 84 | +- File association |
| 85 | +- Syntax highlighting (keywords, types, attributes, comments) |
| 86 | +- Indentation (structs, enums) |
| 87 | +- Comment functionality |
| 88 | +- Custom variables |
| 89 | + |
| 90 | +--- |
| 91 | + |
| 92 | +## Development Workflow |
| 93 | + |
| 94 | +### Making Changes |
| 95 | + |
| 96 | +1. Edit `lumos-mode.el` |
| 97 | +2. Run tests: `make test` |
| 98 | +3. Check compilation: `make compile` |
| 99 | +4. Test in Emacs: |
| 100 | + ```elisp |
| 101 | + M-x load-file RET lumos-mode.el RET |
| 102 | + M-x lumos-mode |
| 103 | + ``` |
| 104 | + |
| 105 | +### Adding Features |
| 106 | + |
| 107 | +1. Implement feature in `lumos-mode.el` |
| 108 | +2. Add tests to `lumos-mode-test.el` |
| 109 | +3. Update README.md with usage instructions |
| 110 | +4. Run full test suite |
| 111 | +5. Update CLAUDE.md if architecture changes |
| 112 | + |
| 113 | +### CI Pipeline |
| 114 | + |
| 115 | +GitHub Actions runs on every push/PR: |
| 116 | +- Tests across Emacs 27.2, 28.2, 29.1, snapshot |
| 117 | +- package-lint validation |
| 118 | +- Byte compilation check |
| 119 | + |
| 120 | +--- |
| 121 | + |
| 122 | +## Publishing to MELPA |
| 123 | + |
| 124 | +### Submission Process |
| 125 | + |
| 126 | +1. Ensure all tests pass |
| 127 | +2. Update version in `lumos-mode.el` header |
| 128 | +3. Create PR to [melpa/melpa](https://github.com/melpa/melpa) with recipe: |
| 129 | + |
| 130 | +```elisp |
| 131 | +(lumos-mode |
| 132 | + :repo "getlumos/lumos-mode" |
| 133 | + :fetcher github |
| 134 | + :files ("*.el")) |
| 135 | +``` |
| 136 | + |
| 137 | +4. MELPA maintainers review and merge |
| 138 | +5. Package available within 24 hours |
| 139 | + |
| 140 | +### Pre-submission Checklist |
| 141 | + |
| 142 | +- [ ] All tests passing locally |
| 143 | +- [ ] CI passing on GitHub |
| 144 | +- [ ] README.md complete |
| 145 | +- [ ] Version bumped in header |
| 146 | +- [ ] package-lint clean |
| 147 | +- [ ] Byte compilation clean |
| 148 | + |
| 149 | +--- |
| 150 | + |
| 151 | +## LSP Integration |
| 152 | + |
| 153 | +### lumos-lsp Server |
| 154 | + |
| 155 | +The mode integrates with `lumos-lsp` (from core repo) for IDE features: |
| 156 | + |
| 157 | +- **Auto-completion**: Type suggestions |
| 158 | +- **Diagnostics**: Inline error checking |
| 159 | +- **Hover**: Documentation on hover |
| 160 | +- **Go to definition**: Jump to type definitions |
| 161 | +- **Find references**: Find all usages |
| 162 | +- **Rename**: Rename symbols across files |
| 163 | + |
| 164 | +### Configuration |
| 165 | + |
| 166 | +```elisp |
| 167 | +(setq lumos-lsp-server-command '("lumos-lsp" "--log-level" "debug")) |
| 168 | +``` |
| 169 | + |
| 170 | +Server must be installed separately: |
| 171 | + |
| 172 | +```bash |
| 173 | +cargo install lumos-lsp |
| 174 | +``` |
| 175 | + |
| 176 | +--- |
| 177 | + |
| 178 | +## Customization |
| 179 | + |
| 180 | +### Variables |
| 181 | + |
| 182 | +```elisp |
| 183 | +;; Indentation width (default: 2) |
| 184 | +(setq lumos-indent-offset 4) |
| 185 | +
|
| 186 | +;; LSP server command (default: '("lumos-lsp")) |
| 187 | +(setq lumos-lsp-server-command '("lumos-lsp" "--log-level" "info")) |
| 188 | +``` |
| 189 | + |
| 190 | +### Keybindings |
| 191 | + |
| 192 | +```elisp |
| 193 | +(define-key lumos-mode-map (kbd "C-c C-c") 'lsp-execute-code-action) |
| 194 | +(define-key lumos-mode-map (kbd "C-c C-r") 'lsp-rename) |
| 195 | +(define-key lumos-mode-map (kbd "C-c C-f") 'lsp-format-buffer) |
| 196 | +``` |
| 197 | + |
| 198 | +--- |
| 199 | + |
| 200 | +## Related Repositories |
| 201 | + |
| 202 | +- **lumos** (core): Compiler, CLI, LSP server |
| 203 | +- **vscode-lumos**: VS Code extension |
| 204 | +- **intellij-lumos**: IntelliJ IDEA / Rust Rover plugin |
| 205 | +- **nvim-lumos**: Neovim plugin with Tree-sitter |
| 206 | +- **tree-sitter-lumos**: Tree-sitter grammar |
| 207 | +- **awesome-lumos**: Examples and templates |
| 208 | +- **docs-lumos**: Official documentation site |
| 209 | + |
| 210 | +--- |
| 211 | + |
| 212 | +## AI Assistant Guidelines |
| 213 | + |
| 214 | +### ✅ DO |
| 215 | + |
| 216 | +- Run `make test` after any code changes |
| 217 | +- Update tests when adding new features |
| 218 | +- Keep README.md synchronized with code |
| 219 | +- Reference file:line when discussing code |
| 220 | +- Check CI passes before committing |
| 221 | + |
| 222 | +### ❌ DON'T |
| 223 | + |
| 224 | +- Skip running tests to save time |
| 225 | +- Add features without tests |
| 226 | +- Change indentation logic without extensive testing |
| 227 | +- Break backward compatibility with Emacs 26.1 |
| 228 | +- Include AI attribution in commits or code |
| 229 | + |
| 230 | +--- |
| 231 | + |
| 232 | +**Last Updated**: 2025-11-24 |
| 233 | +**Version**: 0.1.0 |
| 234 | +**Status**: Development |
0 commit comments