@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
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;
},
}),
],
});