Compare commits

..

17 Commits

Author SHA1 Message Date
Geequlim
cf22aa3595 Merge pull request #138 from sevkin/137
check before calling platform-specific code
2020-01-26 16:27:00 +08:00
Vsevolod Balashov
c41bd642f0 check before calling platform-specific code
closes #137
2020-01-26 02:29:34 +03:00
geequlim
8d8f5c2d9b Support reconnect to language server when server port changed 2020-01-12 00:00:17 +08:00
Geequlim
119a7ebd23 Merge pull request #134 from Bromeon/bugfix/highlight-camel-case
Fix syntax highlighting for camelCase identifiers
2020-01-10 23:54:50 +08:00
Jan Haller
555cb1ce9a Fix syntax highlighting for camelCase identifiers
Currently, any occurrences of PascalCase identifiers (even as parts of other words) are recognized as classes.
This assumes snake_case convention for all methods and variables and makes it impossible to use camelCase. While this is the recommended GDScript style, the syntax highlighter should allow for different styles as long as it can do so unambiguously. This is already done for existing rules, but overridden by one rule with an overly general regex pattern.

This commit modifies the catch-all rule for the 'parscal_class' group to only capture whole words.
For clarity, it renames 'parscal_class' to 'pascal_case_class'.

Other groups to recognize classes remain unchanged: type_declear, function-return-type, class_def, class_new, class_is, class_enum, class_name, extends
2019-12-29 18:00:31 +01:00
geequlim
ca3a1e62c4 Fix status icon color bug 2019-12-07 14:03:59 +08:00
geequlim
61e05e7d6e Update dependencies 2019-12-07 14:03:38 +08:00
Geequlim
96b833851d Merge pull request #124 from Calinou/improve-messages
Improve messages for consistency and fix typos
2019-11-06 00:25:49 +08:00
Hugo Locurcio
602cc895c0 Improve messages for consistency and fix typos 2019-11-04 18:52:53 +01:00
geequlim
41a58d76b1 Fix indent in GDScript.tmLaguage.json 2019-10-27 12:04:42 +08:00
Geequlim
8d6992822e Merge pull request #123 from OrenjiAkira/master
Fix class_name statement bug
2019-10-27 12:00:41 +08:00
orenjiakira
f0914742e1 Fix class_name statement bug 2019-10-26 16:07:09 -03:00
Geequlim
a1e020560d Merge pull request #120 from Calinou/improve-readme
Improve the README and fix various typos
2019-10-10 23:31:51 +08:00
Hugo Locurcio
cf9e478b12 Improve the README and fix various typos 2019-10-10 17:29:43 +02:00
Geequlim
d155016b08 Merge pull request #121 from Calinou/optimize-images
Optimize images losslessly using `oxipng -o6 --strip --zopfli`
2019-10-10 23:28:36 +08:00
Hugo Locurcio
40b09491ac Optimize images losslessly using oxipng -o6 --strip --zopfli 2019-10-10 17:04:21 +02:00
Geequlim
24c29452c7 Fix typo in readme 2019-10-09 15:15:25 +08:00
9 changed files with 113 additions and 98 deletions

View File

