Godot’s built-in script editor is good for relatively small projects. However, my project has grown and the lack of multiple script panel support is making my development hard especially when I wanted to have 2 scripts opened side-by-side. Why not use VSCode? Because I wanted to spice thing up and force myself to learn a keyboard centric editor.
Therefore, over the past few weeks, I have been trying out Neovim. Since, I’m working on a Godot project so I figured why not try it out with my Godot project development? There are a lot of configurations out there but they don’t work or not as good as intended. So, I have done some research and some trial and errors and the configurations below are what I have came up with. For my use case, I’m using Neovide (a GUI for Neovim) with Lazyvim and working exclusively on GDScript at the moment. Therefore, I won’t be covering C# here.
1. LSP (Language Server Protocol)
I would need to let Neovim know that I’m dealing with GDScript. Luckily, Godot has LSP built-in with the editor. So the configuration is relatively simple:
{
"neovim/nvim-lspconfig",
opts = {
servers = {
gdscript = {},
},
setup = {
gdscript = function(_, opts)
require("lspconfig")["gdscript"].setup({
name = "godot",
-- Fill in your Godot Language Server parameters
cmd = vim.lsp.rpc.connect("127.0.0.1", 6005),
-- Fill in where should Neovim listen to Godot LSP
-- In this case, "/tmp/godot.pipe"
on_init = function(client, init_result)
vim.fn.serverstart("/tmp/godot.pipe")
end,
})
return true
end,
},
},
},
Refer to Editor Settings > Network > Language Server
for the connect parameters
While we are at Editor Settings
, make sure to set the following settings as well:
Text Editor > Behavior
Auto Reload Scripts on External Change
toOn
Text Editor > External
Exec Path :
/path/to/nvim
Exec Flags:
--server /tmp/godot.pipe --remote-send "<esc>:n {file}<CR>:call cursor({line},{col})<CR>"
Use External Editor:
On
Note: Windows users are not be able to use “
/tmp/godot.pipe
”, please use “127.0.0.1:{emptyport}
”, where the{emptyport}
is any empty port you have. You don’t need netcat like what other guides suggest.
To trigger to LSP connection, all you need to do is to open Godot Editor, open Neovim and open any .gd file.
2. Treesitter
Treesitter is used to provide syntax highlight.
{
"nvim-treesitter/nvim-treesitter,
opts = {
ensure_installed = { "gdscript", "godot_resource" },
},
},
3. DAP (Debug Adapter Protocol)
DAP used to facilitate debugging in Neovim. I have added in some extra QOL such as debug GUI and debug virtual texts.
{
"mfussenegger/nvim-dap",
dependencies = {
"nvim-neotest/nvim-nio",
"rcarriga/nvim-dap-ui",
"theHamsta/nvim-dap-virtual-text",
},
config = function()
local dap = require("dap")
local ui = require("dapui")
require("nvim-dap-virtual-text").setup({
show_stop_reason = true,
})
-- Keymaps
vim.keymap.set("n", "<F8>", dap.toggle_breakpoint, { desc = "Debug: Toggle Breakpoint" })
vim.keymap.set("n", "<F5>", dap.continue, { desc = "Debug: Continue" })
vim.keymap.set("n", "<F10>", dap.step_over, { desc = "Debug: Step Over" })
vim.keymap.set("n", "<F11>", dap.step_into, { desc = "Debug: Step Into" })
vim.keymap.set("n", "<F9>", dap.step_out, { desc = "Debug: Step Out" })
-- evaluate variable under cursor
vim.keymap.set("n", "<F12>", function()
ui.eval(nil, { enter = true })
end, { desc = "Debug: Expand" })
vim.keymap.set("n", "<F6>", function()
dap.terminate()
end, { desc = "Debug: Terminate" })
dap.configurations.gdscript = {
{
type = "godot",
request = "launch",
name = "Launch Scene",
project = "${workspaceFolder}",
},
}
dap.adapters.godot = {
type = "server",
host = "127.0.0.1",
port = 6006,
}
ui.setup()
dap.listeners.before.attach.dapui_config = function()
ui.open()
end
dap.listeners.before.launch.dapui_config = function()
ui.open()
end
dap.listeners.before.event_terminated.dapui_config = function()
ui.close()
end
dap.listeners.before.event_exited.dapui_config = function()
ui.close()
end
end,
}
For ports
in dap.adapters.godot
, please refer to Editor Settings > Network > Debug Adapter > Remote Port
. For more stable usage, always debug from Neovim, not from Godot Editor.
With all the configurations above, you should have a decent development experience using Neovim with Godot. That’s all I have for today. Sub ’n share if you find it helpful. Thank you for your time and have a nice day.