UNPKG

@gdquest/codemirror-lsp

Version:

Enables Codemirror to interact with a local lsp, ie. a LSP that isn't socket-based, but rather work by function calls.

40 lines (31 loc) 931 B
# @gdquest/codemirror-lsp ## `lsp` extension ### Purpose This extension enables Codemirror interact with a local lsp, ie. a LSP that isn't socket-based, but rather work by function calls. ### Usage ```typescript import { basicSetup } from "codemirror"; import { EditorView } from "@codemirror/view"; import { createLsp, type LspConfigData, type ServerResponseCallback, } from "@gdquest/codemirror-lsp"; // Call this function when the server needs to communicate with the LSP let emitServerCommand: ServerResponseCallback | null = null; function onClientCommand(jsonRpc: string) { // This function is called when codemirror (the client) needs to communicate with the server } new EditorView({ extensions: [ basicSetup, createLsp({ autocompletion: true, onClientCommand, getData: (data: LspConfigData) => { emitServerCommand = data.emitServerCommand; }, }), ], }); ```