Code Monkey home page Code Monkey logo

godot-vscode-plugin's Introduction

Godot Tools

Game development tools for working with Godot Engine in Visual Studio Code.

IMPORTANT NOTE: Versions 1.0.0 and later of this extension only support Godot 3.2 or later.

Features

(bold items are new in Godot Tools v2.0.0)

  • ALL FEATURES FULLY SUPPORT GODOT 4
  • GDScript (.gd) language features:
    • syntax highlighting
    • ctrl+click on any symbol to jump to its definition or open its documentation
    • ctrl+click on res://resource/path links
    • hover previews on res://resource/path links
    • builtin code formatter
    • autocompletions
    • full typed GDScript support
    • optional "Smart Mode" to improve productivity with dynamically typed scripts
    • Hover previews show function/variable definitions including doc-comments
    • switch from a .gd file to the related .tscn file (default keybind is alt+o)
    • display script warnings and errors
  • GDScript Debugger features:
    • completely rewritten, greatly improved reliability
    • new, simple configuration (seriously, just hit F5!)
    • convenient launch targets: current project/current file/pinned file,
    • breakpoints
    • exceptions
    • step-in/out/over
    • variable watch
    • call stack
    • active scene tree
    • inspector
  • GDResource (.tscn and .tres) language features:
    • syntax highlighting
    • ctrl+click on res://resource/path links
    • ctrl+click on symbols to jump to its definition or open its documentation
    • hover previews show definitions of External and Sub Resources
    • hover previews on res://resource/path links
    • inlay hints to help visualize External and Sub Resources
    • in-editor Scene Preview
  • GDShader (.gdshader) language features:
    • syntax highlighting

Download

To install from GitHub Releases or a development build, see Install from a VSIX in the Visual Studio Code documentation.

Commands

The extension adds a few entries to the VS Code Command Palette under "Godot Tools":

  • Open workspace with Godot editor
  • List Godot's native classes (and open thier documentation)
  • Debug the current .tscn/.gd file
  • Debug the pinned .tscn/.gd file
  • Pin/Unpin the current .tscn/.gd file for debugging
  • Open the pinned file

Configuration

Godot Editor

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. Check Use External Editor
  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

You can use the following settings to configure Godot Tools:

  • godotTools.editorPath.godot3
  • godotTools.editorPath.godot4

The path to the Godot editor executable. Under Mac OS, this is the executable inside of Godot.app.

  • godotTools.lsp.headless

When using Godot >3.6 or >4.2, Headless LSP mode is available. In Headless mode, the extension will attempt to launch a windowless instance of the Godot editor to use as its Language Server.

GDScript Debugger

The debugger is for GDScript projects. To debug C# projects, use C# Tools for Godot.

To configure the GDScript debugger:

  1. Open the command palette (by pressing F1):
  2. >View: Show Run and Debug
  3. Click on "create a launch.json file"

Run and Debug View

  1. Select the Debug Godot configuration.
  2. Change any relevant settings.
  3. Press F5 to launch.

Configurations

Minimal:

{
	"name": "Launch",
	"type": "godot",
	"request": "launch"
}

Everything:

{
	"name": "Launch",
	"type": "godot",
	"request": "launch",
	"project": "${workspaceFolder}",
	"address": "127.0.0.1",
	"port": 6007,
	"scene": "main|current|pinned|<path>",
	"editor_path": "<path>",
	// engine command line flags
	"profiling": false,
	"single_threaded_scene": false,
	"debug_collisions": false,
	"debug_paths": false,
	"debug_navigation": false,
	"debug_avoidance": false,
	"debug_stringnames": false,
	"frame_delay": 0,
	"time_scale": 1.0,
	"disable_vsync": false,
	"fixed_fps": 60,
	// anything else
	"additional_options": ""
}

Godot's command flags are documented here: https://docs.godotengine.org/en/stable/tutorials/editor/command_line_tutorial.html

Usage

  • Stacktrace and variable dumps are the same as any regular debugger
  • The active scene tree can be refreshed with the Refresh icon in the top right.
  • Nodes can be brought to the fore in the Inspector by clicking the Eye icon next to nodes in the active scene tree, or Objects in the inspector.
  • You can edit integers, floats, strings, and booleans within the inspector by clicking the pencil icon next to each.

Showing the debugger in action

Issues and contributions

The Godot Tools extension is an open source project from the Godot organization. Feel free to open issues and create pull requests anytime.

See the full changelog for the latest changes.

Contributing

see CONTRIBUTING.md

FAQ

Why does it fail to connect to the language server?

  • Godot 3.2 or later is required.
  • Make sure the Godot editor is running
  • 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.

godot-vscode-plugin's People

Contributors

