Skip to main content

Developer Hub

API Recipes

A focused guide for the api recipes stage of extension development. coc.nvim extensions expose an activate(context) entry point to the Node.js extension host.

API recipes

Use disposables from registration calls and push them to context.subscriptions. Read the linked signature before copying an example.

src/index.ts
1import { commands, ExtensionContext, window } from 'coc.nvim'
2 
3export function activate(context: ExtensionContext): void {
4 const disposable = commands.registerCommand('coc-demo.hello', () => {
5 window.showInformationMessage('Hello from coc-demo')
6 })
7 context.subscriptions.push(disposable)
8}
For every registration, keep the returned Disposable in context.subscriptions. Check a CancellationToken before expensive work, and return promptly when cancellation is requested. The typings reference is generated from the pinned coc.nvim TypeScript declarations; a language server is supplied separately by an extension.