Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lua/dap/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ local if_nil = utils.if_nil
local M = {}


---@param win integer
---@param opts table<string, any>?
function M.apply_winopts(win, opts)
if not opts then return end
if not opts then
return
end
assert(
type(opts) == 'table',
'winopts must be a table, not ' .. type(opts) .. ': ' .. vim.inspect(opts)
Expand Down
8 changes: 7 additions & 1 deletion lua/dap/ui/widgets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,8 @@ function M.builder(widget)
end


---@param expr nil|string|fun():string
---@return string
local function eval_expression(expr)
local mode = api.nvim_get_mode()
if mode.mode == 'v' then
Expand Down Expand Up @@ -544,12 +546,14 @@ local function eval_expression(expr)
expr = expr or '<cexpr>'
if type(expr) == "function" then
return expr()
elseif type(expr) == "string" then
else
return vim.fn.expand(expr)
end
end


---@param expr nil|string|fun():string
---@param winopts table<string, any>?
function M.hover(expr, winopts)
local value = eval_expression(expr)
local view = M.builder(M.expression)
Expand Down Expand Up @@ -582,6 +586,7 @@ end

--- View the value of the expression under the cursor in a preview window
---
---@param expr nil|string|fun():string
---@param opts? {listener?: string[]}
function M.preview(expr, opts)
opts = opts or {}
Expand Down Expand Up @@ -623,6 +628,7 @@ function M.preview(expr, opts)
.new_win(new_preview_win)
.build()
view.open(value)
view.__expression = value
return view
end

Expand Down