Skip to content

Commit 1685cea

Browse files
committed
Initial commit: Emacs major mode for LUMOS
- Implement lumos-mode.el with syntax highlighting and LSP integration - Add smart indentation with configurable offset - Create comprehensive test suite (14 tests) - Set up GitHub Actions CI (Emacs 27.2, 28.2, 29.1, snapshot) - Add MELPA recipe for package distribution - Include dual licenses (MIT + Apache 2.0) - Provide detailed README with installation and usage - Document AI assistant context in CLAUDE.md Features: - Syntax highlighting for keywords, types, attributes, comments - LSP integration via lsp-mode and lumos-lsp server - Auto-completion, diagnostics, hover, go-to-definition - Comment support (line and block) - File type auto-detection for .lumos files - Customizable variables and keybindings Resolves #48
0 parents  commit 1685cea

File tree

10 files changed

+1307
-0
lines changed

10 files changed

+1307
-0
lines changed

.github/workflows/ci.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
emacs_version:
15+
- '27.2'
16+
- '28.2'
17+
- '29.1'
18+
- 'snapshot'
19+
fail-fast: false
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Emacs
26+
uses: purcell/setup-emacs@master
27+
with:
28+
version: ${{ matrix.emacs_version }}
29+
30+
- name: Check Emacs version
31+
run: emacs --version
32+
33+
- name: Run tests
34+
run: make test
35+
36+
- name: Byte compile
37+
run: make compile
38+
39+
lint:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout code
43+
uses: actions/checkout@v4
44+
45+
- name: Setup Emacs
46+
uses: purcell/setup-emacs@master
47+
with:
48+
version: '29.1'
49+
50+
- name: Install package-lint
51+
run: |
52+
emacs -batch -l package \
53+
--eval "(add-to-list 'package-archives '(\"melpa\" . \"https://melpa.org/packages/\") t)" \
54+
--eval "(package-initialize)" \
55+
--eval "(package-refresh-contents)" \
56+
--eval "(package-install 'package-lint)"
57+
58+
- name: Run package-lint
59+
run: |
60+
emacs -batch -l package \
61+
--eval "(add-to-list 'package-archives '(\"melpa\" . \"https://melpa.org/packages/\") t)" \
62+
--eval "(package-initialize)" \
63+
--eval "(require 'package-lint)" \
64+
-f package-lint-batch-and-exit lumos-mode.el

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.elc
2+
*~
3+
*.bak
4+
.DS_Store

CLAUDE.md

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
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

Comments
 (0)