344 words
2 minutes
VSCode with Godot 4 and Common Bugs Tutorial

Requirements#

  1. VSCode
  2. Godot
  3. godot-tools plugin for VSCode

Other Optional Plugins (not related to the setup):

  1. C# Tools for Godot -> C# Support
  2. Godot Files -> Shader support
  3. Godot Hover Docs -> Get documentation information for C++ (GDExtension)
  4. Godot Snippets for C# -> Snippest for C#
  5. Godot Docs for C# -> Hover over to get documentation for C#
  6. Godot Editor Theme -> Godots theme for VSCode

Tutorial#

  1. Close all the scripts open in the editor
TIP

You can do this quickly via right clicking where the list of scripts are on the left and say “close all”

  1. Go to Editor Settings
  2. Go to Text Editor -> External
  3. In Exec Path get the location of the executable for VS Code
  4. In Exec Flags input {project} --goto {file}:{line}:{col}
  5. Enable Use External Editor
  6. Double click a script to open it will open VSCode

Now whenever you open a project in Godot, VSCode will load automatically!


Common Bugs#

Godot can be a bit finnicky with it’s language server (how external editors are able to do things like autocomplete). To my knowledge, this is not a VSCode issue but a Godot issue as I’ve had mixed results with a multitude of editors include nvim, Zed and Rider. VSCode however for the most part works fine, but you may run into a bug here and there. Here are the solutions I’ve found to fix it.

Changing code in VSCode makes Godot bring up a warning that files were changed outside the project and whether to load the new fields or keep the ones in the project#

Sometimes, Godot and VSCode may disconnect. There are two things you can do to try to fix it

  1. Close VSCode and reopen by opening a script from Godot
    • If VSCode is open before the Godot project, it may cause connection issues
  2. Restart the Godot Project
  3. Make sure in your VSCode godot-tools setup, you have the correct version of the Godot application selected
  4. Disable the external editor settings in Godot and re-enable

VSCode gives a warning that it can’t connect to Godot#

If when loading up VSCode it gives this error pop-up, then select it to view the version of Godot you have set in your godot-tools plugin and make sure it matches the Godot version you’re using