npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@neo4j-cypher/language-server

v2.0.0-next.9

Published

Cypher Language Server

Downloads

210

Readme

Language Server

A language server wrapper for the @neo4j-cypher/language-support package.

Installation

You can install the language server using npm:

npm i -g @neo4j-cypher/language-server

Usage

Once installed, you can run the language server using cypher-language-server --stdio.

Below you can find a few examples in Typescript on how to send messages to that server.

For integrations with other editors, see Integrating with other editors.

Using ipc

import * as child_process from 'child_process';

let lspProcess = child_process.spawn('cypher-language-server', ['--ipc']);
let messageId = 1;

function send(method: string, params: object) {
  let message = {
    jsonrpc: '2.0',
    id: messageId++,
    method: method,
    params: params,
  };
  lspProcess.send(message);
}

function initialize() {
  send('initialize', {
    rootPath: process.cwd(),
    processId: process.pid,
    capabilities: {
      /* ... */
    },
  });
}

lspProcess.on('message', function (json) {
  console.log(json);
});
initialize();

Using sockets

import * as net from 'net';
import * as child_process from 'child_process';
import * as rpc from 'vscode-jsonrpc/node';

let messageId = 1;
let reader: rpc.SocketMessageReader = null;
let writer: rpc.SocketMessageWriter = null;

function send(method: string, params: object) {
  let message = {
    jsonrpc: '2.0',
    id: messageId++,
    method: method,
    params: params,
  };
  writer.write(message);
}

function initialize() {
  send('initialize', {
    rootPath: process.cwd(),
    processId: process.pid,
    capabilities: {
      textDocument: {
        /* ... */
      },
      workspace: {
        /* ... */
      },
    },
  });
}

const server = net.createServer((socket: net.Socket) => {
  server.close();
  reader = new rpc.SocketMessageReader(socket);
  reader.listen((data) => {
    console.log(data);
  });
  writer = new rpc.SocketMessageWriter(socket);
  initialize();
});

server.listen(3000, () => {
  child_process.spawn('cypher-language-server', ['--socket=3000']);
});

Using stdio

import * as child_process from 'child_process';
import * as rpc from 'vscode-jsonrpc/node';

let lspProcess = child_process.spawn('cypher-language-server', ['--stdio']);
let messageId = 1;

const reader = new rpc.StreamMessageReader(lspProcess.stdout);
const writer = new rpc.StreamMessageWriter(lspProcess.stdin);

function send(method: string, params: object) {
  let message = {
    jsonrpc: '2.0',
    id: messageId++,
    method: method,
    params: params,
  };
  writer.write(message);
}

function initialize() {
  send('initialize', {
    rootPath: process.cwd(),
    processId: process.pid,
    capabilities: {
      /* ... */
    },
  });
}

reader.listen((data) => {
  console.log(data);
});

initialize();

Integrating with other editors

Emacs

With lsp-mode

As of version 8.0.1, lsp-mode provides built in support for the cypher-language-server. lsp-mode will connect to a cypher-language-server for any file ending with .cypher, or if you're currently in a cypher-mode.

If the cypher-language-server is not already installed, you can install the server by running M-x lsp-install-server RET and then selecting cypher-ls from the list.

With lsp-mode < 8.0.1
(with-eval-after-load 'lsp-mode
  (add-to-list 'lsp-language-id-configuration
  ;; '(cypher-mode . "cypher")) ;; use this if you have a cypher-mode installed
  '(".*cypher" . "cypher")) ;; otherwise, you can simply match on file ending with a regex

(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection '("cypher-language-server" "--stdio"))
  :activation-fn (lsp-activate-on "cypher")
  :server-id 'cypher)))

If you want semantic highlighting, remember to set

(setq lsp-semantic-tokens-enable t)
With eglot

As of Emacs 29, eglot is built in. In eglot, a language server needs to be associate with a specific major mode. Install any available cypher-mode in order to get the server running with eglot. Note also that eglot does not support semantic highlighting.

(add-to-list 'Eglot-server-programs '((cypher-mode) "cypher-language-server" "--stdio")))

Neovim

With nvim-lspconfig

There is built-in support for the cypher-language-server in the plugin (cypher_ls).

Activate the language server support in your config file.

require('lspconfig').cypher_ls.setup{}

The language server is registered for cypher files. To make neovim aware of this type, add a file to your neovim-configuration-path/ftdetect (if it does not exist, create one) folder, e.g. cypher.vim, defining the file suffix and file type.

au BufRead,BufNewFile *.cypher                set filetype=cypher