Skip to content

Commit

Permalink
Prepare for extension publishing (#180)
Browse files Browse the repository at this point in the history
* prep for vscode

* readme cleanup

* touchups

* wording

* self reivew

* self reivew

* self reivew

* fix crash

* renames settings

* clarity

* rename to connectionURL

* review

* rename setting

* fix lock file

* updatebuildscript

* also include lang config
  • Loading branch information
OskarDamkjaer authored Mar 5, 2024
1 parent 7f3e3ff commit 2cd3281
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 61 deletions.
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Occasionally, we might also have logistical, commercial, or legal reasons why we
Pre-requisites:

- Node.js LTS (18.x)
- [Git LFS](https://git-lfs.github.com/) easiest to install via package manager (e.g. `brew install git-lfs` on macOS)
- [antlr4-tools](https://github.com/antlr/antlr4-tools) easiest to install with `pip install antlr4-tools` (python3 required)

In the root folder of the project run:
Expand All @@ -26,4 +27,4 @@ From here you can start the `react-codemirror-playground` with:

`npm run dev:codemirror`

To run the VSCode extension, see the `vscode-extension` [README.md](./packages/vscode-extension/).
To run the VS Code extension, choose `VSCode Playground` in the `Run & Debug` menu in VS Code.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This mono repo contains packages that together make up Neo4j's Cypher Language s

The project is in an early stage. We are still missing important features and the project is not yet stable. We welcome feedback and contributions!

Try it out in our [demo](https://neo4j.github.io/cypher-language-support/) or in our alpha releases in [Neo4j Workspace](https://workspace.neo4j.io) and soon also in our VSCode extension.
Try it out in our [demo](https://neo4j.github.io/cypher-language-support/) or in our alpha releases in [Neo4j Workspace](https://workspace.neo4j.io) and soon also in our VS Code extension.

## Project Overview

Expand All @@ -16,7 +16,7 @@ The project comprises several packages:

- [language-support](./packages/language-support/README.md) - The core library implementing the language support features.
- [language-server](./packages/language-server/README.md) - The language server wrapper for the `language-support` package.
- [vscode-extension](./packages/vscode-extension/README.md) - The Neo4j VSCode extension which bundles the `language-server`
- [vscode-extension](./packages/vscode-extension/README.md) - The Neo4j VS Code extension which bundles the `language-server`
- [react-codemirror](./packages/react-codemirror/README.md) - A set of [codemirror6](https://codemirror.net/) cypher language support plugins and a react wrapper.
- [react-codemirror-playground](./packages/react-codemirror-playground/README.md) - A playground for the codemirror integration.
- [schema-poller](./packages/schema-poller/README.md) - An internal package we use to manage the Neo4j connection and keep the schema (procedure names, labels, database names, etc.) up to date in the language server.
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/language-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@
"workerpool": "^9.0.4"
},
"scripts": {
"build": "tsc -b && npm run bundle && npm run make-executable",
"build": "tsc -b && npm run bundle && npm run make-executable && npm run bundle-worker",
"bundle": "esbuild ./src/server.ts --bundle --format=cjs --platform=node --outfile=dist/cypher-language-server.js --minify",
"bundle-worker": "esbuild ./src/lintWorker.ts --bundle --format=cjs --platform=node --outfile=dist/lintWorker.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
4 changes: 2 additions & 2 deletions packages/language-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ connection.onDidChangeConfiguration(
neo4jSdk.connection === undefined &&
neo4jConfig.connect &&
neo4jConfig.password &&
neo4jConfig.URL &&
neo4jConfig.connectURL &&
neo4jConfig.user
) {
void neo4jSdk.persistentConnect(
neo4jConfig.URL,
neo4jConfig.connectURL,
{
username: neo4jConfig.user,
password: neo4jConfig.password,
Expand Down
2 changes: 1 addition & 1 deletion packages/language-server/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export type Neo4jSettings = {
};
connect?: boolean;
password?: string;
URL?: string;
connectURL?: string;
user?: string;
};
2 changes: 1 addition & 1 deletion packages/language-support/src/signatureHelp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface ParsedMethod {
}

function toSignatureHelp(
methodSignatures: Record<string, SignatureInformation>,
methodSignatures: Record<string, SignatureInformation> = {},
parsedMethod: ParsedMethod,
) {
const methodName = parsedMethod.methodName;
Expand Down
10 changes: 10 additions & 0 deletions packages/language-support/src/tests/signatureHelp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ describe('Procedures signature help', () => {
63,
);
});

test('Does not crash on missing schema', () => {
testSignatureHelp(`CALL apoc.do.when`, undefined, emptyResult);
testSignatureHelp(`CALL apoc.do.when`, {}, emptyResult);
});
});

describe('Functions signature help', () => {
Expand Down Expand Up @@ -391,4 +396,9 @@ describe('Functions signature help', () => {
89,
);
});

test('Does not crash on missing schema', () => {
testSignatureHelp(`CALL apoc.do.when`, undefined, emptyResult);
testSignatureHelp(`CALL apoc.do.when`, {}, emptyResult);
});
});
22 changes: 11 additions & 11 deletions packages/vscode-extension/.vscodeignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
dist/
!dist/extension.js
!dist/cypher-language-server.js
# Ignore everything, https://github.com/microsoft/vscode-vsce/issues/12
**
# Required for the ignore everything rule to work from testing
../../
../
node_modules
out/
src/
e2e_tests/
tsconfig.json
webpack.config.js
.turbo
.vscode

# Unignore only required files, readme/package.json automatically included
!LICENSE.md
!images/
!dist/extension.js
!dist/lintWorker.js
!dist/cypher-language-server.js
!cypher-language-configuration.json
51 changes: 29 additions & 22 deletions packages/vscode-extension/README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
# VSCode Extension
# Neo4j for VS Code Preview

This is a VScode extension playground for testing the Cypher language server.
## Getting started

It's not yet published on the VSCode Marketplace, so to test it you need to run it locally.
After installing the extension from the VS Code Marketplace, open a file with a `.cypher` to start using the extension. To enable database aware features (such as completing labels/functions), set up a connection to a Neo4j instance using the settings described in the settings section below.

For running it, compile the code first:
## Feature Highlights

```
npm install
npm run build
```
Our extension preview provides a rich set of features for working with Cypher, the query language for Neo4j databases, including:

To launch a new VSCode window with the extension installed go to the `Run & Debug` tab (normally in the left pannel), select and run `VSCode Playground` clicking on the play ▷ button.
- Syntax highlighting
- Syntax checking - both simple and semantic errors (e.g. type errors, unknown labels, etc)
- Autocompletion for Cypher keywords, functions, labels, properties, database names and more
- Signature help for functions - shows the signature of the function while typing

This will open a new window where we can open our folder of choice, create a file with `.cypher` extension and start typing cypher helped by the language support.
![demo-gif](https://github.com/neo4j/cypher-language-support/blob/main/packages/vscode-extension/images/demo.gif?raw=true)

## Plugin settings
## Upcoming features

For database aware features (such as autocompleting labels, procedure names, etc), you can connect to a running database (Aura, neo4j docker, etc) by tweaking the playground settings, in the opened window.
We're working on adding more features to the extension, such as:

The following settings are available in VSCode once the plugin is installed, which can be set either through the `Settings` menu on VSCode or by creating a `.vscode/settings.json` file in the window opened by the play button.
- Easier database connection management
- Embedded cypher support in other file types
- Query exectution and result visualization
- Automatic query formatting

### Settings for database connection
## Extension settings

The following settings refer to the database connection used for signature loading, this will allow for autocomplete on Labels and Types.
The following settings are available in VS Code once the plugin is installed, which can be set either through the `Settings` menu on VS Code or by editing your `.vscode/settings.json` file.

- `cypherLSP.neo4j.connect`: If true it will attempt to connect to a Neo4j database to retrieve signature information. Defaults to `true`.
- `cypherLSP.neo4j.user`: Defaults to `"neo4j"`
- `cypherLSP.neo4j.password`: Defaults to `"password"`
- `cypherLSP.neo4j.URL`: Defaults to `"bolt://localhost:7687"`

![](../../imgs/vscode-playground.png)
- `neo4j.connect`: If true it will attempt to connect to a Neo4j database to retrieve data used for completions. Defaults to `true`
- `neo4j.connectURL`: Defaults to `"neo4j://localhost:7687"`, the default url for connecting a local Neo4j instance over websocket via the `bolt` protocol
- `neo4j.user`: Defaults to `"neo4j"`, the default user for a local Neo4j instance
- `neo4j.password`: Replace this with the password for the user above

### Debug

- `cypherLSP.trace.server`: Traces the communication between VS Code and the language server for debugging purposes.
- `neo4j.trace.server`: Traces the communication between VS Code and the language server for debugging purposes

## Contributing

We welcome your suggestions, ideas, bug reports and contributions on our [github](https://github.com/neo4j/cypher-language-support).

To build the project locally, see the [CONTRIBUTING.md](https://github.com/neo4j/cypher-language-support/blob/main/CONTRIBUTING.md) file at the root of the git repository.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"neo4j.connect": true,
"neo4j.password": "{PASSWORD}",
"neo4j.URL": "neo4j://localhost:{PORT}",
"neo4j.connectURL": "neo4j://localhost:{PORT}",
"neo4j.user": "neo4j",
"neo4j.trace.server": "off"
}
3 changes: 3 additions & 0 deletions packages/vscode-extension/images/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/vscode-extension/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 24 additions & 14 deletions packages/vscode-extension/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
{
"name": "neo4j-cypher-vscode-extension",
"private": true,
"description": "Enables support for Neo4j and its query language Cypher",
"name": "neo4j-vscode",
"displayName": "Neo4j for VS Code",
"description": "Highlighting, completions and more for Neo4j Cypher in VS Code",
"publisher": "neo4j-extensions",
"author": "Neo4j Inc.",
"license": "Apache-2.0",
"version": "2.0.0-next.4",
"publisher": "Neo4j Inc.",
"activationEvents": [
"onLanguage:cypher"
"preview": true,
"categories": [
"Programming Languages",
"Linters"
],
"keywords": [
"cypher",
"neo4j",
"graph",
"database",
"completions"
],
"icon": "images/logo.png",
"main": "./dist/extension.js",
"repository": {
"type": "git",
Expand Down Expand Up @@ -36,7 +46,7 @@
}
],
"configuration": {
"title": "Cypher LSP",
"title": "Neo4j for VS Code",
"properties": {
"neo4j.trace.server": {
"scope": "window",
Expand All @@ -53,25 +63,25 @@
"order": 1,
"type": "boolean",
"default": true,
"description": "Shall connect to Neo4j to gather data about labels and types."
"description": "Whether to connect to Neo4j for database aware completions."
},
"neo4j.URL": {
"neo4j.connectURL": {
"order": 2,
"type": "string",
"default": "bolt://localhost:7687",
"description": "Url of the database to connect."
"default": "neo4j://localhost:7687",
"description": "URL of the Neo4j instance to poll data from, `bolt` & `neo4j` protocols supported."
},
"neo4j.user": {
"order": 3,
"type": "string",
"default": "neo4j",
"description": "Username of the database to connect."
"description": "Username for the database connection."
},
"neo4j.password": {
"order": 4,
"type": "string",
"default": "password",
"description": "Password of the database to connect."
"description": "Password for the database connection."
}
}
},
Expand All @@ -83,7 +93,7 @@
},
"scripts": {
"vscode:prepublish": "npm run build",
"bundle-language-server": "cd ../language-server && npm run bundle && cp dist/cypher-language-server.js ../vscode-extension/dist/ && cp dist/lintWorker.js ../vscode-extension/dist/",
"bundle-language-server": "cd ../language-server && npm run bundle && cp dist/cypher-language-server.js ../vscode-extension/dist/ && npm run bundle-worker && cp dist/lintWorker.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",
Expand Down

0 comments on commit 2cd3281

Please sign in to comment.