diff --git a/README.md b/README.md index f8331de..02c3eb2 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ This plugin provides: - **Optional C# support** including LSP, debugging, and tooling - **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, keymaps, formatting, and environment checks, so you can focus on writing game code rather than troubleshooting editor setup. +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. ## Features @@ -27,12 +27,7 @@ godotdev.nvim provides a complete Neovim environment for Godot 4.x development, ### Debugging (DAP) - Debug GDScript directly from Neovim using `nvim-dap` -- Keymaps for standard debugging actions: - - Continue/Start: `F5` - - Step over: `F10` - - Step into: `F11` - - Step out: `F12` - - Toggle breakpoints: `db` / `dB` +- For setting up keymaps see: `:help dap-mappings` - Optional C# debugging via `netcoredbg` ### Formatting @@ -55,11 +50,6 @@ godotdev.nvim provides a complete Neovim environment for Godot 4.x development, - Automatic LSP attachment for Godot filetypes (`.gd`, `.gdshader`, `.gdresource`, optional `.cs`) - Works cross-platform (macOS, Linux, Windows) with TCP or named pipes -### Keymaps -- LSP: `gd`, `gD`, `gr`, `K`, `rn`, `ca`, `f`, etc. -- DAP: `F5`, `F10`, `F11`, `F12`, `db`, `dB` -- DAP UI: `du` (toggle), `dr` (REPL) - ### Optional C# Support - Enable by setting `csharp = true` in `require("godotdev").setup()` - Health checks and DAP integration included @@ -171,34 +161,6 @@ If the LSP disconnects or you opened a script before Neovim, run: Reconnects **all Godot buffers** to the LSP. -## Keymaps - -### LSP -- `gd` → Go to definition -- `gD` → Go to declaration -- `gy` → Type definition -- `gi` → Go to implementation -- `gr` → List references -- `K` → Hover -- `` → Signature help -- `rn` → Rename symbol -- `ca` → Code action -- `f` → Format buffer -- `gl` → Show diagnostics -- `[d` / `]d` → Previous/next diagnostic - -### DAP -- `F5` -> Continue/Start -- `F10` -> Step over -- `F11` -> Step into -- `F12` -> Step out -- `db` -> Toggle Breakpoint -- `dB` -> Conditional breakpoint - -### DAP UI -- `du` -> , Toggle UI -- `dr` -> , Open REPL - ## C# Installation Support - Enable by setting `csharp = true` in `require("godotdev").setup()` diff --git a/lua/godotdev/dap.lua b/lua/godotdev/dap.lua index 86e403d..ef5f540 100644 --- a/lua/godotdev/dap.lua +++ b/lua/godotdev/dap.lua @@ -3,7 +3,6 @@ local M = {} function M.setup(config) local dap = require("dap") local dapui = require("dapui") - require("godotdev.keymaps").attach_dap() dap.adapters.godot = { type = "server", diff --git a/lua/godotdev/formatting.lua b/lua/godotdev/formatting.lua index d95d59b..b7764fd 100644 --- a/lua/godotdev/formatting.lua +++ b/lua/godotdev/formatting.lua @@ -1,25 +1,20 @@ -vim.api.nvim_create_autocmd("FileType", { - pattern = "gdscript", - callback = function() - vim.bo.expandtab = true - vim.bo.shiftwidth = 4 - vim.bo.softtabstop = 4 - vim.bo.tabstop = 4 - vim.bo.autoindent = true - vim.bo.smartindent = true - end, -}) +local config = require("godotdev").opts vim.api.nvim_create_autocmd("BufWritePost", { pattern = "*.gd", callback = function() - if vim.fn.executable("gdformat") == 1 then - -- format with gdformat - vim.cmd("silent !gdformat %") - -- reload buffer if changed externally - vim.cmd("checktime") - else - vim.notify("gdformat not found in PATH. Run `:checkhealth godotdev` for more info.", vim.log.levels.WARN) + local exe = config.formatter_cmd or config.formatter + if vim.fn.executable(exe) ~= 1 then + vim.notify(exe .. " not found in PATH. Run `:checkhealth godotdev` for more info.", vim.log.levels.WARN) + return end + + if config.formatter == "gdformat" then + vim.cmd("silent !" .. exe .. " %") + elseif config.formatter == "gdscript-format" then + vim.cmd("silent !" .. exe .. " %") + end + + vim.cmd("checktime") end, }) diff --git a/lua/godotdev/keymaps.lua b/lua/godotdev/keymaps.lua deleted file mode 100644 index c090c9c..0000000 --- a/lua/godotdev/keymaps.lua +++ /dev/null @@ -1,82 +0,0 @@ -local M = {} - -function M.attach_lsp(bufnr) - local opts = { buffer = bufnr } - - local has_telescope, telescope_builtin = pcall(require, "telescope.builtin") - - local function map(mode, lhs, rhs, desc) - vim.keymap.set(mode, lhs, rhs, vim.tbl_extend("force", opts, { desc = desc })) - end - - -- Definitions / Declarations - map("n", "gd", has_telescope and telescope_builtin.lsp_definitions or vim.lsp.buf.definition, "LSP: Go to definition") - map("n", "gD", vim.lsp.buf.declaration, "LSP: Go to declaration") - map( - "n", - "gy", - has_telescope and telescope_builtin.lsp_type_definitions or vim.lsp.buf.type_definition, - "LSP: Type definition" - ) - map( - "n", - "gi", - has_telescope and telescope_builtin.lsp_implementations or vim.lsp.buf.implementation, - "LSP: Go to implementation" - ) - map("n", "gr", has_telescope and telescope_builtin.lsp_references or vim.lsp.buf.references, "LSP: List references") - - -- Info - map("n", "K", vim.lsp.buf.hover, "LSP: Hover documentation") - map("n", "", vim.lsp.buf.signature_help, "LSP: Signature help") - - -- Symbols - map( - "n", - "ds", - has_telescope and telescope_builtin.lsp_document_symbols or vim.lsp.buf.document_symbol, - "LSP: Document symbols" - ) - map( - "n", - "ws", - has_telescope and telescope_builtin.lsp_dynamic_workspace_symbols or vim.lsp.buf.workspace_symbol, - "LSP: Workspace symbols" - ) - - -- Actions - map("n", "rn", vim.lsp.buf.rename, "LSP: Rename symbol") - map({ "n", "v" }, "ca", vim.lsp.buf.code_action, "LSP: Code action") - map("n", "f", function() - vim.lsp.buf.format({ async = true }) - end, "LSP: Format buffer") - - -- Diagnostics - map("n", "gl", vim.diagnostic.open_float, "LSP: Show diagnostics") - map("n", "[d", vim.diagnostic.goto_prev, "LSP: Previous diagnostic") - map("n", "]d", vim.diagnostic.goto_next, "LSP: Next diagnostic") -end - -function M.attach_dap() - local dap = require("dap") - local dapui = require("dapui") - - local function map(mode, lhs, rhs, desc) - vim.keymap.set(mode, lhs, rhs, { desc = desc }) - end - - -- Basic debugger controls - map("n", "", dap.continue, "DAP: Continue/Start") - map("n", "", dap.step_over, "DAP: Step over") - map("n", "", dap.step_into, "DAP: Step into") - map("n", "", dap.step_out, "DAP: Step out") - map("n", "db", dap.toggle_breakpoint, "DAP: Toggle breakpoint") - map("n", "dB", function() - dap.set_breakpoint(vim.fn.input("Breakpoint condition: ")) - end, "DAP: Conditional breakpoint") - - -- UI - map("n", "du", dapui.toggle, "DAP: Toggle UI") - map("n", "dr", dap.repl.open, "DAP: Open REPL") -end -return M diff --git a/lua/godotdev/lsp.lua b/lua/godotdev/lsp.lua index 0948f38..4479e84 100644 --- a/lua/godotdev/lsp.lua +++ b/lua/godotdev/lsp.lua @@ -4,7 +4,6 @@ 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 @@ -29,7 +28,6 @@ M.setup = function(config) capabilities = capabilities, on_attach = function(client, bufnr) utils.suppress_unsupported_lsp_messages(client, { "Method not found: godot/reloadScript" }) - keymaps.attach_lsp(bufnr) end, }) end