fix: use coroutine to get URL
This commit is contained in:
@@ -29,7 +29,6 @@
|
|||||||
"nvim-cmp": { "branch": "main", "commit": "12509903a5723a876abd65953109f926f4634c30" },
|
"nvim-cmp": { "branch": "main", "commit": "12509903a5723a876abd65953109f926f4634c30" },
|
||||||
"nvim-dap": { "branch": "master", "commit": "1fdfe74661170ce58d37dc46259448987ffe706c" },
|
"nvim-dap": { "branch": "master", "commit": "1fdfe74661170ce58d37dc46259448987ffe706c" },
|
||||||
"nvim-dap-ui": { "branch": "master", "commit": "bc81f8d3440aede116f821114547a476b082b319" },
|
"nvim-dap-ui": { "branch": "master", "commit": "bc81f8d3440aede116f821114547a476b082b319" },
|
||||||
"nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" },
|
|
||||||
"nvim-lspconfig": { "branch": "master", "commit": "637293ce23c6a965d2f11dfbf92f604bb1978052" },
|
"nvim-lspconfig": { "branch": "master", "commit": "637293ce23c6a965d2f11dfbf92f604bb1978052" },
|
||||||
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
|
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
|
||||||
"nvim-treesitter": { "branch": "master", "commit": "2206739829518c9ea59dbdb9003e0147fdaf2d1c" },
|
"nvim-treesitter": { "branch": "master", "commit": "2206739829518c9ea59dbdb9003e0147fdaf2d1c" },
|
||||||
|
|||||||
+246
-239
@@ -1,268 +1,275 @@
|
|||||||
return {
|
return {
|
||||||
"mfussenegger/nvim-dap",
|
"mfussenegger/nvim-dap",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"rcarriga/nvim-dap-ui",
|
"rcarriga/nvim-dap-ui",
|
||||||
"nvim-neotest/nvim-nio",
|
"nvim-neotest/nvim-nio",
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
local dap = require("dap")
|
local dap = require("dap")
|
||||||
local dapui = require("dapui")
|
local dapui = require("dapui")
|
||||||
|
|
||||||
dap.defaults.fallback.exception_breakpoints = { "uncaught" }
|
dap.defaults.fallback.exception_breakpoints = { "uncaught" }
|
||||||
|
|
||||||
dapui.setup({
|
dapui.setup({
|
||||||
controls = {
|
controls = {
|
||||||
element = "repl",
|
element = "repl",
|
||||||
enabled = true,
|
enabled = true,
|
||||||
icons = {
|
icons = {
|
||||||
disconnect = "",
|
disconnect = "",
|
||||||
pause = "",
|
pause = "",
|
||||||
play = "",
|
play = "",
|
||||||
run_last = "",
|
run_last = "",
|
||||||
step_back = "",
|
step_back = "",
|
||||||
step_into = "",
|
step_into = "",
|
||||||
step_out = "",
|
step_out = "",
|
||||||
step_over = "",
|
step_over = "",
|
||||||
terminate = "",
|
terminate = "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
element_mappings = {},
|
element_mappings = {},
|
||||||
expand_lines = true,
|
expand_lines = true,
|
||||||
floating = {
|
floating = {
|
||||||
border = "rounded",
|
border = "rounded",
|
||||||
mappings = {
|
mappings = {
|
||||||
close = { "q", "<Esc>" },
|
close = { "q", "<Esc>" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
force_buffers = true,
|
force_buffers = true,
|
||||||
icons = {
|
icons = {
|
||||||
collapsed = "",
|
collapsed = "",
|
||||||
current_frame = "",
|
current_frame = "",
|
||||||
expanded = "",
|
expanded = "",
|
||||||
},
|
},
|
||||||
layouts = {
|
layouts = {
|
||||||
{
|
{
|
||||||
elements = {
|
elements = {
|
||||||
{
|
{
|
||||||
id = "scopes",
|
id = "scopes",
|
||||||
size = 0.25,
|
size = 0.25,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id = "breakpoints",
|
id = "breakpoints",
|
||||||
size = 0.25,
|
size = 0.25,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id = "stacks",
|
id = "stacks",
|
||||||
size = 0.25,
|
size = 0.25,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id = "watches",
|
id = "watches",
|
||||||
size = 0.25,
|
size = 0.25,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
position = "right",
|
position = "right",
|
||||||
size = 50,
|
size = 50,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
elements = {
|
elements = {
|
||||||
{
|
{
|
||||||
id = "repl",
|
id = "repl",
|
||||||
size = 0.5,
|
size = 0.5,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id = "console",
|
id = "console",
|
||||||
size = 0.5,
|
size = 0.5,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
position = "bottom",
|
position = "bottom",
|
||||||
size = 10,
|
size = 10,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mappings = {
|
mappings = {
|
||||||
edit = "e",
|
edit = "e",
|
||||||
expand = { "<CR>", "<2-LeftMouse>" },
|
expand = { "<CR>", "<2-LeftMouse>" },
|
||||||
open = "o",
|
open = "o",
|
||||||
remove = "d",
|
remove = "d",
|
||||||
repl = "r",
|
repl = "r",
|
||||||
toggle = "t",
|
toggle = "t",
|
||||||
},
|
},
|
||||||
render = {
|
render = {
|
||||||
indent = 1,
|
indent = 1,
|
||||||
max_value_lines = 100,
|
max_value_lines = 100,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
for _, adapterType in ipairs({ "node", "chrome", "msedge" }) do
|
for _, adapterType in ipairs({ "node", "chrome", "msedge" }) do
|
||||||
local pwaType = "pwa-" .. adapterType
|
local pwaType = "pwa-" .. adapterType
|
||||||
|
|
||||||
dap.adapters[pwaType] = {
|
dap.adapters[pwaType] = {
|
||||||
type = "server",
|
type = "server",
|
||||||
host = "localhost",
|
host = "localhost",
|
||||||
port = "${port}",
|
port = "${port}",
|
||||||
executable = {
|
executable = {
|
||||||
command = "node",
|
command = "node",
|
||||||
args = {
|
args = {
|
||||||
vim.fn.stdpath("data") .. "/mason/packages/js-debug-adapter/js-debug/src/dapDebugServer.js",
|
vim.fn.stdpath("data") .. "/mason/packages/js-debug-adapter/js-debug/src/dapDebugServer.js",
|
||||||
"${port}",
|
"${port}",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- this allow us to handle launch.json configurations
|
-- this allow us to handle launch.json configurations
|
||||||
-- which specify type as "node" or "chrome" or "msedge"
|
-- which specify type as "node" or "chrome" or "msedge"
|
||||||
dap.adapters[adapterType] = function(cb, config)
|
dap.adapters[adapterType] = function(cb, config)
|
||||||
local nativeAdapter = dap.adapters[pwaType]
|
local nativeAdapter = dap.adapters[pwaType]
|
||||||
|
|
||||||
config.type = pwaType
|
config.type = pwaType
|
||||||
|
|
||||||
if type(nativeAdapter) == "function" then
|
if type(nativeAdapter) == "function" then
|
||||||
nativeAdapter(cb, config)
|
nativeAdapter(cb, config)
|
||||||
else
|
else
|
||||||
cb(nativeAdapter)
|
cb(nativeAdapter)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local enter_launch_url = function()
|
local enter_launch_url = function()
|
||||||
local url = vim.fn.input("URL to launch: ", "http://localhost:")
|
local co = coroutine.running()
|
||||||
vim.cmd('echo ""')
|
return coroutine.create(function()
|
||||||
return url
|
vim.ui.input({ prompt = "Enter URL: ", default = "http://localhost:" }, function(url)
|
||||||
end
|
if url == nil or url == "" then
|
||||||
|
return
|
||||||
|
else
|
||||||
|
coroutine.resume(co, url)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
for _, language in ipairs({ "typescript", "javascript", "typescriptreact", "javascriptreact", "vue" }) do
|
for _, language in ipairs({ "typescript", "javascript", "typescriptreact", "javascriptreact", "vue" }) do
|
||||||
dap.configurations[language] = {
|
dap.configurations[language] = {
|
||||||
{
|
{
|
||||||
type = "pwa-node",
|
type = "pwa-node",
|
||||||
request = "launch",
|
request = "launch",
|
||||||
name = "Launch file using Node.js (nvim-dap)",
|
name = "Launch file using Node.js (nvim-dap)",
|
||||||
program = "${file}",
|
program = "${file}",
|
||||||
cwd = "${workspaceFolder}",
|
cwd = "${workspaceFolder}",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = "pwa-node",
|
type = "pwa-node",
|
||||||
request = "attach",
|
request = "attach",
|
||||||
name = "Attach to process using Node.js (nvim-dap)",
|
name = "Attach to process using Node.js (nvim-dap)",
|
||||||
processId = require("dap.utils").pick_process,
|
processId = require("dap.utils").pick_process,
|
||||||
cwd = "${workspaceFolder}",
|
cwd = "${workspaceFolder}",
|
||||||
},
|
},
|
||||||
-- requires ts-node to be installed globally or locally
|
-- requires ts-node to be installed globally or locally
|
||||||
{
|
{
|
||||||
type = "pwa-node",
|
type = "pwa-node",
|
||||||
request = "launch",
|
request = "launch",
|
||||||
name = "Launch file using Node.js with ts-node/register (nvim-dap)",
|
name = "Launch file using Node.js with ts-node/register (nvim-dap)",
|
||||||
program = "${file}",
|
program = "${file}",
|
||||||
cwd = "${workspaceFolder}",
|
cwd = "${workspaceFolder}",
|
||||||
runtimeArgs = { "-r", "ts-node/register" },
|
runtimeArgs = { "-r", "ts-node/register" },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = "pwa-chrome",
|
type = "pwa-chrome",
|
||||||
request = "launch",
|
request = "launch",
|
||||||
name = "Launch Chrome (nvim-dap)",
|
name = "Launch Chrome (nvim-dap)",
|
||||||
url = enter_launch_url,
|
url = enter_launch_url,
|
||||||
webRoot = "${workspaceFolder}",
|
webRoot = "${workspaceFolder}",
|
||||||
sourceMaps = true,
|
sourceMaps = true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = "pwa-msedge",
|
type = "pwa-msedge",
|
||||||
request = "launch",
|
request = "launch",
|
||||||
name = "Launch Edge (nvim-dap)",
|
name = "Launch Edge (nvim-dap)",
|
||||||
url = enter_launch_url,
|
url = enter_launch_url,
|
||||||
webRoot = "${workspaceFolder}",
|
webRoot = "${workspaceFolder}",
|
||||||
sourceMaps = true,
|
sourceMaps = true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
dap.adapters.coreclr = {
|
dap.adapters.coreclr = {
|
||||||
type = "executable",
|
type = "executable",
|
||||||
command = "C:/Users/sfree/AppData/Local/nvim-data/mason/packages/netcoredbg/netcoredbg/netcoredbg.exe",
|
command = "C:/Users/sfree/AppData/Local/nvim-data/mason/packages/netcoredbg/netcoredbg/netcoredbg.exe",
|
||||||
args = { "--interpreter=vscode" },
|
args = { "--interpreter=vscode" },
|
||||||
}
|
}
|
||||||
|
|
||||||
local dotnet_build_project = function()
|
local dotnet_build_project = function()
|
||||||
local default_path = vim.fn.getcwd() .. "/"
|
local default_path = vim.fn.getcwd() .. "/"
|
||||||
|
|
||||||
if vim.g["dotnet_last_proj_path"] ~= nil then
|
if vim.g["dotnet_last_proj_path"] ~= nil then
|
||||||
default_path = vim.g["dotnet_last_proj_path"]
|
default_path = vim.g["dotnet_last_proj_path"]
|
||||||
end
|
end
|
||||||
|
|
||||||
local path = vim.fn.input("Path to your *proj file", default_path, "file")
|
local path = vim.fn.input("Path to your *proj file", default_path, "file")
|
||||||
|
|
||||||
vim.g["dotnet_last_proj_path"] = path
|
vim.g["dotnet_last_proj_path"] = path
|
||||||
|
|
||||||
local cmd = "dotnet build -c Debug " .. path .. " > /dev/null"
|
local cmd = "dotnet build -c Debug " .. path .. " > /dev/null"
|
||||||
|
|
||||||
print("")
|
print("")
|
||||||
print("Cmd to execute: " .. cmd)
|
print("Cmd to execute: " .. cmd)
|
||||||
|
|
||||||
local f = os.execute(cmd)
|
local f = os.execute(cmd)
|
||||||
|
|
||||||
if f == 0 then
|
if f == 0 then
|
||||||
print("\nBuild: ✔️ ")
|
print("\nBuild: ✔️ ")
|
||||||
else
|
else
|
||||||
print("\nBuild: ❌ (code: " .. f .. ")")
|
print("\nBuild: ❌ (code: " .. f .. ")")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local dotnet_get_dll_path = function()
|
local dotnet_get_dll_path = function()
|
||||||
local request = function()
|
local request = function()
|
||||||
return vim.fn.input("Path to dll to debug: ", vim.fn.getcwd() .. "/bin/Debug/", "file")
|
return vim.fn.input("Path to dll to debug: ", vim.fn.getcwd() .. "/bin/Debug/", "file")
|
||||||
end
|
end
|
||||||
|
|
||||||
if vim.g["dotnet_last_dll_path"] == nil then
|
if vim.g["dotnet_last_dll_path"] == nil then
|
||||||
vim.g["dotnet_last_dll_path"] = request()
|
vim.g["dotnet_last_dll_path"] = request()
|
||||||
else
|
else
|
||||||
if
|
if
|
||||||
vim.fn.confirm("Change the path to dll?\n" .. vim.g["dotnet_last_dll_path"], "&yes\n&no", 2) == 1
|
vim.fn.confirm("Change the path to dll?\n" .. vim.g["dotnet_last_dll_path"], "&yes\n&no", 2) == 1
|
||||||
then
|
then
|
||||||
vim.g["dotnet_last_dll_path"] = request()
|
vim.g["dotnet_last_dll_path"] = request()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return vim.g["dotnet_last_dll_path"]
|
return vim.g["dotnet_last_dll_path"]
|
||||||
end
|
end
|
||||||
|
|
||||||
dap.configurations.cs = {
|
dap.configurations.cs = {
|
||||||
{
|
{
|
||||||
type = "coreclr",
|
type = "coreclr",
|
||||||
name = "Launch - coreclr (nvim-dap)",
|
name = "Launch - coreclr (nvim-dap)",
|
||||||
request = "launch",
|
request = "launch",
|
||||||
program = function()
|
program = function()
|
||||||
if vim.fn.confirm("Rebuild first?", "&yes\n&no", 2) == 1 then
|
if vim.fn.confirm("Rebuild first?", "&yes\n&no", 2) == 1 then
|
||||||
dotnet_build_project()
|
dotnet_build_project()
|
||||||
end
|
end
|
||||||
|
|
||||||
return dotnet_get_dll_path()
|
return dotnet_get_dll_path()
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
dap.listeners.before.attach.dapui_config = function()
|
dap.listeners.before.attach.dapui_config = function()
|
||||||
dapui.open()
|
dapui.open()
|
||||||
end
|
end
|
||||||
dap.listeners.before.launch.dapui_config = function()
|
dap.listeners.before.launch.dapui_config = function()
|
||||||
dapui.open()
|
dapui.open()
|
||||||
end
|
end
|
||||||
dap.listeners.before.event_terminated.dapui_config = function()
|
dap.listeners.before.event_terminated.dapui_config = function()
|
||||||
dapui.close()
|
dapui.close()
|
||||||
end
|
end
|
||||||
dap.listeners.before.event_exited.dapui_config = function()
|
dap.listeners.before.event_exited.dapui_config = function()
|
||||||
dapui.close()
|
dapui.close()
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.keymap.set("n", "<Leader>dt", dap.toggle_breakpoint, { desc = "Toggle breakpoint" })
|
vim.keymap.set("n", "<Leader>dt", dap.toggle_breakpoint, { desc = "Toggle breakpoint" })
|
||||||
vim.keymap.set("n", "<Leader>dbc", dap.clear_breakpoints, { desc = "Clear all breakpoints" })
|
vim.keymap.set("n", "<Leader>dbc", dap.clear_breakpoints, { desc = "Clear all breakpoints" })
|
||||||
vim.keymap.set("n", "<Leader>dbl", dap.list_breakpoints, { desc = "Clear all breakpoints" })
|
vim.keymap.set("n", "<Leader>dbl", dap.list_breakpoints, { desc = "Clear all breakpoints" })
|
||||||
|
|
||||||
local continue = function()
|
local continue = function()
|
||||||
-- support for vscode launch.json is partial.
|
-- support for vscode launch.json is partial.
|
||||||
-- not all configuration options and features supported
|
-- not all configuration options and features supported
|
||||||
if vim.fn.filereadable(".vscode/launch.json") then
|
if vim.fn.filereadable(".vscode/launch.json") then
|
||||||
require("dap.ext.vscode").load_launchjs()
|
require("dap.ext.vscode").load_launchjs()
|
||||||
end
|
end
|
||||||
dap.continue()
|
dap.continue()
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.keymap.set("n", "<Leader>dc", continue, { desc = "Continue" })
|
vim.keymap.set("n", "<Leader>dc", continue, { desc = "Continue" })
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user