Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

使用外部文字編輯器

使用外部文字編輯器

Godot 可與外部編輯器一起使用,如 Sublime Text 或 Visual Studio Code。欲啟用外部文字編輯器,請於 編輯器 -> 編輯器設定 --> Text Editor(文字編輯器) -> External(外部) 瀏覽對應的編輯器設定

文字編輯器 > 編輯器設定的外部部分

編輯器設定中的 文字編輯器 > 外部 部分

該設定有兩個欄位:執行路徑與命令行旗標。旗標可允許將該編輯器與 Godot 整合、傳入欲開啟的檔案、以及其他相關的參數。Godot 會取代旗標中的下列佔位字元:

Exec Flags 中的欄位

會取代為

{project}

專案目錄的絕對路徑

{file}

檔案的絕對路徑

{col}

錯誤的列號

{line}

錯誤的行號

下列為各種編輯器的一些 Exec Flags 範例:

編輯器

執行旗標

Geany/Kate

{file} --line {line} --column {col}

Atom

{file}:{line}

JetBrains Rider

--line {line} {file}

Visual Studio Code

{project} --goto {file}:{line}:{col}

Vim (gVim)

"+call cursor({line}, {col})" {file}

Emacs

"+call cursor({line}, {col})" {file}

Atom/Sublime Text

{project} --goto {file}:{line}:{col}

備註

對於 Windows 平臺上的 Visual Studio Code,你需要指向 code.cmd 檔案。

Visual Studio 必須指向 code.cmd 檔案。

使用外部文字編輯器

在除錯器中使用外部編輯器由設定中的單獨選項決定。更多細節詳見 腳本編輯器除錯工具及選項

官方 Git 外掛

以下程式碼編輯器有官方外掛程式:

LSP/DAP support

Godot supports the Language Server Protocol (LSP) for code completion and the Debug Adapter Protocol (DAP) for debugging. You can check the LSP client list and DAP client list to find if your editor supports them. If this is the case, you should be able to take advantage of these features without the need of a custom plugin.

To use these protocols, a Godot instance must be running on your current project. You should then configure your editor to communicate to the running adapter ports in Godot, which by default are 6005 for LSP, and 6006 for DAP. You can change these ports and other settings in the Editor Settings, under the Network > Language Server and Network > Debug Adapter sections respectively.

Below are some configuration steps for specific editors:

Visual Studio Code

You need to install the official Visual Studio Code plugin.

For LSP, follow these instructions to change the default LSP port. The connection status can be checked on the status bar:

../../_images/lsp_vscode_status.png

For DAP, specify the debugServer property in your launch.json file:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "GDScript Godot",
            "type": "godot",
            "request": "launch",
            "project": "${workspaceFolder}",
            "port": 6007,
            "debugServer": 6006,
        }
    ]
}

Emacs

Check the official instructions to configure LSP, and DAP.