check dap module before disconnect dap

pull/77/head
ray-x 2 years ago
parent cad485661b
commit 22fe0379de

@ -95,6 +95,13 @@ M.run = function(...)
local mode = select(1, ...)
local ctl_opt = select(2, ...)
local guihua = utils.load_plugin("guihua.lua", "guihua.gui")
local original_select = vim.ui.select
if guihua then
vim.ui.select = require("guihua.gui").select
end
-- testopts = {"test", "nearest", "file", "stop", "restart"}
log("plugin loaded", mode, ctl_opt)
if mode == "stop" or ctl_opt == "stop" then
@ -215,6 +222,8 @@ M.run = function(...)
dap.continue()
end
log(args)
vim.ui.select = original_select
end
local unmap = function()
@ -253,10 +262,13 @@ M.stop = function(unm)
if unm then
unmap()
end
require("dap").disconnect()
require("dap").close()
require("dap").repl.close()
local has_dap, dap = pcall(require, "dap")
if has_dap then
require("dap").disconnect()
require("dap").close()
require("dap").repl.close()
end
local has_dapui, dapui = pcall(require, "dapui")
if has_dapui then
dapui.close()

@ -58,9 +58,12 @@ local launch_json_content = [[
local util = require("go.utils")
local log = util.log
local M = {}
local sep = require("go.utils").sep()
function M.vs_launch()
local launch_json = _GO_NVIM_CFG.launch_json or (vim.fn.getcwd() .. "/.vscode/launch.json")
local workfolder = vim.lsp.buf.list_workspace_folders()[1] or vim.fn.getcwd()
local launch_json = _GO_NVIM_CFG.launch_json or (workfolder .. sep .. ".vscode" .. sep .. "launch.json")
log(launch_json)
if vim.fn.filereadable(launch_json) == 1 then
return true, launch_json
@ -70,7 +73,8 @@ function M.vs_launch()
end
function M.config()
local launch_json = _GO_NVIM_CFG.launch_json or (vim.fn.getcwd() .. "/.vscode/launch.json")
local workfolder = vim.lsp.buf.list_workspace_folders()[1] or vim.fn.getcwd()
local launch_json = _GO_NVIM_CFG.launch_json or (workfolder .. sep .. ".vscode" .. sep .. "launch.json")
local cmd = "e " .. launch_json
if vim.fn.filereadable(launch_json) == 1 then

Loading…
Cancel
Save