Attach Godot LSP server to Neovim on Linux/MacOS

This commit is contained in:
mathijs-bakker
2025-08-20 17:17:59 +02:00
parent 04bbec67cb
commit 70fec979b3
6 changed files with 168 additions and 0 deletions

29
lua/godotdev/lsp.lua Normal file
View File

@@ -0,0 +1,29 @@
local M = {}
M.setup = function(config)
config = config or {}
local lspconfig = require("lspconfig")
local utils = require("godotdev.utils")
local keymaps = require("godotdev.keymaps")
local host = config.editor_host or "127.0.0.1"
local port = config.editor_port or 6005
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.typeDefinition = nil -- suppress unsupported typeDefinition
lspconfig.gdscript.setup({
name = "godot_editor",
cmd = vim.lsp.rpc.connect(host, port),
filetypes = { "gd", "gdscript" },
root_dir = lspconfig.util.root_pattern("project.godot"),
capabilities = capabilities,
on_attach = function(client, bufnr)
-- suppress known Godot unsupported messages
utils.suppress_lsp_messages(client, { "Method not found: godot/reloadScript" })
keymaps.attach(bufnr)
end,
})
end
return M