mirror of
https://github.com/godotengine/godot-vscode-plugin.git
synced 2026-01-01 17:48:36 +03:00
Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d404eaedc6 | ||
|
|
854ec42027 | ||
|
|
281c78f133 | ||
|
|
a254b55aa5 | ||
|
|
1be4ccaaad | ||
|
|
1755e2f3c3 | ||
|
|
f9a5204dcf | ||
|
|
62cb49e506 | ||
|
|
c347a522a3 | ||
|
|
293cc8c1fb | ||
|
|
f21d7517c4 | ||
|
|
314288b592 | ||
|
|
c3c615825d | ||
|
|
6ebc866ce1 | ||
|
|
fb498a7502 | ||
|
|
ee80ea914b | ||
|
|
158c0c38bf | ||
|
|
f1e57e5443 | ||
|
|
e78a8b8f86 | ||
|
|
c03ab7e3f5 | ||
|
|
12858a2e05 | ||
|
|
355c0f8614 | ||
|
|
650170ce13 | ||
|
|
1b358fadec | ||
|
|
20dc0445c3 | ||
|
|
1a932d5283 | ||
|
|
975acd7aa4 | ||
|
|
1ec75dc622 | ||
|
|
6fe93c9c6b | ||
|
|
363160ee3b | ||
|
|
9fa3031699 | ||
|
|
ce30e6ed95 | ||
|
|
2364664f7a | ||
|
|
21cfd82f4d | ||
|
|
29f1bc0ceb | ||
|
|
338b6ae977 | ||
|
|
71a4a0420d | ||
|
|
383dcc9507 | ||
|
|
5c5c19b534 | ||
|
|
91da651444 | ||
|
|
f2a6288276 | ||
|
|
a8872c2e56 | ||
|
|
e9f674d9e7 |
71
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
71
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
name: Bug report
|
||||
description: Report a bug in Godot Tools VS Code add-on
|
||||
labels:
|
||||
- bug
|
||||
body:
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
- Write a descriptive issue title above.
|
||||
- Search [open](https://github.com/godotengine/godot-vscode-plugin/issues) and [closed](https://github.com/godotengine/godot-vscode-plugin/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported.
|
||||
- Verify that you are using a [supported Godot version](https://docs.godotengine.org/en/stable/about/release_policy.html).
|
||||
- This repository only contains the LSP *client*. Issues pertaining to the Godot editor itself or the LSP's *server* side should be reported on the [main Godot repository](https://github.com/godotengine/godot/issues).
|
||||
|
||||
- type: input
|
||||
attributes:
|
||||
label: Godot version
|
||||
description: >
|
||||
Specify the Git commit hash if using a development or non-official build.
|
||||
If you use a custom build, please test if your issue is reproducible in official builds too.
|
||||
placeholder: 3.3.stable, 4.0.dev (3041becc6)
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
attributes:
|
||||
label: VS Code version
|
||||
description: >
|
||||
Use the **Help > About** menu to see your current version.
|
||||
Specify the Git commit hash if using a development or non-official build.
|
||||
If you use a custom build, please test if your issue is reproducible in official builds too.
|
||||
placeholder: "1.64.2"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
attributes:
|
||||
label: Godot Tools VS Code extension version
|
||||
description: >
|
||||
Open the **Extensions** side panel and click on the **godot-tools** extension to see your current version.
|
||||
Specify the Git commit hash if using a development or non-official build.
|
||||
If you use a custom build, please test if your issue is reproducible in official builds too.
|
||||
placeholder: "1.2.0"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
attributes:
|
||||
label: System information
|
||||
description: |
|
||||
Specify the OS version, and when relevant hardware information.
|
||||
placeholder: Windows 10
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Issue description
|
||||
description: |
|
||||
Describe your issue briefly. What doesn't work, and how do you expect it to work instead?
|
||||
You can include images or videos with drag and drop, and format code blocks or logs with <code>```</code> tags.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: |
|
||||
List of steps or sample code that reproduces the issue. Having reproducible issues is a prerequisite for contributors to be able to solve them.
|
||||
validations:
|
||||
required: true
|
||||
6
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
6
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
blank_issues_enabled: false
|
||||
|
||||
contact_links:
|
||||
- name: Godot community channels
|
||||
url: https://godotengine.org/community
|
||||
about: Please ask for technical support on one of the other community channels, not here.
|
||||
71
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
71
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
name: Feature request
|
||||
description: Request a new feature to be added or improved in Godot Tools VS Code add-on
|
||||
labels:
|
||||
- enhancement
|
||||
body:
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
- Write a descriptive issue title above.
|
||||
- Search [open](https://github.com/godotengine/godot-vscode-plugin/issues) and [closed](https://github.com/godotengine/godot-vscode-plugin/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported.
|
||||
- Verify that you are using a [supported Godot version](https://docs.godotengine.org/en/stable/about/release_policy.html).
|
||||
- This repository only contains the LSP *client*. Issues pertaining to the Godot editor itself or the LSP's *server* side should be reported on the [main Godot repository](https://github.com/godotengine/godot/issues).
|
||||
|
||||
- type: input
|
||||
attributes:
|
||||
label: Godot version
|
||||
description: >
|
||||
Specify the Git commit hash if using a development or non-official build.
|
||||
If you use a custom build, please test if your issue is reproducible in official builds too.
|
||||
placeholder: 3.3.stable, 4.0.dev (3041becc6)
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
attributes:
|
||||
label: VS Code version
|
||||
description: >
|
||||
Use the **Help > About** menu to see your current version.
|
||||
Specify the Git commit hash if using a development or non-official build.
|
||||
If you use a custom build, please test if your issue is reproducible in official builds too.
|
||||
placeholder: "1.64.2"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
attributes:
|
||||
label: Godot Tools VS Code extension version
|
||||
description: >
|
||||
Open the **Extensions** side panel and click on the **godot-tools** extension to see your current version.
|
||||
Specify the Git commit hash if using a development or non-official build.
|
||||
If you use a custom build, please test if your issue is reproducible in official builds too.
|
||||
placeholder: "1.2.0"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
attributes:
|
||||
label: System information
|
||||
description: |
|
||||
Specify the OS version, and when relevant hardware information.
|
||||
placeholder: Windows 10
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Problem statement
|
||||
description: |
|
||||
Describe the problem or limitation you're currently facing with the Godot Tools extension.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Proposed solution
|
||||
description: |
|
||||
Describe your proposed solution and how it resolves the problem or limitation mentioned above.
|
||||
You can include images or videos with drag and drop, and format code blocks or logs with <code>```</code> tags.
|
||||
validations:
|
||||
required: true
|
||||
9
.github/workflows/ci.yml
vendored
9
.github/workflows/ci.yml
vendored
@@ -6,18 +6,19 @@ jobs:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v2.1.2
|
||||
uses: actions/setup-node@v3.1.0
|
||||
with:
|
||||
node-version: 12.x
|
||||
node-version: 16.x
|
||||
|
||||
- name: Lint and build extension
|
||||
run: |
|
||||
npm install
|
||||
npm run lint
|
||||
node_modules/.bin/vsce package --out godot-tools.vsix
|
||||
npm run package -- --out godot-tools.vsix
|
||||
ls -l godot-tools.vsix
|
||||
|
||||
- name: Upload extension VSIX
|
||||
uses: actions/upload-artifact@v2
|
||||
|
||||
19
CHANGELOG.md
19
CHANGELOG.md
@@ -1,5 +1,24 @@
|
||||
# Change Log
|
||||
|
||||
### 1.2.0
|
||||
* [Add support for setting language-server-host](https://github.com/godotengine/godot-vscode-plugin/pull/297)
|
||||
* [Improve syntax highlighting](https://github.com/godotengine/godot-vscode-plugin/pull/330)
|
||||
* [Update LSP client to 7.0.0 to use the 3.16.0 specification](https://github.com/godotengine/godot-vscode-plugin/pull/264)
|
||||
* [Fix some `$` node path shorthand regex bugs in syntax highlighting](https://github.com/godotengine/godot-vscode-plugin/pull/340)
|
||||
* [Fix handling of Windows terminals determined by profiles](https://github.com/godotengine/godot-vscode-plugin/pull/303)
|
||||
* [Fix "static func" indent error](https://github.com/godotengine/godot-vscode-plugin/pull/279)
|
||||
* [Fix restart of debugging sessions](https://github.com/godotengine/godot-vscode-plugin/pull/327)
|
||||
* [Use the LSP defined SymbolKind enum and fix marked](https://github.com/godotengine/godot-vscode-plugin/pull/325)
|
||||
* [Fix "Continue" for multiple breakpoints in the same script](https://github.com/godotengine/godot-vscode-plugin/pull/324)
|
||||
|
||||
### 1.1.3
|
||||
* [Fix conditional breakpoints being parsed as regular breakpoints](https://github.com/godotengine/godot-vscode-plugin/pull/278)
|
||||
- [Add `in` to the list of keywords and add rule for `$` shorthand](https://github.com/godotengine/godot-vscode-plugin/pull/274)
|
||||
- [Fix typo in snippets: "decleration" -> "declaration"](https://github.com/godotengine/godot-vscode-plugin/pull/262)
|
||||
- [Add `remote` keyword to syntax highlighting](https://github.com/godotengine/godot-vscode-plugin/pull/257)
|
||||
- [Remove the configuration item `godot-tools.check_config` as it has no effect](https://github.com/godotengine/godot-vscode-plugin/pull/246)
|
||||
- [Fix the syntax of escaped characters in strings](https://github.com/godotengine/godot-vscode-plugin/pull/247)
|
||||
|
||||
### 1.1.1
|
||||
* Fix bug for GDScript debugger
|
||||
* Add TCP protocol support for GDScript language server Godot 3.2.2
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2016-2019 The Godot Engine community
|
||||
Copyright (c) 2016-2022 The Godot Engine community
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -44,6 +44,7 @@ for Godot by following these steps:
|
||||
2. Select **Text Editor > External**
|
||||
3. Make sure the **Use External Editor** box is checked
|
||||
4. Fill **Exec Path** with the path to your VS Code executable
|
||||
* On macOS, this executable is typically located at: `/Applications/Visual Studio Code.app/Contents/MacOS/Electron`
|
||||
5. Fill **Exec Flags** with `{project} --goto {file}:{line}:{col}`
|
||||
|
||||
### VS Code
|
||||
@@ -103,14 +104,12 @@ for the latest changes.
|
||||
#### Requirements
|
||||
|
||||
- [npm](https://www.npmjs.com/get-npm)
|
||||
- Typescript to compile, installed using npm with `npm install -g typescript`
|
||||
- VSCE to create a VSIX file, installed using npm with `npm install -g vsce`
|
||||
|
||||
#### Process
|
||||
|
||||
1. Open a command prompt/terminal and browse to the location of this repository on your local filesystem.
|
||||
2. Download dependencies by using the command `npm install`
|
||||
3. When done, package a VSIX file by using the command `vsce package`.
|
||||
3. When done, package a VSIX file by using the command `npm run package`.
|
||||
4. Install it by opening Visual Studio Code, opening the Extensions tab, clicking on the More actions (**...**) button in the top right, and choose **Install from VSIX...** and find the compiled VSIX file.
|
||||
|
||||
When developing for the extension, you can open this project in Visual Studio Code and debug the extension by using the **Run Extension** launch configuration instead of going through steps 3 and 4. It will launch a new instance of Visual Studio Code that has the extension running. You can then open a Godot project folder and debug the extension or GDScript debugger.
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
["{", "}"]
|
||||
],
|
||||
"indentationRules": {
|
||||
"increaseIndentPattern": "^\\s*((class|func|else|elif|for|if|match|while|enum)|(.*\\sdo\\b))\\b[^\\{;]*$",
|
||||
"increaseIndentPattern": "^\\s*((class|static func|func|else|elif|for|if|match|while|enum)|(.*\\sdo\\b))\\b[^\\{;]*$",
|
||||
"decreaseIndentPattern": "^\\s*([}\\]]([,)]?\\s*(#|$)|\\.[a-zA-Z_]\\w*\\b)|(else|elif)\\b)"
|
||||
},
|
||||
"folding": {
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
]
|
||||
},
|
||||
|
||||
"signal decleration": {
|
||||
"signal declaration": {
|
||||
"prefix": "signal",
|
||||
"body": [
|
||||
"signal ${1:signalname}(${2:args})"
|
||||
|
||||
BIN
icon.png
BIN
icon.png
Binary file not shown.
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.4 KiB |
979
package-lock.json
generated
979
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
41
package.json
41
package.json
@@ -2,20 +2,27 @@
|
||||
"name": "godot-tools",
|
||||
"displayName": "godot-tools",
|
||||
"icon": "icon.png",
|
||||
"version": "1.1.2",
|
||||
"description": "Tools for game development with godot game engine",
|
||||
"version": "1.2.0",
|
||||
"description": "Tools for game development with Godot Engine and GDScript",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/godotengine/godot-vscode-plugin"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/godotengine/godot-vscode-plugin/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": "The Godot Engine community",
|
||||
"publisher": "geequlim",
|
||||
"engines": {
|
||||
"vscode": "^1.33.0"
|
||||
},
|
||||
"categories": [
|
||||
"Other",
|
||||
"Debuggers"
|
||||
"Programming Languages",
|
||||
"Linters",
|
||||
"Snippets",
|
||||
"Debuggers",
|
||||
"Other"
|
||||
],
|
||||
"activationEvents": [
|
||||
"workspaceContains:project.godot",
|
||||
@@ -27,7 +34,8 @@
|
||||
"vscode:prepublish": "npm run compile",
|
||||
"compile": "tsc -p ./",
|
||||
"lint": "tslint -p ./",
|
||||
"watch": "tsc -watch -p ./"
|
||||
"watch": "tsc -watch -p ./",
|
||||
"package": "vsce package"
|
||||
},
|
||||
"contributes": {
|
||||
"commands": [
|
||||
@@ -99,6 +107,11 @@
|
||||
],
|
||||
"description": "The server protocol of the GDScript language server.\nYou have restart VSCode editor after change this value."
|
||||
},
|
||||
"godot_tools.gdscript_lsp_server_host": {
|
||||
"type": "string",
|
||||
"default": "127.0.0.1",
|
||||
"description": "The server host of the GDScript language server"
|
||||
},
|
||||
"godot_tools.gdscript_lsp_server_port": {
|
||||
"type": "number",
|
||||
"default": 6008,
|
||||
@@ -289,23 +302,23 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/marked": "^0.6.5",
|
||||
"@types/mocha": "^2.2.42",
|
||||
"@types/mocha": "^9.1.0",
|
||||
"@types/node": "^10.12.21",
|
||||
"@types/prismjs": "^1.16.0",
|
||||
"@types/prismjs": "^1.16.8",
|
||||
"@types/vscode": "^1.33.0",
|
||||
"@types/ws": "^6.0.1",
|
||||
"tslint": "^5.16.0",
|
||||
"@types/ws": "^8.2.2",
|
||||
"tslint": "^5.20.1",
|
||||
"typescript": "^3.5.1",
|
||||
"vsce": "^1.76.1"
|
||||
"vsce": "^2.6.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"await-notify": "^1.0.1",
|
||||
"global": "^4.4.0",
|
||||
"marked": "^0.7.0",
|
||||
"marked": "^4.0.11",
|
||||
"net": "^1.0.2",
|
||||
"terminate": "^2.1.2",
|
||||
"terminate": "^2.5.0",
|
||||
"vscode-debugadapter": "^1.38.0",
|
||||
"vscode-languageclient": "^5.2.1",
|
||||
"ws": "^7.0.0"
|
||||
"vscode-languageclient": "^7.0.0",
|
||||
"ws": "^8.4.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,8 +82,9 @@ export class GodotDebugData {
|
||||
|
||||
bps.push(bp);
|
||||
|
||||
let out_file = `res://${path.relative(this.project_path, bp.file)}`;
|
||||
|
||||
Mediator.notify("set_breakpoint", [out_file.replace(/\\/g, "/"), line]);
|
||||
if (this.project_path) {
|
||||
let out_file = `res://${path.relative(this.project_path, bp.file)}`;
|
||||
Mediator.notify("set_breakpoint", [out_file.replace(/\\/g, "/"), line]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +89,7 @@ export class GodotDebugSession extends LoggingDebugSession {
|
||||
args: DebugProtocol.ConfigurationDoneArguments
|
||||
) {
|
||||
this.configuration_done.notify();
|
||||
this.sendResponse(response);
|
||||
}
|
||||
|
||||
public set_scopes(
|
||||
@@ -236,7 +237,7 @@ export class GodotDebugSession extends LoggingDebugSession {
|
||||
args.launch_scene,
|
||||
get_configuration("scene_file_config", "") || args.scene_file,
|
||||
]);
|
||||
|
||||
|
||||
this.sendResponse(response);
|
||||
}
|
||||
|
||||
@@ -298,7 +299,10 @@ export class GodotDebugSession extends LoggingDebugSession {
|
||||
});
|
||||
client_lines.forEach((l) => {
|
||||
if (bp_lines.indexOf(l) === -1) {
|
||||
this.debug_data.set_breakpoint(path, l);
|
||||
let bp = args.breakpoints.find((bp_at_line) => (bp_at_line.line == l));
|
||||
if (!bp.condition) {
|
||||
this.debug_data.set_breakpoint(path, l);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ export class GodotTools {
|
||||
|
||||
private open_workspace_with_editor(params = "") {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
let valid = false;
|
||||
if (this.workspace_dir) {
|
||||
let cfg = path.join(this.workspace_dir, this.project_file);
|
||||
@@ -79,18 +79,51 @@ export class GodotTools {
|
||||
|
||||
private run_editor(params = "") {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
const run_godot = (path: string, params: string) => {
|
||||
const is_powershell_path = (path?: string) => {
|
||||
const POWERSHELL = "powershell.exe";
|
||||
const POWERSHELL_CORE = "pwsh.exe";
|
||||
return path && (path.endsWith(POWERSHELL) || path.endsWith(POWERSHELL_CORE));
|
||||
};
|
||||
const escape_command = (cmd: string) => {
|
||||
let cmdEsc = `"${cmd}"`;
|
||||
const cmdEsc = `"${cmd}"`;
|
||||
if (process.platform === "win32") {
|
||||
const POWERSHELL = "powershell.exe";
|
||||
const POWERSHELL_CORE = "pwsh.exe";
|
||||
const shell_plugin = vscode.workspace.getConfiguration("terminal.integrated.shell");
|
||||
let shell = (shell_plugin ? shell_plugin.get("windows", POWERSHELL) : POWERSHELL) || POWERSHELL;
|
||||
if (shell.endsWith(POWERSHELL) || shell.endsWith(POWERSHELL_CORE)) {
|
||||
cmdEsc = `&${cmdEsc}`;
|
||||
|
||||
if (shell_plugin) {
|
||||
const shell = shell_plugin.get<string>("windows");
|
||||
if (shell) {
|
||||
if (is_powershell_path(shell)) {
|
||||
return `&${cmdEsc}`;
|
||||
} else {
|
||||
return cmdEsc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const POWERSHELL_SOURCE = "PowerShell"
|
||||
const default_profile = vscode.workspace.getConfiguration("terminal.integrated.defaultProfile");
|
||||
if (default_profile) {
|
||||
const profile_name = default_profile.get<string>("windows");
|
||||
if (profile_name) {
|
||||
if (POWERSHELL_SOURCE === profile_name) {
|
||||
return `&${cmdEsc}`;
|
||||
}
|
||||
const profiles = vscode.workspace.getConfiguration("terminal.integrated.profiles.windows");
|
||||
const profile = profiles.get<{source?: string, path?: string}>(profile_name);
|
||||
if (profile) {
|
||||
if (POWERSHELL_SOURCE === profile.source || is_powershell_path(profile.path)) {
|
||||
return `&${cmdEsc}`;
|
||||
} else {
|
||||
return cmdEsc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// default for Windows if nothing is set is PowerShell
|
||||
return `&${cmdEsc}`
|
||||
|
||||
}
|
||||
return cmdEsc;
|
||||
};
|
||||
@@ -131,9 +164,11 @@ export class GodotTools {
|
||||
}
|
||||
|
||||
private check_client_status() {
|
||||
let host = get_configuration("gdscript_lsp_server_host", "localhost");
|
||||
let port = get_configuration("gdscript_lsp_server_port", 6008);
|
||||
switch (this.client.status) {
|
||||
case ClientStatus.PENDING:
|
||||
vscode.window.showInformationMessage("Connecting to the GDScript language server...");
|
||||
vscode.window.showInformationMessage(`Connecting to the GDScript language server at ${host}:${port}`);
|
||||
break;
|
||||
case ClientStatus.CONNECTED:
|
||||
vscode.window.showInformationMessage("Connected to the GDScript language server.");
|
||||
@@ -145,10 +180,12 @@ export class GodotTools {
|
||||
}
|
||||
|
||||
private on_client_status_changed(status: ClientStatus) {
|
||||
let host = get_configuration("gdscript_lsp_server_host", "localhost");
|
||||
let port = get_configuration("gdscript_lsp_server_port", 6008);
|
||||
switch (status) {
|
||||
case ClientStatus.PENDING:
|
||||
this.connection_status.text = `$(sync) Connecting`;
|
||||
this.connection_status.tooltip = `Connecting to the GDScript language server...`;
|
||||
this.connection_status.tooltip = `Connecting to the GDScript language server at ${host}:${port}`;
|
||||
break;
|
||||
case ClientStatus.CONNECTED:
|
||||
this.connection_status.text = `$(check) Connected`;
|
||||
@@ -169,7 +206,9 @@ export class GodotTools {
|
||||
}
|
||||
|
||||
private retry_connect_client() {
|
||||
vscode.window.showErrorMessage(`Couldn't connect to the GDScript language server.`, 'Open Godot Editor', 'Retry', 'Ignore').then(item=>{
|
||||
let host = get_configuration("gdscript_lsp_server_host", "localhost");
|
||||
let port = get_configuration("gdscript_lsp_server_port", 6008);
|
||||
vscode.window.showErrorMessage(`Couldn't connect to the GDScript language server at ${host}:${port}`, 'Open Godot Editor', 'Retry', 'Ignore').then(item=>{
|
||||
if (item == 'Retry') {
|
||||
this.client.connect_to_server();
|
||||
} else if (item == 'Open Godot Editor') {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as vscode from 'vscode';
|
||||
import { LanguageClient, LanguageClientOptions, ServerOptions, RequestMessage } from "vscode-languageclient";
|
||||
import { LanguageClient, LanguageClientOptions, ServerOptions, RequestMessage } from "vscode-languageclient/node";
|
||||
import { is_debug_mode, get_configuration } from "../utils";
|
||||
import { MessageIO, MessageIOReader, MessageIOWriter, Message, WebsocktMessageIO, TCPMessageIO } from "./MessageIO";
|
||||
import logger from "../loggger";
|
||||
@@ -74,8 +74,9 @@ export default class GDScriptLanguageClient extends LanguageClient {
|
||||
|
||||
connect_to_server() {
|
||||
this.status = ClientStatus.PENDING;
|
||||
let host = get_configuration("gdscript_lsp_server_host", "127.0.0.1");
|
||||
let port = get_configuration("gdscript_lsp_server_port", 6008);
|
||||
this.io.connect_to_language_server(port);
|
||||
this.io.connect_to_language_server(host, port);
|
||||
}
|
||||
|
||||
start(): vscode.Disposable {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { AbstractMessageReader, MessageReader, DataCallback } from "vscode-jsonrpc/lib/messageReader";
|
||||
import { AbstractMessageReader, MessageReader, DataCallback, Disposable } from "vscode-jsonrpc";
|
||||
import { EventEmitter } from "events";
|
||||
import * as WebSocket from 'ws';
|
||||
import { Socket } from 'net';
|
||||
|
||||
import MessageBuffer from "./MessageBuffer";
|
||||
import { AbstractMessageWriter, MessageWriter } from "vscode-jsonrpc/lib/messageWriter";
|
||||
import { RequestMessage, ResponseMessage, NotificationMessage } from "vscode-jsonrpc/lib/messages";
|
||||
import { AbstractMessageWriter, MessageWriter } from "vscode-jsonrpc";
|
||||
import { RequestMessage, ResponseMessage, NotificationMessage } from "vscode-jsonrpc";
|
||||
export type Message = RequestMessage | ResponseMessage | NotificationMessage;
|
||||
|
||||
export class MessageIO extends EventEmitter {
|
||||
@@ -30,7 +30,7 @@ export class MessageIO extends EventEmitter {
|
||||
this.emit("message", message);
|
||||
}
|
||||
|
||||
async connect_to_language_server(port: number): Promise<void> {
|
||||
async connect_to_language_server(host: string, port: number): Promise<void> {
|
||||
// virtual
|
||||
}
|
||||
}
|
||||
@@ -46,10 +46,10 @@ export class WebsocktMessageIO extends MessageIO {
|
||||
}
|
||||
}
|
||||
|
||||
async connect_to_language_server(port: number): Promise<void> {
|
||||
async connect_to_language_server(host:string, port: number): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.socket = null;
|
||||
const ws = new WebSocket(`ws://localhost:${port}`);
|
||||
const ws = new WebSocket(`ws://${host}:${port}`);
|
||||
ws.on('open', ()=>{ this.on_connected(ws); resolve(); });
|
||||
ws.on('message', this.on_message.bind(this));
|
||||
ws.on('error', this.on_disconnected.bind(this));
|
||||
@@ -77,11 +77,11 @@ export class TCPMessageIO extends MessageIO {
|
||||
}
|
||||
}
|
||||
|
||||
async connect_to_language_server(port: number):Promise<void> {
|
||||
async connect_to_language_server(host:string, port: number):Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.socket = null;
|
||||
const socket = new Socket();
|
||||
socket.connect(port);
|
||||
socket.connect(port, host);
|
||||
socket.on('connect', ()=>{ this.on_connected(socket); resolve(); });
|
||||
socket.on('data', this.on_message.bind(this));
|
||||
socket.on('end', this.on_disconnected.bind(this));
|
||||
@@ -127,7 +127,7 @@ export class MessageIOReader extends AbstractMessageReader implements MessageRea
|
||||
return this._partialMessageTimeout;
|
||||
}
|
||||
|
||||
public listen(callback: DataCallback): void {
|
||||
public listen(callback: DataCallback): Disposable {
|
||||
this.nextMessageLength = -1;
|
||||
this.messageToken = 0;
|
||||
this.partialMessageTimer = undefined;
|
||||
@@ -137,6 +137,8 @@ export class MessageIOReader extends AbstractMessageReader implements MessageRea
|
||||
});
|
||||
this.io.on('error', (error: any) => this.fireError(error));
|
||||
this.io.on('close', () => this.fireClose());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
private onData(data: Buffer | String): void {
|
||||
@@ -214,8 +216,12 @@ export class MessageIOWriter extends AbstractMessageWriter implements MessageWri
|
||||
this.io.on('error', (error: any) => this.fireError(error));
|
||||
this.io.on('close', () => this.fireClose());
|
||||
}
|
||||
|
||||
public end(): void {
|
||||
|
||||
}
|
||||
|
||||
public write(msg: Message): void {
|
||||
public write(msg: Message): Promise<void> {
|
||||
let json = JSON.stringify(msg);
|
||||
let contentLength = Buffer.byteLength(json, this.encoding);
|
||||
|
||||
@@ -235,5 +241,7 @@ export class MessageIOWriter extends AbstractMessageWriter implements MessageWri
|
||||
this.errorCount++;
|
||||
this.fireError(error, msg, this.errorCount);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import * as vscode from "vscode";
|
||||
import * as ls from "vscode-languageclient";
|
||||
import { EventEmitter } from "events";
|
||||
import { MessageIO } from "./MessageIO";
|
||||
import { NotificationMessage } from "vscode-jsonrpc";
|
||||
@@ -32,7 +33,7 @@ export default class NativeDocumentManager extends EventEmitter {
|
||||
this.io = io;
|
||||
io.on("message", (message: NotificationMessage) => {
|
||||
if (message.method == Methods.SHOW_NATIVE_SYMBOL) {
|
||||
this.show_native_symbol(message.params);
|
||||
this.show_native_symbol(message.params as GodotNativeSymbol);
|
||||
} else if (message.method == Methods.GDSCRIPT_CAPABILITIES) {
|
||||
for (const gdclass of (message.params as GodotCapabilities)
|
||||
.native_classes) {
|
||||
@@ -190,8 +191,8 @@ export default class NativeDocumentManager extends EventEmitter {
|
||||
with_class = false
|
||||
): { index?: string; body: string } {
|
||||
switch (s.kind) {
|
||||
case vscode.SymbolKind.Property:
|
||||
case vscode.SymbolKind.Variable:
|
||||
case ls.SymbolKind.Property:
|
||||
case ls.SymbolKind.Variable:
|
||||
{
|
||||
// var Control.anchor_left: float
|
||||
const parts = /\.([A-z_0-9]+)\:\s(.*)$/.exec(s.detail);
|
||||
@@ -215,7 +216,7 @@ export default class NativeDocumentManager extends EventEmitter {
|
||||
};
|
||||
}
|
||||
break;
|
||||
case vscode.SymbolKind.Constant:
|
||||
case ls.SymbolKind.Constant:
|
||||
{
|
||||
// const Control.FOCUS_ALL: FocusMode = 2
|
||||
// const Control.NOTIFICATION_RESIZED = 40
|
||||
@@ -243,7 +244,7 @@ export default class NativeDocumentManager extends EventEmitter {
|
||||
};
|
||||
}
|
||||
break;
|
||||
case vscode.SymbolKind.Event:
|
||||
case ls.SymbolKind.Event:
|
||||
{
|
||||
const parts = /\.([A-z0-9]+)\((.*)?\)/.exec(s.detail);
|
||||
if (!parts) {
|
||||
@@ -269,8 +270,8 @@ export default class NativeDocumentManager extends EventEmitter {
|
||||
};
|
||||
}
|
||||
break;
|
||||
case vscode.SymbolKind.Method:
|
||||
case vscode.SymbolKind.Function:
|
||||
case ls.SymbolKind.Method:
|
||||
case ls.SymbolKind.Function:
|
||||
{
|
||||
const signature = make_function_signature(s, with_class);
|
||||
const title = element("h4", signature);
|
||||
@@ -290,7 +291,7 @@ export default class NativeDocumentManager extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
if (symbol.kind == vscode.SymbolKind.Class) {
|
||||
if (symbol.kind == ls.SymbolKind.Class) {
|
||||
let doc = element("h2", `Native class ${symbol.name}`);
|
||||
const parts = /extends\s+([A-z0-9]+)/.exec(symbol.detail);
|
||||
let inherits = parts && parts.length > 1 ? parts[1] : "";
|
||||
@@ -326,19 +327,19 @@ export default class NativeDocumentManager extends EventEmitter {
|
||||
for (let s of symbol.children as GodotNativeSymbol[]) {
|
||||
const elements = make_symbol_elements(s);
|
||||
switch (s.kind) {
|
||||
case vscode.SymbolKind.Property:
|
||||
case vscode.SymbolKind.Variable:
|
||||
case ls.SymbolKind.Property:
|
||||
case ls.SymbolKind.Variable:
|
||||
properties_index += element("li", elements.index);
|
||||
propertyies += element("li", elements.body, { id: s.name });
|
||||
break;
|
||||
case vscode.SymbolKind.Constant:
|
||||
case ls.SymbolKind.Constant:
|
||||
constants += element("li", elements.body, { id: s.name });
|
||||
break;
|
||||
case vscode.SymbolKind.Event:
|
||||
case ls.SymbolKind.Event:
|
||||
signals += element("li", elements.body, { id: s.name });
|
||||
break;
|
||||
case vscode.SymbolKind.Method:
|
||||
case vscode.SymbolKind.Function:
|
||||
case ls.SymbolKind.Method:
|
||||
case ls.SymbolKind.Function:
|
||||
methods_index += element("li", elements.index);
|
||||
methods += element("li", elements.body, { id: s.name });
|
||||
break;
|
||||
@@ -373,11 +374,8 @@ export default class NativeDocumentManager extends EventEmitter {
|
||||
let doc = "";
|
||||
const elements = make_symbol_elements(symbol, true);
|
||||
if (elements.index) {
|
||||
if (
|
||||
[vscode.SymbolKind.Function, vscode.SymbolKind.Method].indexOf(
|
||||
symbol.kind
|
||||
) == -1
|
||||
) {
|
||||
const symbols: ls.SymbolKind[] = [ls.SymbolKind.Function, ls.SymbolKind.Method];
|
||||
if (!symbols.includes(symbol.kind)) {
|
||||
doc += element("h2", elements.index);
|
||||
}
|
||||
}
|
||||
@@ -419,7 +417,7 @@ function make_link(classname: string, symbol: string) {
|
||||
}
|
||||
|
||||
function make_codeblock(code: string) {
|
||||
const md = marked("```gdscript\n" + code + "\n```");
|
||||
const md = marked.parse("```gdscript\n" + code + "\n```");
|
||||
return `<div class="codeblock">${md}</div>`;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { DocumentSymbol } from "vscode";
|
||||
import { DocumentSymbol, Range, SymbolKind } from "vscode-languageclient";
|
||||
|
||||
|
||||
export const enum Methods {
|
||||
GDSCRIPT_CAPABILITIES = 'gdscript/capabilities',
|
||||
@@ -11,7 +12,15 @@ export interface NativeSymbolInspectParams {
|
||||
symbol_name: string;
|
||||
}
|
||||
|
||||
export class GodotNativeSymbol extends DocumentSymbol {
|
||||
export class GodotNativeSymbol implements DocumentSymbol {
|
||||
name: string;
|
||||
detail?: string;
|
||||
kind: SymbolKind;
|
||||
tags?: 1[];
|
||||
deprecated?: boolean;
|
||||
range: Range;
|
||||
selectionRange: Range;
|
||||
children?: DocumentSymbol[];
|
||||
documentation: string;
|
||||
native_class: string;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
{ "include": "#class_def" },
|
||||
{ "include": "#class_name"},
|
||||
{ "include": "#builtin_func" },
|
||||
{ "include": "#builtin_get_node_shorthand" },
|
||||
{ "include": "#builtin_classes" },
|
||||
{ "include": "#const_vars" },
|
||||
{ "include": "#class_new"},
|
||||
@@ -87,7 +88,7 @@
|
||||
},
|
||||
"logic_op": {
|
||||
"match": "\\b(and|or|not)\\b",
|
||||
"name": "keyword.operator.logical.gdscript"
|
||||
"name": "keyword.operator.wordlike.gdscript"
|
||||
},
|
||||
"compare_op": {
|
||||
"match": "<=|>=|==|<|>|!=",
|
||||
@@ -103,8 +104,16 @@
|
||||
},
|
||||
|
||||
"keywords": {
|
||||
"match": "\\b(?i:if|elif|else|for|while|break|continue|pass|return|match|func|class|class_name|extends|is|in|onready|tool|static|export|setget|const|var|as|void|enum|preload|assert|yield|signal|breakpoint|rpc|sync|master|puppet|slave|remotesync|mastersync|puppetsync)\\b",
|
||||
"name": "keyword.language.gdscript"
|
||||
"patterns": [
|
||||
{
|
||||
"match": "\\b(?i:func|class|class_name|extends|is|in|onready|tool|static|export|setget|const|var|as|void|enum|preload|assert|yield|signal|breakpoint|rpc|sync|remote|master|puppet|slave|remotesync|mastersync|puppetsync|in)\\b",
|
||||
"name": "keyword.language.gdscript"
|
||||
},
|
||||
{
|
||||
"match": "\\b(?i:if|elif|else|for|while|break|continue|pass|return|match)\\b",
|
||||
"name": "keyword.control"
|
||||
}
|
||||
]
|
||||
},
|
||||
"letter": {
|
||||
"match": "\\b(?i:true|false|null)\\b",
|
||||
@@ -202,6 +211,10 @@
|
||||
"match": "(?<![^.]\\.|:)\\b(sin|cos|tan|sinh|cosh|tanh|asin|acos|atan|atan2|sqrt|fmod|fposmod|floor|ceil|round|abs|sign|pow|log|exp|is_nan|is_inf|ease|decimals|stepify|lerp|dectime|randomize|randi|randf|rand_range|seed|rand_seed|deg2rad|rad2deg|linear2db|db2linear|max|min|clamp|nearest_po2|weakref|funcref|convert|typeof|type_exists|char|str|print|printt|prints|printerr|printraw|var2str|str2var|var2bytes|bytes2var|range|load|inst2dict|dict2inst|hash|Color8|print_stack|instance_from_id|preload|yield|assert)\\b(?=(\\()([^)]*)(\\)))",
|
||||
"name": "support.function.builtin.gdscript"
|
||||
},
|
||||
"builtin_get_node_shorthand": {
|
||||
"match": "\\$(((?<quote>\"|')((\\.\\.\\/)+|\\/)?)[0-9A-Za-z_ ]+(\\/[0-9A-Za-z_ ]+)*\\k<quote>|[0-9A-Za-z_]+(\\/[0-9A-Za-z_]+)*)",
|
||||
"name": "support.function.builtin.shorthand.gdscript"
|
||||
},
|
||||
"builtin_classes": {
|
||||
"match": "(?<![^.]\\.|:)\\b(Vector2|Vector3|Color|Rect2|Array|Basis|Dictionary|Plane|Quat|RID|Rect3|Transform|Transform2D|AABB|String|Color|NodePath|RID|Object|Dictionary|Array|PoolByteArray|PoolIntArray|PoolRealArray|PoolStringArray|PoolVector2Array|PoolVector3Array|PoolColorArray)\\b",
|
||||
"name": "support.class.library.gdscript"
|
||||
|
||||
11
syntaxes/README.md
Normal file
11
syntaxes/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# Helpful resources
|
||||
|
||||
You can find the regex syntax that VSCode uses [here](https://macromates.com/manual/en/regular_expressions).
|
||||
|
||||
## Creating and debugging regex
|
||||
|
||||
When creating regexes it is sometimes useful to test against a data set.
|
||||
|
||||
[Regex101](https://regex101.com/) allows for pretty good match testing. Unfortunately, it does not support the regex (Ruby) version that TextMate uses.
|
||||
|
||||
[ExtendsClass's](https://extendsclass.com/regex-tester.html#ruby) regex engine does support the Ruby variant, but the match testing experience is not as good. However, it automatically generates an FSM for your regex, which is very useful when debugging.
|
||||
Reference in New Issue
Block a user