-
Notifications
You must be signed in to change notification settings - Fork 0
Tools Formatter
GitHub Actions edited this page Jan 25, 2026
·
2 revisions
Der VelinScript Code Formatter sorgt für konsistente Code-Formatierung in Ihren Projekten. Er ist direkt in den Compiler integriert und kann über die CLI oder die VS Code Extension verwendet werden.
Der Formatter ist ideal für:
- ✅ Konsistente Formatierung - Stellt einheitliche Code-Formatierung sicher
- ✅ Team-Kollaboration - Eliminiert Formatierungs-Diskussionen im Code Review
- ✅ Pre-Commit-Hooks - Automatische Formatierung vor jedem Commit
- ✅ Code-Migration - Formatiert Legacy-Code auf neue Standards
- ✅ Format-on-Save - Automatische Formatierung beim Speichern (VS Code)
- ✅ CI/CD-Integration - Kann Formatierungs-Checks in Pipelines durchführen
Der Formatter ist NICHT gedacht für:
- ❌ Code-Qualität - Für Code-Qualitätsprüfung nutzen Sie den Linter
- ❌ Syntax-Fehler - Für Syntax-Korrektur nutzen Sie AutoFix
- ❌ Code-Optimierung - Für Performance-Optimierung nutzen Sie den Profiler
- ❌ Security-Checks - Für Security-Vulnerabilities nutzen Sie den Security Scanner
- ❌ Funktionale Änderungen - Der Formatter ändert nur Formatierung, nicht Logik
Der Formatter ist Teil des VelinScript Compilers. Keine separate Installation nötig.
# Formatiert und gibt das Ergebnis in der Konsole aus
velin format -i main.velin
# Formatiert und überschreibt die Datei
velin format -i main.velin --in-place# Mit Shell-Loop
for file in src/**/*.velin; do
velin format -i "$file" --in-place
doneDer Formatter ist automatisch in der VS Code Extension integriert:
-
Format Document:
Shift+Alt+F(Windows/Linux) oderShift+Option+F(Mac) - Format on Save: Automatisch aktiviert (konfigurierbar in Settings)
-
Format Selection: Markieren Sie Code und drücken Sie
Ctrl+K Ctrl+F
- Standard: 4 Leerzeichen
- Einrückungsstil: Spaces (keine Tabs)
- Tab-Breite: 4 Zeichen
- Standard: 100 Zeichen
- Längere Zeilen werden automatisch umgebrochen
-
Operatoren: Leerzeichen um binäre Operatoren (
+,-,*,/,==, etc.) - Kommas: Leerzeichen nach Kommas in Listen
- Funktionsaufrufe: Keine Leerzeichen zwischen Funktionsname und öffnender Klammer
- Funktionen: Leerzeile zwischen Funktionen
- Structs/Enums: Leerzeile zwischen Typ-Definitionen
- Imports: Gruppierte Imports mit Leerzeilen zwischen Gruppen
Sie können die Formatierung in velin.toml anpassen:
[formatter]
# Einrückungsgröße (Standard: 4)
indent_size = 4
# Einrückungsstil: "spaces" oder "tabs"
indent_style = "spaces"
# Maximale Zeilenbreite (Standard: 100)
line_width = 100
# Tab-Breite (Standard: 4)
tab_width = 4{
"velin.formatter.enabled": true,
"velin.formatter.formatOnSave": true,
"velin.formatter.indentSize": 4,
"velin.formatter.lineWidth": 100
}@GET("/api/users")
fn getUsers():List<User>{
let users=db.findAll(User);
return users;
}
@POST("/api/users")
@Auth
fn createUser(name:string,email:string):User{
let user=User{id:generateId(),name:name,email:email,createdAt:datetime.now()};
return user;
}
@GET("/api/users")
fn getUsers(): List<User> {
let users = db.findAll(User);
return users;
}
@POST("/api/users")
@Auth
fn createUser(name: string, email: string): User {
let user = User {
id: generateId(),
name: name,
email: email,
createdAt: datetime.now(),
};
return user;
}
┌─────────────────────────────────────────────────────────┐
│ VelinScript Formatter │
├─────────────────────────────────────────────────────────┤
│ │
│ $ velin format -i main.velin --in-place │
│ │
│ ✓ Formatiere: main.velin │
│ ✓ Formatierung erfolgreich │
│ │
│ Vorher: │
│ fn getUsers():List<User>{ │
│ let users=db.findAll(User); │
│ return users;} │
│ │
│ Nachher: │
│ fn getUsers(): List<User> { │
│ let users = db.findAll(User); │
│ return users; │
│ } │
│ │
└─────────────────────────────────────────────────────────┘
Der Formatter normalisiert:
- ✅ Einrückung: Konsistente Einrückung mit Spaces
- ✅ Leerzeichen: Um Operatoren, nach Kommas, etc.
- ✅ Zeilenumbrüche: Zwischen Funktionen, Structs, etc.
- ✅ Klammern: Konsistente Platzierung von
{,},(,),[,] - ✅ Semikolons: Konsistente Platzierung
- ✅ Imports: Gruppierung und Sortierung von
useStatements
#!/bin/sh
# .git/hooks/pre-commit
# Formatiere alle geänderten .velin Dateien
git diff --cached --name-only --diff-filter=ACM | grep '\.velin$' | while read file; do
velin format -i "$file" --in-place
git add "$file"
donename: Format Check
on: [push, pull_request]
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Rust
uses: actions-rs/toolchain@v1
- name: Build Compiler
run: |
cd compiler
cargo build --release
- name: Check Formatting
run: |
for file in $(find . -name "*.velin" -not -path "./target/*"); do
velin format -i "$file" > formatted.velin
if ! diff -q "$file" formatted.velin > /dev/null; then
echo "❌ $file ist nicht formatiert!"
exit 1
fi
done
echo "✅ Alle Dateien sind korrekt formatiert"- Format on Save aktivieren - Automatische Formatierung bei jedem Speichern
- Pre-Commit Hooks - Formatierung vor jedem Commit
- CI/CD Integration - Format-Checks in der Pipeline
- Team-Konsens - Einheitliche Formatierungsregeln im Team
- Regelmäßige Formatierung - Vor größeren Commits formatieren
- Der Formatter ist konsistent - wenn er Ihre Formatierung ändert, entspricht sie nicht den Standardregeln
- Passen Sie die Konfiguration in
velin.tomlan, wenn Sie andere Regeln möchten
- Prüfen Sie, ob die VS Code Extension installiert ist
- Prüfen Sie die VS Code Settings für
velin.formatter.enabled - Starten Sie VS Code neu
- Der Formatter benötigt gültigen Code
- Beheben Sie zuerst Parsing-Fehler mit
velin checkoder--autofix
# Zuerst AutoFix, dann Formatierung
velin check -i main.velin --autofix
velin format -i main.velin --in-place# Finde alle .velin Dateien und formatiere sie
find . -name "*.velin" -not -path "./target/*" -exec velin format -i {} --in-place \;| Feature | VelinScript Formatter | Prettier | rustfmt |
|---|---|---|---|
| VelinScript-spezifisch | ✅ | ❌ | ❌ |
| Konfigurierbar | ✅ | ✅ | ✅ |
| Format on Save | ✅ | ✅ | ✅ |
| CLI-Integration | ✅ | ✅ | ✅ |
| VS Code Extension | ✅ | ✅ | ✅ |
- VS Code Extension - IDE-Integration
- Linter - Code-Qualitätsprüfung
- AutoFix - Automatische Fehlerkorrektur
- Compiler Architecture
- Pass-Verlauf
- Type Inference
- Code Ordering
- IR Representation
- Borrow Checker
- Code Generation
- Multi-Target Compilation
- Module Resolution
- Framework Integration
- Parallelization
- AI Compiler Passes
- Prompt Optimizer
- System Generation
- Basics
- APIs
- Security
- Database
- Validation
- Authentication
- ML/LLM
- Intelligence Features
- Type Inference
- ML Training
- Pattern Matching
- Closures
- Collections
- HTTP Client
- String Interpolation
- Debugger
- Vektor-Datenbanken
- CLI Reference
- API Keys Setup
- Advanced
- Backend
- Security Best Practices
- AI/ML
- Auto Imports
- Plugin Development