@gdquest/codemirror-lsp
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

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

Package Sidebar

Install

npm i @gdquest/codemirror-lsp

Weekly Downloads

8

Version

0.1.2

License

MIT

Unpacked Size

184 kB

Total Files

23

Last publish

Collaborators

  • adamscott
  • razcore-rad
  • nathan_gdquest
  • xananax