updates for dapui

pull/46/head
ray-x 3 years ago
parent 1b11f52b08
commit 4611c34548

@ -30,18 +30,6 @@ _GO_NVIM_CFG = {
}
local dap_config = function()
vim.fn.sign_define('DapBreakpoint', {
text = _GO_NVIM_CFG.icons.breakpoint,
texthl = '',
linehl = '',
numhl = ''
})
vim.fn.sign_define('DapStopped', {
text = _GO_NVIM_CFG.icons.currentpos,
texthl = '',
linehl = '',
numhl = ''
})
vim.cmd([[command! BreakCondition lua require"dap".set_breakpoint(vim.fn.input("Breakpoint condition: "))]])
vim.cmd([[command! ReplRun lua require"dap".repl.run_last()]])
@ -50,7 +38,6 @@ local dap_config = function()
vim.cmd([[command! DapRerun lua require'dap'.disconnect();require'dap'.close();require'dap'.run_last()]])
vim.cmd([[command! DapStop lua require'go.dap'.stop()]])
vim.g.dap_virtual_text = true
end
function go.setup(cfg)
@ -126,7 +113,8 @@ function go.setup(cfg)
if _GO_NVIM_CFG.dap_debug then
dap_config()
vim.cmd([[command! -nargs=* GoDebug lua require"go.dap".run(<f-args>)]])
vim.cmd(
[[command! -nargs=* -complete=custom,v:lua.package.loaded.go.dbg_complete GoDebug lua require"go.dap".run(<f-args>)]])
vim.cmd([[command! GoBreakToggle lua require"go.dap".breakpt()]])
vim.cmd([[command! BreakCondition lua require"dap".set_breakpoint(vim.fn.input("Breakpoint condition: "))]])
@ -134,6 +122,8 @@ function go.setup(cfg)
vim.cmd([[command! ReplToggle lua require"dap".repl.toggle()]])
vim.cmd([[command! ReplOpen lua require"dap".repl.open(), 'split']])
vim.cmd([[command! DapRerun lua require'dap'.disconnect();require'dap'.close();require'dap'.run_last()]])
vim.cmd([[command! DapUiFloat lua require("dapui").float_element()]])
vim.cmd([[command! DapUiToggle lua require("dapui").toggle()]])
vim.cmd([[command! GoDbgStop lua require'go.dap'.stop()]])
@ -169,4 +159,10 @@ go.set_test_runner = function(runner)
end
print("runner not supported " .. runner)
end
go.dbg_complete = function(arglead, cmdline, cursorpos)
-- richgo, go test, richgo, dlv, ginkgo
local testopts = {"test", "nearest", "file", "stop"}
return table.concat(testopts, '\n')
end
return go

@ -90,9 +90,11 @@ M.run = function(...)
keybind()
M.prepare()
local args = {...}
local mode = select(1, ...)
if mode == 'stop' then
return require"go.dap".stop()
end
log("plugin loaded", mode)
if _GO_NVIM_CFG.dap_debug_gui then
require("dapui").setup()

@ -211,12 +211,15 @@ M.test_file = function(...)
-- require sed
-- local testcases = [[sed -n 's/func.*\(Test.*\)(.*/\1/p' | xargs | sed 's/ /\\\|/g']]
utils.log(args)
local fname = vim.fn.expand('%:p')
local cmd = [[cat ]] .. fname .. [[| sed -n 's/func.*\(Test.*\)(.*/\1/p' | xargs | sed 's/ /\\\|/g']]
local cmd = [[cat ]] .. vim.fn.expand('%:p') .. [[| sed -n 's/func.*\(Test.*\)(.*/\1/p' | xargs | sed 's/ /\\\|/g']]
-- TODO maybe with treesitter or lsp list all functions in current file and regex with Test
local tests = vim.fn.systemlist(cmd)[1]
-- local fpath = './' .. vim.fn.expand('%:h') .. '/...'
utils.log(tests)
if tests == nil or tests == {} then
print('no test found fallback to package test')
M.test_package(...)
end
local tags, args2 = get_build_tags(args)
local argsstr = ""

Loading…
Cancel
Save