Skip to content

AI Code Completion

Sidian's AI-powered code completion goes beyond traditional IntelliSense to provide intelligent, context-aware suggestions that understand your code's intent and patterns.

How AI Code Completion Works

Intelligent Analysis

  • Context understanding: AI analyzes your entire codebase for relevant suggestions
  • Pattern recognition: Learns from your coding patterns and style
  • Multi-language support: Works across different programming languages
  • Real-time processing: Provides suggestions as you type

Advanced Features

  • Whole line completion: Complete entire lines of code
  • Multi-line suggestions: Generate multiple lines of related code
  • Function generation: Create complete functions based on comments or names
  • Import suggestions: Automatically suggest and add required imports

Enabling Code Completion

Basic Setup

  1. Sign in: Ensure you're signed into your Sidian account
  2. Enable feature: Go to Settings → Providers/Local → Enable Code Completion
  3. Select model: Choose your preferred AI model for completion
  4. Configure delay: Set the delay before suggestions appear (default: 500ms)

Configuration Options

  • Suggestion count: Number of suggestions to show (1-5)
  • Minimum trigger length: Minimum characters before triggering (1-3)
  • Auto-accept: Automatically accept single suggestions
  • Show inline: Display suggestions inline vs. in popup

Using Code Completion

Basic Usage

  1. Start typing: Begin typing code in any supported language
  2. Wait for suggestions: AI suggestions appear after the configured delay
  3. Accept suggestion: Press Tab to accept the highlighted suggestion
  4. Cycle suggestions: Use / arrows to browse multiple suggestions
  5. Dismiss: Press Esc to dismiss suggestions

Keyboard Shortcuts

ActionShortcutDescription
Accept suggestionTabAccept the current suggestion
Next suggestion or Ctrl+Move to next suggestion
Previous suggestion or Ctrl+Move to previous suggestion
Dismiss suggestionsEscClose suggestion popup
Force triggerCtrl+SpaceManually trigger suggestions

Types of Completions

Variable and Function Names

  • Smart naming: Suggests meaningful variable names based on context
  • Camel case: Automatically formats names in appropriate case
  • Type inference: Suggests names based on inferred types
  • Convention following: Follows language-specific naming conventions

Code Patterns

  • Common patterns: Recognizes and completes common coding patterns
  • Boilerplate code: Generates standard boilerplate for classes, functions
  • Error handling: Suggests appropriate error handling patterns
  • API usage: Completes API calls based on documentation

Language-Specific Features

JavaScript/TypeScript

  • Promise handling: Async/await and Promise completion
  • React components: JSX and React hook patterns
  • Node.js modules: CommonJS and ES6 import/export
  • Type annotations: TypeScript type completions

Python

  • List comprehensions: Complex list comprehension patterns
  • Decorators: Function and class decorator suggestions
  • Context managers: With statement completions
  • Package imports: Intelligent import suggestions

Java

  • Stream operations: Java 8+ stream method chains
  • Exception handling: Try-catch block completions
  • Annotation usage: Spring, JPA, and other framework annotations
  • Generic types: Generic type parameter completions

C#

  • LINQ queries: Complex LINQ expression completions
  • Async patterns: Task-based asynchronous patterns
  • Property definitions: Auto-property and full property patterns
  • Attribute usage: Framework-specific attribute completions

Advanced Features

Context-Aware Suggestions

  • Project context: Understands your project structure and dependencies
  • File context: Considers imports, variables, and functions in current file
  • Selection context: Provides relevant suggestions based on selected code
  • Comment-driven: Generates code based on comments and documentation

Learning and Adaptation

  • Usage patterns: Learns from your accepted and rejected suggestions
  • Code style: Adapts to your coding style and preferences
  • Project-specific: Learns patterns specific to your project
  • Team consistency: Maintains consistency with team coding standards

Multi-Language Projects

  • Cross-language: Understands relationships between different languages
  • API boundaries: Suggests appropriate interfaces between languages
  • Configuration files: Completes configuration in JSON, YAML, XML
  • Template languages: Supports HTML, CSS, and template engines

Customization

Model Selection

  • Fast models: Quick suggestions with lower accuracy
  • Balanced models: Good balance of speed and accuracy
  • Advanced models: Highest accuracy with longer processing time
  • Local models: Privacy-focused offline processing

Filtering Options

  • Language filters: Enable/disable for specific languages
  • File type filters: Control completion in different file types
  • Project filters: Different settings for different projects
  • Context filters: Filter based on code context (comments, strings, etc.)

Performance Tuning

  • Cache settings: Configure suggestion caching
  • Network timeout: Set timeout for cloud-based models
  • Batch processing: Group multiple requests for efficiency
  • Resource limits: Control CPU and memory usage

Troubleshooting

Common Issues

Suggestions not appearing

  • Check if code completion is enabled in settings
  • Verify you're signed in and have an active subscription
  • For cloud models: Ensure internet connection
  • For local models: Verify Ollama/LM Studio is running
  • Try increasing the trigger delay

Slow suggestions

  • Switch to a faster AI model
  • Reduce the number of suggestions shown
  • Check network connection speed
  • Clear suggestion cache

Irrelevant suggestions

  • Provide more context by typing additional characters
  • Use comments to guide the AI
  • Check if the correct language is detected
  • Try a different AI model

High resource usage

  • Switch to a lighter AI model
  • Reduce suggestion frequency
  • Enable local processing if available
  • Close unnecessary files and tabs

Best Practices

  1. Provide context: Write descriptive comments and variable names
  2. Be patient: Allow time for AI to analyze context
  3. Review suggestions: Always review generated code before accepting
  4. Learn shortcuts: Master keyboard shortcuts for efficient usage
  5. Customize settings: Adjust settings to match your development style
  6. Give feedback: Use feedback options to improve suggestions

AI code completion in Sidian is designed to enhance your productivity while maintaining code quality. Take time to explore and customize the features to match your development style.