Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
296 changes: 42 additions & 254 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,243 +32,26 @@ This plugin helps you to set up:

While it is possible to configure Neovim manually for Godot development, this plugin **simplifies setup** and ensures a consistent, cross-platform workflow. It automatically configures LSP, debugging, formatting, and environment checks, so you can focus on writing game code rather than troubleshooting editor setup.

## Why godotdev.nvim?
- Turn Neovim into a first‑class external editor for Godot 4 projects.
- Get LSP features for GDScript/GDShader without manual wiring.
- Debug GDScript via DAP and validate setup with built‑in health checks.

## Features

Below is a quick overview of what you get out of the box:

### LSP Support
- Full GDScript language support (Go to definition, references, hover, rename, code actions, etc.)
- `.gdshader` syntax highlighting and language features via Treesitter
- Optional C# LSP support (user-managed `csharp-ls` or OmniSharp) for Godot projects with C# scripts

### Debugging (DAP)
- Debug GDScript directly from Neovim using `nvim-dap`
- Optional C# debugging via `netcoredbg`

### Formatting
- Automatic `.gd` file formatting using [`gdtoolkit`](https://pypi.org/project/gdtoolkit/)
- Reloads buffer after formatting for immediate feedback
- Recommended `.editorconfig` included for consistent indentation (4 spaces per indent)

### Health Checks
- `:checkhealth godotdev` validates:
- Built-in Neovim LSP support plus plugin dependencies: `nvim-dap`, `nvim-dap-ui`, `nvim-treesitter`
- Godot editor LSP and debug servers
- Floating Godot docs support (`curl` and active docs source configuration)
- Optional C# tooling: `dotnet`, `csharp-ls`/OmniSharp, `netcoredbg`
- Formatter: `gdformat` (with installation instructions)

### Editor Integration
- Commands to start or reconnect to Godot’s editor LSP:
- `:GodotStartEditorServer`
- `:GodotReconnectLSP`
- Commands to run Godot from Neovim without DAP:
- `:GodotRunProject`
- `:GodotRunCurrentScene`
- `:GodotRunScene {path}`
- `:GodotRunScenePicker` (optional Telescope integration)
- Commands to open Godot class reference docs:
- `:GodotDocs [ClassName]`
- `:GodotDocsFloat [ClassName]`
- `:GodotDocsBuffer [ClassName]`
- `:GodotDocsBrowser [ClassName]`
- `:GodotDocsCursor`
- Automatic LSP attachment for Godot filetypes (`.gd`, `.gdshader`, `.gdresource`, optional `.cs`)
- Works cross-platform (macOS, Linux, Windows) with TCP or named pipes

### Optional C# Support
- Enable by setting `csharp = true` in `require("godotdev").setup()`
- C# LSP is configured by you (the plugin only checks that `csharp-ls` or OmniSharp is installed)
- Health checks and DAP integration included

## Requirements

- Neovim 0.11+
- Godot 4.x+ with TCP LSP enabled
- `nvim-dap` and `nvim-dap-ui` for debugging
- `nvim-treesitter`
- Windows users must have [`ncat`](https://nmap.org/ncat/) in PATH
- Optional C# support requires (you manage the LSP configuration):
- .NET SDK (dotnet)
- C# LSP server (csharp-ls recommended or omnisharp)
- netcoredbg debugger

## Installation (Lazy.nvim)

```lua
{
'Mathijs-Bakker/godotdev.nvim',
dependencies = { 'nvim-dap', 'nvim-dap-ui', 'nvim-treesitter' },
}
```

## Installation (`vim.pack`, Neovim 0.12+)

```lua
vim.pack.add({
"https://github.com/Mathijs-Bakker/godotdev.nvim",
"https://github.com/mfussenegger/nvim-dap",
"https://github.com/rcarriga/nvim-dap-ui",
"https://github.com/nvim-treesitter/nvim-treesitter",
})
```
## Quickstart

1. Open your Godot project in Neovim
1. Start Godot editor with TCP LSP enabled (Editor Settings → Network → Enable TCP LSP server)
1. Open a `.gd` or `.gdshader` file
1. LSP will automatically attach
1. Use Neovim's built-in LSP mappings such as `K`, `grr`, `grn`, and `gri`, or your own custom mappings
1. Start debugging with DAP (Launch scene configuration)
1. Optional: Enable C# support by setting `csharp = true` in the plugin setup
1. Run `:checkhealth godotdev` at any time to verify plugin, LSP, debug server, and C# dependencies

## Configuration

### Optional settings
```lua
require("godotdev").setup({
editor_host = "127.0.0.1", -- Godot editor host
editor_port = 6005, -- Godot LSP port
debug_port = 6006, -- Godot debugger port
csharp = true, -- Enable C# Installation Support
autostart_editor_server = false, -- opt-in: start a Neovim server automatically on setup
formatter = "gdformat", -- "gdformat" | "gdscript-format" | false
formatter_cmd = nil, -- string or argv list, e.g. { "gdscript-format", "--check" }
editor_server = {
address = nil, -- nil uses the current server or the platform default
remove_stale_socket = true,
},
treesitter = {
auto_setup = true, -- convenience default; disable if you manage nvim-treesitter yourself
ensure_installed = { "gdscript" },
},
docs = {
renderer = "float", -- default: open docs in a floating window
fallback_renderer = "browser", -- nil | "browser" | "buffer"; browser is the only fetch-recovery fallback
missing_symbol_feedback = "message", -- "message" | "notify"
version = "stable", -- e.g. "stable", "latest", "4.5"
language = "en",
source_ref = "master", -- godot-docs git ref used for floating docs
source_base_url = nil, -- optional override for raw docs source
timeout_ms = 10000,
cache = {
enabled = true,
max_entries = 64,
},
float = {
width = 0.8,
height = 0.8,
border = "rounded",
},
buffer = {
position = "right", -- "right" | "bottom" | "current"
size = 0.4,
},
},
})
```

For formatter commands with flags, prefer an argv list:

```lua
formatter_cmd = { "gdscript-format", "--check" }
```

To disable autoformat-on-save entirely:

```lua
formatter = false
```

If you already manage `nvim-treesitter` yourself, you can disable plugin-managed setup:

```lua
treesitter = {
auto_setup = false,
}
```

Default notes:
- `autostart_editor_server = false` is the safer default because starting a Neovim server is an external-editor concern and should be opt-in.
- `treesitter.auto_setup = true` stays enabled by default for convenience, but it is safe to turn off if you already configure `nvim-treesitter` yourself.
- `docs.fallback_renderer = "browser"` remains the default because browser fallback is the only option that can recover when rendered `.rst` docs cannot be fetched.
- The plugin uses Neovim's built-in LSP APIs; `nvim-lspconfig` is not required unless you want it for other servers in your own config.

**Note:** This plugin does not define any keymaps by default, so it will not interfere with the standard DAP mappings. If you want custom keybindings, you can configure them yourself. For example, you could map `:GDebug` to `DapNew` to start one or more new debug sessions.

See `:help dap-mappings` and `:help dap-user-commands` for more details.

Additional references:
- [DAP documentation](https://github.com/mfussenegger/nvim-dap/blob/master/doc/dap.txt)
- [DAP README / usage](https://github.com/mfussenegger/nvim-dap/tree/master?tab=readme-ov-file#usage)

## Testing

Run the headless test suite:

```bash
nvim --headless -u NONE -i NONE -c "lua dofile('tests/run.lua')" -c qa
```

The same command runs in GitHub Actions on pushes to `master` and on pull requests.

For integration testing, also run the plugin inside Neovim against a real Godot project and verify editor server, docs, formatting, and debugging flows on your target platform.

### Optimize Godot editor for Neovim

Below are the recommended settings for configuring the Godot editor for optimal integration with Neovim as your external editor. To access these settings, make sure that the **Advanced Settings switch is enabled** at the top of the **Editor Settings dialog**.

- `Editor Settings > Text Editor > Behavior > Auto Reload Scripts on External Change`

<details><summary>Show Screenshot -> Godot Editor Settings</summary><img src="assets/godot-editor-auto-reload-script.png"></details>
- `Editor Settings > Interface > Editor > Save on Focus Loss`

<details><summary>Show Screenshot -> Godot Editor Settings</summary><img src="assets/godot-editor-focus.png"></details>
- `Editor Settings > Interface > Editor > Import Resources When Unfocused`

<details><summary>Show Screenshot -> Godot Editor Settings</summary><img src="assets/godot-editor-focus.png"></details>

### Recommended Godot addon

If you use `godotdev.nvim` as your main external-editor workflow, the companion addon
[`godotdev.nvim-node-copy`](https://github.com/Mathijs-Bakker/godotdev.nvim-node-copy)
is recommended.

Why it helps:
- Godot's built-in external editor integration does not provide drag-and-drop of nodes into Neovim.
- The addon adds copy actions for selected nodes in the Scene Tree and 2D editor, so you can paste useful references directly into your script.
- It keeps the workflow explicit and safe: select a node in Godot, copy the reference you want, then paste it at the cursor in Neovim.

<div align="left"><img src="assets/godotdev_nvim_node_copy.png" width="500"></div>

It currently supports copying:
- node paths
- `$Node` references
- `get_node(...)` expressions
- typed `@onready var` snippets
- C# property snippets

# godotdev.nvim

A Neovim plugin for Godot 4 that brings GDScript/GDShader LSP, DAP debugging, and formatting to your external‑editor workflow.

This plugin helps you to set up:

- **LSP support** for GDScript and Godot shaders (`.gdshader` files)
- **Godot class docs** in Neovim, rendered from the official docs source as Markdown
- **Debugging** via `nvim-dap` for GDScript
- **Treesitter syntax highlighting** for Godot shader files
- **Automatic formatting** of `.gd` files using `gdformat`
- **Optional C# support** (user-managed LSP, plus debugging and tooling checks)
- **Built-in health checks** to verify environment, dependencies, and editor integration

While it is possible to configure Neovim manually for Godot development, this plugin **simplifies setup** and ensures a consistent, cross-platform workflow. It automatically configures LSP, debugging, formatting, and environment checks, so you can focus on writing game code rather than troubleshooting editor setup.
## Table of Contents

- [Why godotdev.nvim?](#why-godotdevnvim)
- [Features](#features)
- [Requirements](#requirements)
- [Installation (Lazy.nvim)](#installation-lazynvim)
- [Installation (`vim.pack`, Neovim 0.12+)](#installation-vimpack-neovim-012)
- [Quickstart](#quickstart)
- [Configuration](#configuration)
- [Testing](#testing)
- [Optimize Godot editor for Neovim](#optimize-godot-editor-for-neovim)
- [Open scripts from Godot Editor in Neovim (running in a terminal)](#open-scripts-from-godot-editor-in-neovim-running-in-a-terminal)
- [Godot editor server](#godot-editor-server)
- [Reconnect to Godot's LSP server](#reconnect-to-godots-lsp-server)
- [Run Godot](#run-godot)
- [Godot class docs](#godot-class-docs)
- [C# Installation Support](#c-installation-support)
- [Autoformatting / Indentation](#autoformatting--indentation)
- [Recommended Godot addon (Node Copy)](#recommended-godot-addon-node-copy)
- [Hiding Godot Project Files in oil.nvim and mini.files](#hiding-godot-project-files-in-oilnvim-and-minifiles)

## Why godotdev.nvim?
- Turn Neovim into a first‑class external editor for Godot 4 projects.
Expand Down Expand Up @@ -458,7 +241,7 @@ The same command runs in GitHub Actions on pushes to `master` and on pull reques

For integration testing, also run the plugin inside Neovim against a real Godot project and verify editor server, docs, formatting, and debugging flows on your target platform.

### Optimize Godot editor for Neovim
## Optimize Godot editor for Neovim

Below are the recommended settings for configuring the Godot editor for optimal integration with Neovim as your external editor. To access these settings, make sure that the **Advanced Settings switch is enabled** at the top of the **Editor Settings dialog**.

Expand All @@ -472,18 +255,7 @@ Below are the recommended settings for configuring the Godot editor for optimal

<details><summary>Show Screenshot -> Godot Editor Settings</summary><img src="assets/godot-editor-focus.png"></details>

### Recommended Godot addon

If you use `godotdev.nvim` as your main external-editor workflow, the companion addon
[`godotdev.nvim-node-copy`](https://github.com/Mathijs-Bakker/godotdev.nvim-node-copy)
is recommended.
It currently supports copying:
- node paths
- `$Node` references
- `get_node(...)` expressions
- typed `@onready var` snippets

### Open .gdscript/.gdshader from Godot in Neovim
## Open scripts from Godot Editor in Neovim (running in a terminal)

When you click on a gdscript in Godot's FileSystem dock it doesn't open automatically in Neovim.
A [workaround](doc/neovim-external-editor-setup.md) is to to create a small script which launches the file in Neovim.
Expand Down Expand Up @@ -626,14 +398,30 @@ This plugin automatically sets buffer options for `.gd` files.

Additionally, `.gd` files are autoformatted on save with [`gdtoolkit`](https://github.com/godotengine/gdtoolkit) unless you set `formatter = false`:

```vim
:w
```

Make sure `gdformat` is installed and in your PATH. If not, you will see a warning notification.

For more info on indentation: `:help godotdev-indent`

## Recommended Godot addon (Node Copy)

If you use `godotdev.nvim` as your main external-editor workflow, the companion addon
[`godotdev.nvim-node-copy`](https://github.com/Mathijs-Bakker/godotdev.nvim-node-copy)
is recommended.

Why it helps:
- Godot's built-in external editor integration does not provide drag-and-drop of nodes into Neovim.
- The addon adds copy actions for selected nodes in the Scene Tree and 2D editor, so you can paste useful references directly into your script.
- It keeps the workflow explicit and safe: select a node in Godot, copy the reference you want, then paste it at the cursor in Neovim.

<div align="left"><img src="assets/godotdev_nvim_node_copy.png" width="500"></div>

It currently supports copying:
- node paths
- `$Node` references
- `get_node(...)` expressions
- typed `@onready var` snippets
- C# property snippets

## Hiding Godot Project Files in oil.nvim and mini.files
Godot generates files and folders like `.uid`, `.import`, or `.godot/` that can clutter your file explorer.
You can hide them in both [oil.nvim](https://github.com/stevearc/oil.nvim) and [mini.files](https://github.com/nvim-mini/mini.nvim
Expand Down
Loading