akien-mga avatar akirakido avatar anoadragon453 avatar arrkiin avatar bitwes avatar calinou avatar chybby avatar daelonsuzuka avatar dependabot[bot] avatar fractile81 avatar geequlim avatar jogly avatar kemgoblin avatar kurtlachmann avatar linkpy avatar nathanlovato avatar oidro avatar rakkarage avatar raulsntos avatar razoric480 avatar rivencode avatar ryan-000 avatar ryanabx avatar s7m4b4 avatar sandygk avatar tomwyr avatar vlad-zumer avatar vpyatnitskiy avatar wachtel1 avatar zachisagardner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

godot-vscode-plugin's Issues

Incorrect extra brackets warning

If the condition is something like if (somecondition or someother) and condition: it gives a false warning.

The regex should be something like (if|elif|while|match)\s*\(.*\)\s*:\s*$

But there's one other case this doesn't catch, and that's when you have something like if (somecondition) or someother: but I wouldn't know how to fix that in one regex expression without a negative look behind for and/or which javascript doesn't support.

"Variable is never used" on constant that is used in another file

In 0.3.4, Godot 2.1:

All constants in this script of my project are indicated as unused:

image

However, they are:

image
...
image

I get no accurate completion from Group.* either.
They should be resolvable since it's all consts. Maybe it's a more general intellisense problem regarding consts?

The same happens with member vars, but they are not consts so I guess it's harder to verify:

image
How could you guess?^^
image

In that case it would be nice to not squiggle those since it's not reliable, unless they are prefixed by _ though, as an option?

Intellisense shows all symbols

When typing self. the intellisense completion appears to include every possible symbol, not just those that the Sprite class responds to.

Allow disabling syntax checking rules

I like writing code my own way, like using brackets in if statements for example, even when they aren't needed.

It'd be nice to be able to disable some of these rules or even all of them.

I don't think there's a way to do it with the current settings, am I missing something?

Also, I've added the extension from the extension manager in VSCode, but I still get warnings for inlined if else statements (even though they're fixed here).

Methods and variable appear twice

The definition for user created methods and variables is always shown at least 2 times, when the method/variable is only defined once:

image

Incorrect error with punctuation in string

This statement:

			info("Mesh names match, deleting old one")

gives the error

 ': or \' expected at end of line.

But there is no error. If you delete the comma in the string, the error message goes away.

License?

What is license of your code? GPL?

Syntax checker false warning.

Getting weird results, when naming variable as ll (lowercase LL).

Shows syntax warning, that "Variable ll is never used", although it's clearly used later. Screenshot:
screenshot1

If I rename this variable, then it works correctly. Screenshot:
screenshot2

Maybe there's more variable names that produce this false syntax error.

The Exec Flags {project} --goto {file}:{line}:{col} gives error. . .

Hi, I set the VS Code to be my default text editor and when I set this: {project} --goto {file}:{line}:{col}, the console drops this error:

the mode arguments from "--goto" must have format "FILE(:LINE(:CHARACTER))"

What that means?, thanks in advanced, cheers.

PD: I'm not an experienced programmer, that's why I don't understand.

Add refactor/rename feature

Refactoring in Godots native editor is a nightmare for me. Rename one node and create possible bugs all over the place. VS code seems to have a proper rename function which changes variable occurences but as microsoft/vscode#7213 states this has to be added to the language extension as it is highly language specific.
My only alternative is "Change all occurences" which also changes strings - not the wanted behaviour. This would be an awesome feature and I bet one many Godot devs would like.

line continuation does not get recognized

The following is valid GDScript, at least it works in the engine itself with no complaints, but gets highlighted as an error. (see Line 64 and Line 71)

Screenshot:
31_03_2017

Some errors with syntax checking

  • ': or ' expected at end of the line.
return val if sign_flag else -val
var ret = plugin.get_properties(self) if plugin != null else []

Editor Path Not Escaped or Quoted

I installed the Godot game engine through Steam, and it puts the engine under the directory Godot Engine. The space (in Godot Engine) is messing up the argument parsing (because the editor argument is not escaped/quoted), and causing the extension to fail when loading the editor:

PS D:\projects\godot> D:/SteamLibrary/steamapps/common/Godot Engine/godot.windows.opt.tools.32.exe -path D:/projects/godot  res://C:/settings.json

