From edda37cb5ed07ff5586972e8eada263b987140d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Brelih?= Date: Sat, 2 Jul 2022 04:33:20 +0200 Subject: [PATCH 1/2] Cmd is tranformed to string before pushed to term (#151) * Cmd is tranformed to string before pushed to term Float terminal command is tranformed to string using table.concat before used. This allow us to use neovim buff option to unite quoting. * Update term.lua Co-authored-by: Ales Brelih Co-authored-by: rayx --- lua/go/term.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/go/term.lua b/lua/go/term.lua index 72980d3..10509f9 100644 --- a/lua/go/term.lua +++ b/lua/go/term.lua @@ -48,10 +48,16 @@ local term = function(opts) if opts.autoclose == nil then opts.autoclose = true end + -- run in neovim shell + if type(opts.cmd) == "table" then + opts.cmd = table.concat(opts.cmd, " ") + end + + utils.log(opts) local buf, win, closer = guihua_term.floating_term(opts) api.nvim_command("setlocal nobuflisted") api.nvim_buf_set_var(cur_buf, "go_float_terminal_win", { buf, win }) - + api.nvim_buf_set_var(cur_buf, "shellcmdflag", "shell-unquoting") return buf, win, closer end From a2d0bbee53a9a1fc1d1e98b57219f8c0f2fc617a Mon Sep 17 00:00:00 2001 From: ray-x Date: Sun, 3 Jul 2022 09:11:26 +1000 Subject: [PATCH 2/2] bugfix #153, update doc --- README.md | 3 +++ doc/go.txt | 7 +++++++ lua/go.lua | 3 ++- lua/go/dap.lua | 28 ++++++++++++++++++++++++++-- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 65b87c7..b706d2d 100644 --- a/README.md +++ b/README.md @@ -360,6 +360,8 @@ or simply put your cursor in a struct and do | GoDebug -s | stop debug session and unmap debug keymap | | GoDbgKeys | show debug keymaps in a floating window (guihua) | | GoBreakToggle | GoDebug -b | +| GoDbgStop | Same as GoDebug -s | +| GoDbgContinue | Continue debug session | | BreakCondition | conditional break | Notes: @@ -573,6 +575,7 @@ require('go').setup({ dap_debug = true, -- set to false to disable dap dap_debug_keymap = true, -- true: use keymap for debugger defined in go/dap.lua -- false: do not use keymap in go/dap.lua. you must define your own. + -- windows: use visual studio keymap dap_debug_gui = true, -- set to true to enable dap gui, highly recommand dap_debug_vt = true, -- set to true to enable dap virtual text build_tags = "tag1,tag2", -- set default build tags diff --git a/doc/go.txt b/doc/go.txt index 925b587..cf3c6b3 100644 --- a/doc/go.txt +++ b/doc/go.txt @@ -269,6 +269,12 @@ COMMANDS *go-nvim-commands* :GoDbgKeys *:GoDbgKeys* Display keymaps for debuger +:GoDbgStop *:GoDbgStop* + Stop debug session and unmap all keymaps, same as GoDebug -s + +:GoDbgContinue *:GoDbgStop* + Continue debug session, keymap `c` + :GoCreateLaunch *:GoCreateLaunch* Create alaunch.json @@ -338,6 +344,7 @@ You can setup go.nvim with following options: dap_debug_gui = true, dap_debug_keymap = true, -- true: use keymap for debugger defined in go/dap.lua -- false: do not use keymap in go/dap.lua. you must define your own. + -- windows: use visual studio style of keymap dap_vt = true, -- false, true and 'all frames' textobjects = true, gopls_cmd = nil, --- you can provide gopls path and cmd if it not in PATH, e.g. cmd = { "/home/ray/.local/nvim/data/lspinstall/go/gopls" } diff --git a/lua/go.lua b/lua/go.lua index 94ac7f0..139e84b 100644 --- a/lua/go.lua +++ b/lua/go.lua @@ -229,7 +229,8 @@ function go.setup(cfg) 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()]]) + vim.cmd([[command! GoDbgStop lua require'go.dap'.stop(true)]]) + vim.cmd([[command! GoDbgContinue lua require'dap'.continue()]]) end require("go.project").load_project() diff --git a/lua/go/dap.lua b/lua/go/dap.lua index ca0ba50..0879bbf 100644 --- a/lua/go/dap.lua +++ b/lua/go/dap.lua @@ -68,6 +68,21 @@ local function keybind() ["n|P"] = 'lua require"dap".pause()', -- } + if _GO_NVIM_CFG.dap_debug_keymap == "windows" then + keys = { + -- DAP -- + -- run + + ["n|"] = 'lua require"dap".toggle_breakpoint()', + ["n|"] = 'lua require"dap".continue()', + ["n|"] = 'lua require"dap".step_over()', + ["n|"] = 'lua require"dap".run_to_cursor()', + ["n|"] = 'lua require"dap".step_into()', + ["n|"] = 'lua require"dap".step_out()', + ["n|"] = 'lua require"go.dap".stop()', + -- + } + end if _GO_NVIM_CFG.dap_debug_gui then keys["n|p"] = 'lua require("dapui").eval()' keys["v|p"] = 'lua require("dapui").eval()' @@ -99,7 +114,6 @@ local M = {} function M.debug_keys() local keymap_help = {} for key, val in pairs(keys) do - local m = vim.fn.matchlist(val, [[\v(\p+)\.(\p+\(\p*\))]]) -- match last function e.g.float_element("repl") table.insert(keymap_help, key .. " -> " .. m[3]) @@ -119,7 +133,6 @@ function M.debug_keys() }) end - local close_events = { "CursorMoved", "CursorMovedI", "BufHidden", "InsertCharPre" } local config = { close_events = close_events, focusable = true, border = "single" } vim.lsp.util.open_floating_preview(keymap_help, "lua", config) @@ -529,6 +542,17 @@ local unmap = function() "a", "w", } + if _GO_NVIM_CFG.dap_debug_keymap == "windows" then + keys = { + "", + "", + "", + "", + "", + "", + "", + } + end for _, value in pairs(keys) do local cmd = "silent! unmap " .. value vim.cmd(cmd)