@@ -21,7 +21,7 @@
```
### 0.3.6
* Fix project configuartion file path
* Fix project configuration file path
### 0.3.5
* Add option to disable syntax checking for GDScript
@@ -61,7 +61,7 @@
* Limited code completions
### 0.2.9
* Add configuration `GodotTools.completeNodePath` to switch is complete node pathes
* Add configuration `GodotTools.completeNodePath` to switch is complete node paths
* Enhanced syntax highlight with GDScript
* Enhanced code completion with GDScript
@@ -74,7 +74,7 @@
* Fix some error with syntax checking
* Add symbol support for enumerations
* Remove key bindings for `F5`~`F8` as it might be confict with other functionalities of VSCode
* Remove key bindings for `F5`~`F8` as it might be conflict with other functionalities of VSCode
* You can bind the key bindings back by add following configurations
```json
{
@@ -110,14 +110,14 @@
* Run games within VSCode terminals
* Add key bindings for `F5 to run the workspace` and `F6 to run the edting scene`
* Fix a lot of bugs with unused vaiable cheching
* Fix a lot of bugs with unused variable checking
* Move workspace symbols state notice to status bar
### 0.2.4
* Add code cheching for asignments and comparations
* Impoved builtin documentation preview page
* Fix bugs with unused vaiable cheching
* Add code checking for asignments and comparisons
* Improved builtin documentation preview page
* Fix bugs with unused variable checking
### 0.2.3
* Fix known errors with code syntax checking
@@ -127,7 +127,7 @@
### 0.2.2
* Better Syntax validating for code blocks
* More waring for non-python liked expression
* More warning for non-python liked expression
### 0.2.1
* Support markdown render in hover tips for documentations in workspace symbols
@@ -135,14 +135,14 @@
### 0.2.0
* Show autoloads informations in hover tips and go to autoloads' definitions are supported now
* Show autoloads information in hover tips and go to autoloads' definitions are supported now
* Fix the bug that workspace symbols resoved twice on Windows
### 0.1.9
* Show workspace constant value in hover tips and completion items
* More readable style for links in documentation preview page
* Improve code completion sort order and auto insert `()` for functions without paramaters
* Improve code completion sort order and auto insert `()` for functions without parameters
* Fix bugs with workspace documentation parsing
### 0.1.8
@@ -159,7 +159,7 @@
* Reorder mouse hover tips, builtin methods are at top of workspace methods
* Show callabel signatures with documente symbols and workspace symbols
* Syntax highlight support for signal paramaters
* Syntax highlight support for signal parameters
### 0.1.5

View File

@@ -1,63 +1,79 @@
A complete set of tools to code games with the [Godot game engine](http://www.godotengine.org/) in Visual Studio Code.
# Godot Tools
**IMPORTANT NOTE**
This version of plugin only support godot 3.2 and above.
A complete set of tools to code games with
[Godot Engine](http://www.godotengine.org/) in Visual Studio Code.
**IMPORTANT NOTE:** Versions 1.0.0 and later of this plugin only support
Godot 3.2 or later.
## Features
The extension comes with a wealth of features to make your Godot programming experience as comfortable as possible:
The extension comes with a wealth of features to make your Godot programming
experience as comfortable as possible:
- Syntax highlighting for the GDScript (`.gd`) language
- Syntax highlighting for the `.tscn` and `.tres` scene formats
- Full Typed GDScript support
- Optional `Smart Mode` to speed up dynamic typed script coding
- Full typed GDScript support
- Optional "Smart Mode" to improve productivity with dynamically typed scripts
- Function definitions and documentation display on hover (see image below)
- Rich auto-completion
- Rich autocompletion
- Display script warnings and errors
- Ctrl-click on a variable or method call to jump to its definition
- Full documentation of the Godot engine's API supported
- Run godot project from VS Code
- Ctrl + click on a variable or method call to jump to its definition
- Full documentation of the Godot Engine's API supported
- Run a Godot project from VS Code
![Showing the documentation on hover feature](img/godot-tools.png)
## Available Commands
## Available commands
The extension adds a few entries to the VS Code Command Palette under "GodotTools":
The extension adds a few entries to the VS Code Command Palette under "Godot Tools":
- Open workspace with Godot editor
- Run workspace as Godot project
- List native classes of godot
- Run the workspace as a Godot project
- List Godot's native classes
## Settings
### Godot
If you like this extension, you can set VS Code as your default script editor for Godot by following these steps:
1. Open editor settings
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
5. Fill `Exec Flags` with `{project} --goto {file}:{line}:{col}`
If you like this extension, you can set VS Code as your default script editor
for Godot by following these steps:
1. Open the **Editor Settings**
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
5. Fill **Exec Flags** with `{project} --goto {file}:{line}:{col}`
### VS Code
You can use the following settings to configure Godot Tools:
- **editor_path** - The absolute path to the Godot editor executable
- **gdscript_lsp_server_port** - The websocket server port of the GDScript language server
- **check_status** - Check the GDScript language server connection status
## Issues and Contributions
- `editor_path` - The absolute path to the Godot editor executable.
- `gdscript_lsp_server_port` - The WebSocket server port of the GDScript language server.
- `check_status` - Check the GDScript language server connection status.
The [Godot Tools](https://github.com/godotengine/godot-vscode-plugin) extension is an open source project of godot orgnization. Feel free to open issues and create pull requests anytime.
## Issues and contributions
See the [full changelog](https://github.com/GodotExplorer/godot-tools/blob/master/CHANGELOG.md) for the latest changes.
The [Godot Tools](https://github.com/godotengine/godot-vscode-plugin) extension
is an open source project from the Godot orgnization. Feel free to open issues
and create pull requests anytime.
See the [full changelog](https://github.com/GodotExplorer/godot-tools/blob/master/CHANGELOG.md)
for the latest changes.
## FAQ
### Why failed to connect to language server?
- You may not open your project with godot editor.
- Godot 3.2 and above is required.
### Why does it fail to connect to the language server?
### Why isn't intellisense showing up my script members for me?
- The GDScript is a dynamic typed script language the tool may can infer all the variable types as you want.
- You can turn on the `Smart Mode` in godot editor `Editor Settings > Language Server` check the `Enable Smart Resolve`.
- Godot 3.2 or later is required.
- Make sure to open the project in the Godot editor first. If you opened
the editor after opening VS Code, you can click the **Retry** button
in the bottom-right corner in VS Code.
### Why isn't IntelliSense displaying script members?
- GDScript is a dynamically typed script language. The language server can't
infer all variable types.
- To increase the number of results displayed, open the **Editor Settings**,
go to the **Language Server** section then check **Enable Smart Resolve**.

View File

@@ -15,7 +15,7 @@
{ "include": "#const_def" },
{ "include": "#type_declear"},
{ "include": "#class_def" },
{ "include": "#classname"},
{ "include": "#class_name"},
{ "include": "#builtin_func" },
{ "include": "#builtin_classes" },
{ "include": "#const_vars" },
@@ -27,7 +27,7 @@
{ "include": "#any-method" },
{ "include": "#any-property" },
{ "include": "#extends" },
{ "include": "#parscal_class" }
{ "include": "#pascal_case_class" }
],
"repository": {
"comment": {
@@ -173,7 +173,7 @@
},
"match": "\\b([a-zA-Z_][a-zA-Z_0-9]*).(new)\\("
},
"class_is": {
"class_is": {
"captures": {
"1": { "name": "storage.type.is.gdscript" },
"2": { "name": "entity.name.type.class.gdscript" }
@@ -187,11 +187,14 @@
},
"match": "\\b([A-Z][a-zA-Z_0-9]*)\\.([A-Z_0-9]+)"
},
"classname": {
"match": "(?<=class_name)\\s+([a-zA-Z_][a-zA-Z_0-9]*(\\.([a-zA-Z_][a-zA-Z_0-9]*))?)",
"name": "entity.name.type.class.gdscript"
"class_name": {
"captures": {
"1": { "name": "entity.name.type.class.gdscript" },
"2": { "name": "class.other.gdscript" }
},
"match": "(?<=class_name)\\s+([a-zA-Z_][a-zA-Z_0-9]*(\\.([a-zA-Z_][a-zA-Z_0-9]*))?)"
},
"extends": {
"extends": {
"match": "(?<=extends)\\s+[a-zA-Z_][a-zA-Z_0-9]*(\\.([a-zA-Z_][a-zA-Z_0-9]*))?",
"name": "entity.other.inherited-class.gdscript"
},
@@ -325,11 +328,11 @@
}
]
},
"parscal_class": {
"pascal_case_class": {
"captures": {
"1": { "name": "entity.name.type.class.gdscript" }
},
"match": "([A-Z][a-zA-Z_0-9]*)"
"match": "\\b([A-Z][a-zA-Z_0-9]*)\\b"
}
}
}

BIN
icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 183 KiB

After

Width:  |  Height:  |  Size: 107 KiB

View File

@@ -19,11 +19,10 @@
],
"main": "./out/extension.js",
"scripts": {
"vscode:prepublish": "yarn run compile",
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"postinstall": "node ./node_modules/vscode/bin/install",
"test": "yarn run compile && node ./node_modules/vscode/bin/test"
"lint": "tslint -p ./",
"watch": "tsc -watch -p ./"
},
"contributes": {
"commands": [
@@ -106,8 +105,8 @@
"@types/prismjs": "^1.16.0",
"@types/ws": "^6.0.1",
"tslint": "^5.16.0",
"typescript": "^3.4.5",
"vscode": "^1.1.33"
"typescript": "^3.5.1",
"@types/vscode": "^1.40.0"
},
"dependencies": {
"global": "^4.4.0",

View File

@@ -21,7 +21,7 @@ export class GodotTools {
this.client.watch_status(this.on_client_status_changed.bind(this));
this.connection_status = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right);
}
public activate() {
vscode.commands.registerCommand("godot-tool.open_editor", ()=>{
this.open_workspace_with_editor("-e").catch(err=>vscode.window.showErrorMessage(err));
@@ -30,22 +30,22 @@ export class GodotTools {
this.open_workspace_with_editor().catch(err=>vscode.window.showErrorMessage(err));
});
vscode.commands.registerCommand("godot-tool.check_status", this.check_client_status.bind(this));
this.connection_status.text = "$(sync) Initializing";
this.connection_status.command = "godot-tool.check_status";
this.connection_status.show();
this.client.connect_to_server();
}
public deactivate() {
this.client.stop();
}
private open_workspace_with_editor(params = "") {
return new Promise((resolve, reject) => {
let valid = false
if (this.workspace_dir) {
@@ -63,14 +63,14 @@ export class GodotTools {
}
private run_editor(params = "") {
return new Promise((resolve, reject) => {
const run_godot = (path: string, params: string) => {
const escape_command = (cmd: string) => {
let cmdEsc = `"${cmd}"`;
const shell_plugin = vscode.workspace.getConfiguration("terminal.integrated.shell");
let shell = shell_plugin ? shell_plugin.get("windows", "") || "" : "";
if (shell.endsWith("powershell.exe") && process.platform === "win32") {
if (process.platform === "win32" && shell.endsWith("powershell.exe")) {
cmdEsc = `&${cmdEsc}`;
}
return cmdEsc;
@@ -86,7 +86,7 @@ export class GodotTools {
terminal.show();
resolve();
};
let editorPath = get_configuration("editor_path", "")
editorPath = editorPath.replace("${workspaceRoot}", this.workspace_dir);
if (!fs.existsSync(editorPath) || !fs.statSync(editorPath).isFile()) {
@@ -108,38 +108,37 @@ export class GodotTools {
}
});
}
private check_client_status() {
switch (this.client.status) {
case ClientStatus.PENDING:
vscode.window.showInformationMessage("Connecting to GDScript language server");
vscode.window.showInformationMessage("Connecting to the GDScript language server...");
break;
case ClientStatus.CONNECTED:
vscode.window.showInformationMessage("Connected to GDScript language server");
vscode.window.showInformationMessage("Connected to the GDScript language server.");
break;
case ClientStatus.DISCONNECTED:
this.retry_connect_client();
break;
}
}
private on_client_status_changed(status: ClientStatus) {
this.connection_status.color = vscode.ThemeColor;
switch (status) {
case ClientStatus.PENDING:
this.connection_status.text = `$(sync) Connecting`;
this.connection_status.tooltip = `Connecting to GDScript Language Server`;
this.connection_status.tooltip = `Connecting to the GDScript language server...`;
break;
case ClientStatus.CONNECTED:
this.connection_status.text = `$(check) Connected`;
this.connection_status.tooltip = `Connected to GDScript Language Server`;
this.connection_status.tooltip = `Connected to the GDScript language server.`;
if (!this.client.started) {
this.context.subscriptions.push(this.client.start());
}
break;
case ClientStatus.DISCONNECTED:
this.connection_status.text = `$(x) Disconnected`;
this.connection_status.tooltip = `Disconnect to GDScript Language Server`;
this.connection_status.tooltip = `Disconnected from the GDScript language server.`;
// retry
this.retry_connect_client();
break;
@@ -147,9 +146,9 @@ export class GodotTools {
break;
}
}
private retry_connect_client() {
vscode.window.showErrorMessage(`Failed connect to GDScript Language Server`, 'Open Godot Editor', 'Retry', 'Ignore').then(item=>{
vscode.window.showErrorMessage(`Couldn't connect to the GDScript language server.`, 'Open Godot Editor', 'Retry', 'Ignore').then(item=>{
if (item == 'Retry') {
this.client.connect_to_server();
} else if (item == 'Open Godot Editor') {

View File

@@ -40,17 +40,17 @@ export enum ClientStatus {
const CUSTOM_MESSAGE = "gdscrip_client/";
export default class GDScriptLanguageClient extends LanguageClient {
public io: MessageIO = io;
private context: vscode.ExtensionContext;
private _started : boolean = false;
private _status : ClientStatus;
private _status_changed_callbacks: ((v : ClientStatus)=>void)[] = [];
private _initialize_request: Message = null;
private message_handler: MessageHandler = null;
private native_doc_manager: NativeDocumentManager = null;
private native_doc_manager: NativeDocumentManager = null;
public get started() : boolean { return this._started; }
public get status() : ClientStatus { return this._status; }
public set status(v : ClientStatus) {
@@ -61,13 +61,13 @@ export default class GDScriptLanguageClient extends LanguageClient {
}
}
}
public watch_status(callback: (v : ClientStatus)=>void) {
if (this._status_changed_callbacks.indexOf(callback) == -1) {
this._status_changed_callbacks.push(callback);
}
}
constructor(context: vscode.ExtensionContext) {
super(`GDScriptLanguageClient`, serverOptions, getClientOptions());
this.context = context;
@@ -79,36 +79,36 @@ export default class GDScriptLanguageClient extends LanguageClient {
this.io.on('send_message', this.on_send_message.bind(this));
this.native_doc_manager = new NativeDocumentManager(this.io);
}
connect_to_server() {
this.status = ClientStatus.PENDING;
io.connect_to_language_server();
io.connect_to_language_server(get_server_uri());
}
start(): vscode.Disposable {
this._started = true;
return super.start();
}
private on_send_message(message: Message) {
if (is_debug_mode()) logger.log("[client]", JSON.stringify(message));
if ((message as RequestMessage).method == "initialize") {
this._initialize_request = message;
}
}
private on_message(message: Message) {
if (is_debug_mode()) logger.log("[server]", JSON.stringify(message));
this.message_handler.on_message(message);
}
private on_connected() {
if (this._initialize_request) {
this.io.writer.write(this._initialize_request);
}
this.status = ClientStatus.CONNECTED;
}
private on_disconnected() {
this.status = ClientStatus.DISCONNECTED;
}
@@ -117,16 +117,16 @@ export default class GDScriptLanguageClient extends LanguageClient {
class MessageHandler extends EventEmitter {
changeWorkspace(params: {path: string}) {
vscode.window.showErrorMessage("The GDScript Language Server can't work properly!\nThe opening workspace is diffrent with the editor's.", 'Reload', 'Ignore').then(item=>{
vscode.window.showErrorMessage("The GDScript language server can't work properly!\nThe open workspace is different from the editor's.", 'Reload', 'Ignore').then(item=>{
if (item == "Reload") {
let folderUrl = vscode.Uri.file(params.path);
vscode.commands.executeCommand('vscode.openFolder', folderUrl, false);
}
});
}
on_message(message: any) {
if (message && message.method && (message.method as string).startsWith(CUSTOM_MESSAGE)) {
const method = (message.method as string).substring(CUSTOM_MESSAGE.length, message.method.length);

View File

@@ -12,11 +12,9 @@ export class MessageIO extends EventEmitter {
writer: MessageIOWriter = null;
private socket: WebSocket = null;
private url: string = "";
constructor(url: string) {
super();
this.url = url;
}
public send_message(message: string) {
@@ -39,10 +37,10 @@ export class MessageIO extends EventEmitter {
this.emit("message", message);
}
connect_to_language_server():Promise<void> {
connect_to_language_server(url: string):Promise<void> {
return new Promise((resolve, reject) => {
this.socket = null;
const ws = new WebSocket(this.url);
const ws = new WebSocket(url);
ws.on('open', ()=>{ this.on_connected(ws); resolve(); });
ws.on('message', this.on_message.bind(this));
ws.on('error', this.on_disconnected.bind(this));