Skip to content

Commit

Permalink
Makes language server executable (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
ncordon authored Oct 26, 2023
1 parent dd5b63d commit a05f617
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 23 deletions.
6 changes: 6 additions & 0 deletions .changeset/nervous-rabbits-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'neo4j-cypher-vscode-extension': patch
'@neo4j-cypher/language-server': patch
---

Makes language server executable with npx
6 changes: 5 additions & 1 deletion .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@
"antlr4": "4.13.1",
"antlr4-c3": "3.0.1"
},
"changesets": ["brown-ravens-obey", "fuzzy-rice-train"]
"changesets": [
"brown-ravens-obey",
"fuzzy-rice-train",
"nervous-rabbits-greet"
]
}
6 changes: 6 additions & 0 deletions packages/language-server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @neo4j-cypher/language-server

## 2.0.0-next.1

### Patch Changes

- Makes language server executable with npx

## 2.0.0-next.0

### Major Changes
Expand Down
23 changes: 9 additions & 14 deletions packages/language-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ A language server wrapper for the `@neo4j-cypher/language-support` package.

## Installation

We will provide a quick way to install the serer via npm soon™️. For now you can build it yourself, see instructions below.
You can install the language server using npm:

### Bundling and usage from typescript
```
npm i -g @neo4j-cypher/language-server
```

To package the language server into a single javascript bundle, go to the root of the project and
do `npm run build`.
After that a file `./packages/language-server/dist/cypher-language-server.js` will be generated.
### Usage

You can run the language server with `node ./cypher-language-server.js --stdio`.
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.

Expand All @@ -21,9 +21,7 @@ Below you can find a few examples in Typescript on how to send messages to that
```typescript
import * as child_process from 'child_process';

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

function send(method: string, params: object) {
Expand Down Expand Up @@ -99,7 +97,7 @@ const server = net.createServer((socket: net.Socket) => {
});

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

Expand All @@ -109,10 +107,7 @@ server.listen(3000, () => {
import * as child_process from 'child_process';
import * as rpc from 'vscode-jsonrpc/node';

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

const reader = new rpc.StreamMessageReader(lspProcess.stdout);
Expand Down
14 changes: 9 additions & 5 deletions packages/language-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"author": "Neo4j Inc.",
"license": "Apache-2.0",
"files": [
"./dist/cypher-language-server.js",
"./dist/cypher-language-server",
"./src",
"package.json",
"README.md",
Expand All @@ -16,8 +16,8 @@
"cypher",
"language server"
],
"version": "2.0.0-next.0",
"main": "./dist/cypher-language-server.js",
"version": "2.0.0-next.1",
"main": "./dist/server.js",
"types": "src/server.ts",
"repository": {
"type": "git",
Expand All @@ -30,15 +30,19 @@
"engines": {
"node": ">=18.18.2"
},
"bin": {
"cypher-language-server": "./dist/cypher-language-server"
},
"dependencies": {
"@neo4j-cypher/language-support": "2.0.0-next.0",
"neo4j-driver": "^5.3.0",
"vscode-languageserver": "^8.1.0",
"vscode-languageserver-textdocument": "^1.0.8"
},
"scripts": {
"build": "tsc -b && npm run bundle",
"bundle": "esbuild ./src/server.ts --bundle --format=cjs --platform=node --outfile=dist/cypher-language-server.js",
"build": "tsc -b && npm run bundle && npm run make-executable",
"bundle": "esbuild ./src/server.ts --bundle --format=cjs --platform=node --outfile=dist/cypher-language-server.js --minify",
"make-executable": "cd dist && echo '#!/usr/bin/env node' > cypher-language-server && cat cypher-language-server.js >> cypher-language-server",
"clean": "rm -rf dist",
"watch": "tsc -b -w"
},
Expand Down
8 changes: 8 additions & 0 deletions packages/vscode-extension/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @neo4j-cypher/vscode-extension

## 2.0.0-next.1

### Patch Changes

- Makes language server executable with npx
- Updated dependencies
- @neo4j-cypher/language-server@2.0.0-next.1

## 2.0.0-next.0

### Major Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Enables support for Neo4j and its query language Cypher",
"author": "Neo4j Inc.",
"license": "Apache-2.0",
"version": "2.0.0-next.0",
"version": "2.0.0-next.1",
"publisher": "Neo4j Inc.",
"activationEvents": [
"onLanguage:cypher"
Expand Down Expand Up @@ -83,14 +83,14 @@
},
"scripts": {
"vscode:prepublish": "npm run build",
"bundle-language-server": "cd ../language-server && npm run bundle -- --minify && cp dist/cypher-language-server.js ../vscode-extension/dist/",
"bundle-language-server": "cd ../language-server && npm run bundle && cp dist/cypher-language-server.js ../vscode-extension/dist/",
"bundle-extension": "esbuild ./src/extension.ts --bundle --external:vscode --format=cjs --platform=node --minify --outfile=dist/extension.js",
"build": "tsc -b && npm run bundle-extension && npm run bundle-language-server",
"clean": "rm -rf dist",
"test:e2e": "npm run build && rm -rf .vscode-test/user-data && node ./dist/e2e_tests/main.js"
},
"dependencies": {
"@neo4j-cypher/language-server": "2.0.0-next.0",
"@neo4j-cypher/language-server": "2.0.0-next.1",
"vscode-languageclient": "^8.1.0"
},
"devDependencies": {
Expand Down

0 comments on commit a05f617

Please sign in to comment.