D:/SteamLibrary/steamapps/common/Godot : The term 'D:/SteamLibrary/steamapps/common/Godot' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ D:/SteamLibrary/steamapps/common/Godot Engine/godot.windows.opt.tools ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (D:/SteamLibrary/steamapps/common/Godot:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

VS Code gives the error output: Invalid editor path to run the project

A few strings I've tried:

Normal string
"D:/SteamLibrary/steamapps/common/Godot Engine/godot.windows.opt.tools.32.exe"

Single quoted string
"'D:/SteamLibrary/steamapps/common/Godot Engine/godot.windows.opt.tools.32.exe'"

Caret before space
"D:/SteamLibrary/steamapps/common/Godot^ Engine/godot.windows.opt.tools.32.exe"

Quoted with caret before space
"'D:/SteamLibrary/steamapps/common/Godot^ Engine/godot.windows.opt.tools.32.exe'"

back slash (single backslash was giving "Invalid escape character in string", presumably because of the json spec https://github.com/Microsoft/vscode/issues/23601)
"D:/SteamLibrary/steamapps/common/Godot\\ Engine/godot.windows.opt.tools.32.exe"

& quoted (which is what powershell expanded it out to be when you do tab completion)
"&'D:/SteamLibrary/steamapps/common/Godot Engine/godot.windows.opt.tools.32.exe'"

Deprecation - use MarkdownString for command-links

This extension has been identified as using command-links in either hovers or decorations. The August release (1.16) is the last release to support this in the MarkedString and with September the MarkdownString must be used. We are doing this because of security concerns. Background and details are explained here: microsoft/vscode#33577 (comment)

The adoption should be straight forward and usages of MarkedString need to be replaced with:

let md = new MarkdownString(content);
md.isTrusted = true;

Please let us know if you need more information. Thanks and Happy Coding

Duplicate definitions for built-in methods

Builtin methods like _ready, _fixed_process etc. are indexed in the whole workspace. I think it would be more useful to only have the engine's built-in definition, so you can access the documentation easily. The current implementation makes it harder to find the information you're looking for (the screenshot is for a small project - with a large godot game, it's going to be worse).

I would suggest 2 options:

  • Don't index the symbol when it's a built-in method
  • Or only add the definition once and leave "Click to show 8 definitions"

image

pass keyword autocompletion

Hi,

Great work on this toolset, thanks for your hard work.

When typing pass in an empty function/code block the autocomplete doesn't suggest pass and typing pass + [Enter] will give you something you then have to delete.

Could you add pass to the autocomplete dictionary please?

Thanks

Adam

"Current workspace is not a godot project"

I configured the editor path to the directory my executable is located in, but I am still getting "Current workspace is not a godot project" error when I attempt to run the project from VS Code.

My user settings look like the below:

{
    "editor.codeLens": false,
    "csproj.itemType": {
        "*": "Content",
        ".ts": "TypeScriptCompile",
        ".cs": "Compile"
    },
    "csharp.format.enable": false,
    "GodotTools.completeNodePath": true,
    "GodotTools.editorPath": "C:\\Godot_v3.0-stable_win64.exe\\"
}

Error when using comment on line after function declaration

If I'd write this:

def derp():
pass # replace later

Which is generated by connecting signals in the editor to scripts, the extension sees this as an error in the code analysis while it shouldn't be, mistaking it for this behaviour:

def derp():
# replace later

"Load GDScript documentations failed" after extension auto updated to 0.3.5

Looks like there was a new version of the extension published to the Visual Studio Code Marketplace that causes at least the syntax highlighting to fail with a "Load GDScript documentations failed" error.

In the Marketplace the extension has the folloving in the More Info section:

Version 0.3.5
Last updated 1/30/2018, 4:50:01 PM

In addition the Change Log in the Marketplace displays the 0.3.5 version with following changes:

  • Add option to disable syntax checking for GDScript
  • Improved inline if else statement syntax checking
  • More resource type supported for syntax highglight
  • Bump default godot version to 3.0
  • Sync the documentations from godot 3.0

Latest commit to this repository however was on Jan 1 and there's no mention of 0.3.5 anywhere.

Cannot open Godot documentation

I do not know if it comes from my editor or your code but I did not find any answer on the web:

This work fine
capture d ecran_2018-04-04_09-13-07

But when I ctrl+clic to see the full documentation :
capture d ecran_2018-04-13_10-01-44

Autocompletions and definitions not working

On VSCode version 1.7.1, and no auto-completions seem to be working. I don't get them while typing, and ctrl+space gives me the message about not finding them. Hovering doesn't work either. Snippets working correctly, though.

Assignment and comparation expression checking

Waring the assign and equals operation below:

var value = value
self.condition == Utils.create_condition(logicmain, cd, format)
if a = b:
  pass

func valid(param):
    return param = null

Valid for-loop considered invalid

func iterate():
  for i in (50):
    pass

This results in error: Invalid for expression. Removing parens from the expression clears the error:

func iterate():
  for i in 50:
    pass

match statement is not parsed correctly

This is correct GDScript code, but you get "Expected end of statement after expression" error on any match pattern after the first one:

func match_func():
  var str = "hello"
  match str:
    "world":
      pass
    "hello":
      pass
    "third":
      pass

Ternary intreprete as error

texture = (_mSprite if !mState else GameVars.backTheme)

or

texture = _mSprite if !mState else GameVars.backTheme

Prompt errors :
': or \' expected at end of the line.
Expected indented block after expression
and

texture = _mSprite if mState else GameVars.backTheme

or

texture = _mSprite if not mState else GameVars.backTheme

don't
Thanks for your awesome work !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.