0.1.2 • Published 8 months ago

@gdquest/codemirror-lsp v0.1.2

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

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

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago