diff --git a/doc/nvim-dap-ui.txt b/doc/nvim-dap-ui.txt index be9e906..ec9b7e5 100644 --- a/doc/nvim-dap-ui.txt +++ b/doc/nvim-dap-ui.txt @@ -331,7 +331,7 @@ render order of variables. *dapui.Action* Alias~ -`dapui.Action` → `"expand"|"open"|"remove"|"edit"|"repl"|"toggle"` +`dapui.Action` → `"expand"|"open"|"remove"|"edit"|"repl"|"toggle"|"watch"` *dapui.FloatingAction* Alias~ @@ -347,6 +347,7 @@ Mappings: - `edit`: Edit the value of a variable - `expand`: Toggle showing any children of variable. - `repl`: Send variable to REPL +- `watch`: Send variable to watches ============================================================================== diff --git a/lua/dapui/components/variables.lua b/lua/dapui/components/variables.lua index 8095f7f..c701841 100644 --- a/lua/dapui/components/variables.lua +++ b/lua/dapui/components/variables.lua @@ -80,6 +80,7 @@ return function(client, send_ready) end) if variable.evaluateName then canvas:add_mapping("repl", partial(util.send_to_repl, variable.evaluateName)) + canvas:add_mapping("watch", partial(util.send_to_watches, variable.evaluateName)) end end canvas:add_mapping("edit", function() diff --git a/lua/dapui/config/init.lua b/lua/dapui/config/init.lua index 73a1a51..cf819b9 100644 --- a/lua/dapui/config/init.lua +++ b/lua/dapui/config/init.lua @@ -70,7 +70,7 @@ local dapui = {} ---@field sort_variables? fun(a: dapui.types.Variable, b: dapui.types.Variable):boolean Sorting function to determine --- render order of variables. ----@alias dapui.Action "expand"|"open"|"remove"|"edit"|"repl"|"toggle" +---@alias dapui.Action "expand"|"open"|"remove"|"edit"|"repl"|"toggle"|"watch" ---@alias dapui.FloatingAction "close" @@ -86,6 +86,7 @@ local default_config = { edit = "e", repl = "r", toggle = "t", + watch = "w", }, element_mappings = {}, expand_lines = vim.fn.has("nvim-0.7") == 1, diff --git a/lua/dapui/render/canvas.lua b/lua/dapui/render/canvas.lua index 7ef0e09..cfe619d 100644 --- a/lua/dapui/render/canvas.lua +++ b/lua/dapui/render/canvas.lua @@ -16,7 +16,7 @@ M.namespace = api.nvim_create_namespace("dapui") local Canvas = {} ---@type dapui.Action[] -local all_actions = { "expand", "open", "remove", "edit", "repl", "toggle" } +local all_actions = { "expand", "open", "remove", "edit", "repl", "toggle", "watch" } ---@return dapui.Canvas function Canvas:new() diff --git a/lua/dapui/util.lua b/lua/dapui/util.lua index b08b6c7..b515892 100644 --- a/lua/dapui/util.lua +++ b/lua/dapui/util.lua @@ -264,6 +264,10 @@ function M.send_to_repl(expression) vim.cmd("normal i" .. expression) end +function M.send_to_watches(expression) + require('dapui').elements.watches.add(expression) +end + function M.float_element(elem_name) local line_no = vim.fn.screenrow() local col_no = vim.fn.screencol()