Skip to main content

Languages API

The Languages API enables extensions to provide rich language features like IntelliSense, diagnostics, code actions, formatting, and more. This API allows you to enhance the editing experience for any programming language.

Namespace

All language-related functionality is available through the languages namespace.

Core Functions

Language Information

Diagnostics

Creating a Diagnostic Collection

Range
required
The range to which this diagnostic applies
string
required
The human-readable diagnostic message
DiagnosticSeverity
Error (0), Warning (1), Information (2), or Hint (3)
string
Human-readable source of the diagnostic (e.g., ‘eslint’)
string | number
Code or identifier for later processing

Diagnostic Events

IntelliSense Providers

Completion Provider

Hover Provider

Definition Provider

Code Actions

Code Action Provider

Use providedCodeActionKinds metadata to filter when your provider is invoked, improving performance.

Formatting

Document Formatting

number
required
Size of a tab in spaces
boolean
required
Prefer spaces over tabs

Range Formatting

On-Type Formatting

Symbol Providers

Document Symbol Provider

Workspace Symbol Provider

Reference Providers

Rename Provider

Semantic Tokens

Semantic Tokens Provider

Language Configuration

Setting Language Configuration

Advanced Providers

Code Lens Provider

Signature Help Provider

Inlay Hints

Best Practices

  • Return results quickly, use resolve methods for expensive operations
  • Respect cancellation tokens
  • Use document selectors to limit when providers are invoked
  • Cache parsed results when appropriate
  • Provide meaningful documentation and details
  • Use appropriate severity levels for diagnostics
  • Mark preferred code actions
  • Support both keyboard and mouse interactions
  • Validate positions and ranges
  • Handle edge cases (empty files, large files)
  • Provide accurate type information
  • Test with various language constructs