Tutorial 20~25 MinutenFortgeschritten
Plugin-Entwicklung
Erstelle eigene Tools und Erweiterungen für Velisch.
Was du lernen wirst
- Rust Tool Plugins erstellen
- VS Code Extensions entwickeln
- Compiler-API nutzen
1
Plugin-Typen
Velisch unterstützt drei Arten von Plugins – wähle basierend auf deinem Use-Case.
Rust Tool
CLI-Tools mit Compiler-API
- ✅ Hohe Performance
- ✅ Binary Distribution
VS Code
Editor-Integration
- ✅ Syntax Highlighting
- ✅ Code Completion
LSP Extension
Editor-unabhängig
- ✅ Custom Actions
- ✅ Multi-Editor
2
Rust Tool Plugin
Cargo.tomltoml
[package]
name = "velin-my-plugin"
version = "0.1.0"
edition = "2021"
[dependencies]
clap = { version = "4.0", features = ["derive"] }
anyhow = "1.0"
velin-compiler = { path = "../../compiler" }src/main.rsrust
use clap::{Parser, Subcommand};
use anyhow::Result;
use velin_compiler::parser::parser::Parser as VelinParser;
#[derive(Parser)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Analyze {
#[arg(short, long, default_value = ".")]
input: PathBuf,
},
}
fn main() -> Result<()> {
let cli = Cli::parse();
match cli.command {
Commands::Analyze { input } => {
println!("🔍 Analysiere: {}", input.display());
// VelinParser nutzen...
Ok(())
}
}
}3
VS Code Extension
import * as vscode from 'vscode';
export function activate(context: vscode.ExtensionContext) {
const disposable = vscode.commands.registerCommand(
'velin.analyze',
async () => {
const editor = vscode.window.activeTextEditor;
if (!editor) return;
vscode.window.showInformationMessage('Velisch Plugin aktiv!');
}
);
context.subscriptions.push(disposable);
}Zusammenfassung
Was du gelernt hast:
- Plugin-Typen verstehen
- Rust Tools mit Compiler-API
- VS Code Extensions