Skip to content

Commit

Permalink
Makes language server executable using npx
Browse files Browse the repository at this point in the history
  • Loading branch information
ncordon committed Oct 26, 2023
1 parent e372093 commit 7b77f06
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 22 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
22 changes: 11 additions & 11 deletions packages/language-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ A language server wrapper for the `@neo4j-cypher/language-support` package.

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

### Bundling and usage from typescript
### Usage from typescript

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.

You can run the language server with `node ./cypher-language-server.js --stdio`.
You can run the language server with `npx @neo4j-cypher/language-server.js --stdio`.

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

Expand All @@ -21,8 +17,9 @@ 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('npx', [
'@neo4j-cypher/language-server',
'--ipc',
]);
let messageId = 1;

Expand Down Expand Up @@ -99,7 +96,10 @@ const server = net.createServer((socket: net.Socket) => {
});

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

Expand All @@ -109,8 +109,8 @@ 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',
let lspProcess = child_process.spawn('npx', [
'@neo4j-cypher/language-server',
'--stdio',
]);
let messageId = 1;
Expand Down
10 changes: 6 additions & 4 deletions packages/language-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,17 @@
"engines": {
"node": ">=18.18.2"
},
"bin": "./dist/cypher-ls-node.js",
"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-ls.js --minify",
"make-executable": "cd dist && echo '#!/usr/bin/env node' > cypher-language-server.js && cat cypher-ls.js >> cypher-language-server.js",
"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-ls.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
4 changes: 1 addition & 3 deletions packages/vscode-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ let client: LanguageClient;

export function activate(context: ExtensionContext) {
// The server is implemented in node
const runServer = context.asAbsolutePath(
path.join('dist', 'cypher-language-server.js'),
);
const runServer = context.asAbsolutePath(path.join('dist', 'cypher-ls.js'));
const debugServer = context.asAbsolutePath(
path.join('..', 'language-server', 'dist', 'server.js'),
);
Expand Down

0 comments on commit 7b77f06

Please sign in to comment.