An open API service indexing awesome lists of open source software.

https://github.com/mathijs-bakker/godot-lsp.nvim

Neovim plugin for Godot LSP & DAP. Supports GDScript with TreeSitter. Use Neovim as your Godot's external editor.
https://github.com/mathijs-bakker/godot-lsp.nvim

dap debugger gdscript godot lsp neovim neovim-plugin

Last synced: 9 months ago
JSON representation

Neovim plugin for Godot LSP & DAP. Supports GDScript with TreeSitter. Use Neovim as your Godot's external editor.

Awesome Lists containing this project

README

          

## This project is archived,
### there's a better solution here: [godotdev.nvim](https://github.com/Mathijs-Bakker/godotdev.nvim)

# godot-lsp.nvim

A Neovim plugin to integrate Godot's LSP for GDScript, providing features like _go-to-definition, hover documentation, diagnostics,_ and _completion_ across multiple buffers. Supports TreeSitter syntax highlighting and experimental DAP debugging.

## ๐Ÿ“‘ Table of Contents

- [โœจ Features](#-features)
- [โ— Requirements](#-requirements)
- [๐ŸŒฑ Why I Created This Plugin](#-why-i-created-this-plugin)
- [๐Ÿš€ Quick Start](#-quick-start)
- [โš™๏ธ Setup](#%EF%B8%8F-setup)
- [๐Ÿ“ฆ Installation](#-installation)
- [๐ŸŒณ TreeSitter Parser](#-treesitter-parser)
- [๐ŸŒ External Editor](#-external-editor)
- [๐ŸŽฎ Usage](#-usage)
- [๐Ÿค– Commands](#-commands)
- [๐Ÿ› ๏ธ Configuration](#%EF%B8%8F-configuration)
- [๐Ÿ“‹ Debug Logging](#-debug-logging)
- [๐Ÿชฒ DAP Debugging](#-dap-debugging)
- [๐Ÿ•ต๐Ÿปโ€โ™‚๏ธ Troubleshooting](#%EF%B8%8F-troubleshooting)
- [๐Ÿค Contributing](#-contributing)
- [๐Ÿ“„ License](#-license)

## โœจ Features

- **LSP Integration**: Autocompletion, definitions, references, and diagnostics via Godotโ€™s LSP.
- **Multi-Buffer Support**: Syncs LSP across all GDScript buffers.
- **TreeSitter**: Enhanced syntax highlighting.
- **Custom Keymaps**: Configurable shortcuts for LSP actions.
- **DAP Debugging**: Experimental debugging support (unstable).

Full Feature Details

- Connects to Godotโ€™s LSP server via `ncat` on port 6005.
- Supports go-to-definition, hover documentation, renaming, and workspace symbols.
- Automatic buffer attachment and TreeSitter highlighting on `.gd` file open.
- Experimental DAP with breakpoints and step-through (requires `nvim-dap`).

## โ— Requirements

- Neovim 0.9.0+
- `ncat` (e.g., `brew install ncat` on macOS, `apt install ncat` on Linux)
- Godot 4.3+ with `--lsp`
- [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig)
- [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter)
- Optional: [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim), [nvim-dap](https://github.com/mfussenegger/nvim-dap), [nvim-dap-ui](https://github.com/rcarriga/nvim-dap-ui)

## ๐ŸŒฑ Why I Created This Plugin

I built this to use Neovim as my Godot external editor, frustrated by ineffective setups and plugins. Itโ€™s macOS-focused, uses Ghostty, but runs on Linux too. No Windows support yetโ€”contributions welcome! Ooh did I mentioned experimental DAP debugging?

## ๐Ÿš€ Quick Start

1. Install with **lazy.nvim**:
```lua
require("lazy").setup({ { "Mathijs-Bakker/godot-lsp.nvim" } })
```
```
:Lazy sync
```
1. Start Godot: `godot --editor --lsp --verbose`
1. Configure external editor (see Setup).
1. Open a `.gd` file in Neovim for LSP features.

## โš™๏ธ Setup
### ๐Ÿ“ฆ Installation
Use lazy.nvim:
```
luarequire("lazy").setup({
{ "Mathijs-Bakker/godot-lsp.nvim", config = function() require("godot-lsp").setup() end },
{ "neovim/nvim-lspconfig" },
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
})
```
Then run:
```
:Lazy sync
```

### ๐ŸŒณ TreeSitter Parser
Install the `gdscript` parser:
```
:TSInstall gdscript
```

### ๐ŸŒ External Editor

1. Create a launch script (e.g., `~/.local/bin/open-nvim-godot.sh`):
```bash
#!/bin/bash
FILE="$1" LINE="$2" COL="$3"
/Applications/Ghostty.app/Contents/MacOS/ghostty -- nvim "$FILE" +"$LINE:$COL"
# Linux: gnome-terminal -- nvim "$FILE" +"$LINE:$COL"
```
1. Make executable:
```bash
chmod +x ~/.local/bin/open-nvim-godot.sh
```
1. Add to PATH:
```bash
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc
```
1. Configure Godot: `Editor > Editor Settings > Text Editor > External` with full path and `"{file}" "{line}" "{col}"`.

### ๐ŸŽฎ Usage

- Start Godot with `godot --editor --lsp --verbose`.
- Open `.gd` files for LSP and TreeSitter features.
- Use keymaps (see Configuration).

Advanced Usage

- **Keymaps**: `gd` (definition), `K` (hover), `cd` (diagnostics), etc.
- **Autocommands**: Auto-attaches buffers, syncs with Godot.
- See [Commands](#-commands) and [Configuration](%EF%B8%8F-configuration) for more.

### ๐Ÿค– Commands

- `:GodotLspStart:` Start LSP manually.
- `:GodotLspStatus:` Check server status.
- `:GodotLspAttachAll:` Attach all buffers.

### ๐Ÿ› ๏ธ Configuration
Customize via `setup`:
```lua
require("godot-lsp").setup({
cmd = { "ncat", "localhost", "6005" },
keymaps = { definition = "gd", hover = "K", format = nil },
})
```
You can find a complete setup example [here](docs/TROUBLESHOOTING.md#%EF%B8%8F-example-setup).

## ๐Ÿ“‹ Debug Logging
Enable with `debug_logging = true` for logs in `~/.cache/nvim/godot-lsp.log`.

## ๐Ÿชฒ DAP Debugging
Enable with `dap = true` and `godot --remote-debug localhost:6006 --editor`.
Use:
- `` (continue),
- `` (breakpoint),
- etc.

# ๐Ÿ•ต๐Ÿปโ€โ™‚๏ธ Troubleshooting

Common Issues: LSP not starting, no syntax highlighting, DAP failures, plugin setup.
Details: See full [troubleshooting](docs/TROUBLESHOOTING.md) for steps and workarounds.

## ๐Ÿค Contributing
Submit issues or PRs at github.com/Mathijs-Bakker/godot-lsp.nvim.

## ๐Ÿ“„ License
[MIT License](LICENSE)