rcarriga / nvim-dap-ui

A UI for nvim-dap
MIT License
2.63k stars 96 forks source link

[Question] Anything like <Plug>VimspectorBalloonEval #254

Open ioperations opened 1 year ago

ioperations commented 1 year ago

vimspector allow mouse hover to popup variable value , is there any thing like this or can it be implemented ?

rcarriga commented 1 year ago

As vimspector states, it uses the balloons feature of Vim which Neovim doesn't have so no mouse hover cannot be implemented.

https://github.com/puremourning/vimspector#neovim-differences

ioperations commented 1 year ago

actually there do have a snippet , but i cannot locate mouse position and pass the right expression to dapui,


local hover_time = 500
local hover_timer = nil
vim.o.mousemoveevent = true

local mousemove_str = vim.api.nvim_replace_termcodes("<MouseMove>", false, false, true)
local dap = require "dap"
local dapui = require "dapui"

 vim.on_key(function(str)
     if str == mousemove_str then
         if hover_timer then
             hover_timer:close()
         end
         hover_timer = vim.defer_fn(function()
             hover_timer = nil
             if dap.session() ~= nil then
             --  print("looping " .. vim.loop.now())
             --  pop()
                  dapui.eval()
             end
         end, hover_time)
     end
 end)

and there do have other issue, (when moving the mouse to float window that dapui managed, no new float window should be produced)

popup function that may reminds you ```lua local function pop() local expr local args local async = require "dapui.async" local dapui = require "dapui" local util = require "dapui.util" async.run(function() if not dap.session() then return end args = args or {} if not expr then expr = util.get_current_expr() end if open_float then if prev_expr == expr then open_float:jump_to() return else open_float:close() end end prev_expr = expr local elem = dapui.elements.hover elem.set_expression(expr, args.context) local v = vim.fn.getmousepos() local line_no = v.line local col_no = v.column local position = { line = line_no, col = col_no } open_float = require("dapui.windows").open_float("hover", elem, position, args) if open_float then open_float:listen("close", function() open_float = nil end) end end) end ```