diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-06-25 07:44:15 +0200 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-06-25 07:44:15 +0200 |
| commit | fb3587e51e0908c3d43722c55741cf6a386e39ce (patch) | |
| tree | 248c42999260ab6c9175aea90365aab08bd68c9d /plugin/50-dap.lua | |
| parent | c22fab35706facfa780b800b4dc72559f0ac6c60 (diff) | |
| download | nvim-config-fb3587e51e0908c3d43722c55741cf6a386e39ce.tar.gz nvim-config-fb3587e51e0908c3d43722c55741cf6a386e39ce.zip | |
refactor(nvim): restructure plugin configs, fix OSV launch port
- rewrite the file headers as block comments and regroup the
autocompletion and dap files into Settings / Autocommands / Keymaps
sections
- fix `OSVLaunch`: `dap.configurations.lua.port` was nil (the field is
a list), so the server ignored 8086; share an `OSV_PORT` constant
between the launch call and the attach configuration
- `.luarc.json`: list each plugin directory explicitly so lua_ls loads
their type annotations
- use `vim.fs.basename` instead of `vim.fn.fnamemodify(…, ":t")`
Diffstat (limited to 'plugin/50-dap.lua')
| -rw-r--r-- | plugin/50-dap.lua | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/plugin/50-dap.lua b/plugin/50-dap.lua index 7c715ba..4f07214 100644 --- a/plugin/50-dap.lua +++ b/plugin/50-dap.lua @@ -1,24 +1,46 @@ --- --- 50-dap.lua --- --- * Configures OSV: --- User commands: --- * OSVLaunch: start the OSV server (on the debuggee) --- * OSVStatus: show status of OSV server and client --- +--[[ 50-dap.lua — debug Lua running inside Neovim via OSV (one-small-step-for-vimkind). + +Wires nvim-dap to the OSV adapter so the running Neovim instance can be attached to and debugged. + +User commands: + `OSVLaunch`: start the OSV server (on the debuggee) + `OSVStatus`: show the status of the OSV server and client +]] local dap = require("dap") +local osv = require("osv") + +-- Port shared by the OSV server and the dap attach configuration. +local OSV_PORT = 8086 ---------------------------------------------------------------------------------------------------- --- OSV (Lua inside Neovim) +-- OSV (Lua inside Neovim) ------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------- -dap.configurations.lua = { +-- Start the OSV server so the running Neovim instance can be attached to. +local function osv_launch() + osv.launch({ port = OSV_PORT }) +end + +-- Report whether the OSV server is running and whether a client is attached. +local function osv_status() + vim.notify("OSV server running: " .. tostring(osv.is_running())) + vim.notify("OSV client attached: " .. tostring(osv.is_attached())) +end + +---------------------------------------------------------------------------------------------------- +-- Configuration & commands ------------------------------------------------------------------------ +---------------------------------------------------------------------------------------------------- + +--[[ The cast restores dap.configurations' own type: with fzf-lua in the lua_ls library its dap +provider cross-merges a `configurations` field, which otherwise mistypes this as a function. ]] +local configurations = dap.configurations --[[@as table<string, dap.Configuration[]>]] +configurations.lua = { { type = "nlua", request = "attach", name = "Attach to running Neovim instance", - port = 8086, + port = OSV_PORT, }, } @@ -26,18 +48,5 @@ dap.adapters.nlua = function(callback, config) callback({ type = "server", host = config.host or "127.0.0.1", port = config.port }) end -local osv = require("osv") - -local function osv_launch() - osv.launch({ port = dap.configurations.lua.port }) -end - -local function osv_status() - vim.notify("OSV server running: " .. tostring(osv.is_running())) - vim.notify("OSV client attached: " .. tostring(osv.is_attached())) -end - ----------------------------------------------------------------------------------------------------- - vim.api.nvim_create_user_command("OSVLaunch", osv_launch, { desc = "Launch OSV server" }) vim.api.nvim_create_user_command("OSVStatus", osv_status, { desc = "Show OSV status" }) |
