Plugin Examples
This section contains complete, production-ready plugin examples that demonstrate the full capabilities of the Lokus Plugin SDK. Each example is fully functional and can be copied directly to create your own plugins.
Example Complexity Levels
Our examples are organized from simple to advanced:
Beginner
- Hello World - The simplest possible plugin
- Shows a notification when activated
- Demonstrates basic plugin structure
- Perfect first example
Intermediate
-
Word Counter - Status bar integration
- Real-time word counting
- Status bar item updates
- Editor event listeners
- Document change tracking
-
Custom Formatter - Editor manipulation
- Custom text formatting
- Command registration
- Editor selection handling
- Text transformation
Advanced
-
File Explorer - Tree view UI
- Complete file tree view
- Tree data provider
- File system operations
- Custom icons and context menus
-
AI Assistant - Network & streaming
- OpenAI API integration
- Streaming responses
- Progress indicators
- Error handling
- Configuration management
What Each Example Includes
Every example in this section provides:
- Complete Source Code - Copy-paste ready, fully commented
- Full Manifest - Complete
manifest.jsonwith all required fields - Feature List - What the plugin demonstrates
- Installation Guide - How to install and test
- Code Walkthrough - Explanation of key concepts
- Common Pitfalls - What to watch out for
- Extension Ideas - How to build on the example
Using These Examples
Quick Start
# Create a new plugin from an example
npm create lokus-plugin@latest my-plugin
# Or manually copy an example
mkdir my-plugin
cd my-plugin
# Copy the code from the example
npm install
npm run devTesting Examples
All examples can be tested immediately:
# Link the plugin to Lokus
npm link
# In Lokus plugins directory
npm link plugin-name
# Restart Lokus and enable the pluginExample Features Matrix
| Example | Commands | Status Bar | Tree View | Network | Editor API | Config |
|---|---|---|---|---|---|---|
| Hello World | ✓ | - | - | - | - | - |
| Word Counter | - | ✓ | - | - | ✓ | - |
| Custom Formatter | ✓ | - | - | - | ✓ | ✓ |
| File Explorer | ✓ | - | ✓ | - | - | ✓ |
| AI Assistant | ✓ | ✓ | - | ✓ | ✓ | ✓ |
Learning Path
We recommend following this path:
- Start with Hello World to understand basic structure
- Try Word Counter to learn about editor events
- Build Custom Formatter to manipulate editor content
- Create File Explorer to work with tree views
- Implement AI Assistant to integrate external services
Common Patterns
All examples demonstrate these best practices:
- Error Handling - Proper try-catch blocks
- Cleanup - Disposing resources in
deactivate() - TypeScript - Type-safe code with JSDoc comments
- Async/Await - Modern async patterns
- Event Listeners - Proper listener registration and cleanup
- User Feedback - Notifications, progress indicators, and status updates
Need Help?
- Check the API Reference for detailed API documentation
- Review Architecture to understand plugin internals
- See Best Practices for production tips
- Join our Discord community for support
Contributing Examples
Have a great plugin example? We’d love to include it! See our contribution guide for details.
Ready to build? Pick an example and start coding!