summaryrefslogtreecommitdiffstats
path: root/.config/nvim/plugin/50-dap.lua
blob: 7c715baeb30d2d4348677e0fed497263f073a9c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
--
-- 50-dap.lua
--
-- * Configures OSV:
--   User commands:
--   * OSVLaunch: start the OSV server (on the debuggee)
--   * OSVStatus: show status of OSV server and client
--

local dap = require("dap")

----------------------------------------------------------------------------------------------------
-- OSV (Lua inside Neovim)
----------------------------------------------------------------------------------------------------

dap.configurations.lua = {
	{
		type = "nlua",
		request = "attach",
		name = "Attach to running Neovim instance",
		port = 8086,
	},
}

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" })