Skip to content

Commit

Permalink
Include source for custom widgets we're reimplementing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian committed Sep 4, 2024
1 parent 45a3a5b commit b829054
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 10 additions & 1 deletion lua/lean/infoview/components.lua
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,16 @@ function components.user_widgets_at(bufnr, params, sess, use_widgets)
elseif sess == nil then
sess = require('lean.rpc').open(bufnr, params)
end
return widgets.render_response(sess:getWidgets(params.position))
return widgets.render_response(
---@param widget UserWidget
sess:getWidgets(params.position),
function(widget)
return sess:getWidgetSource({
pos = params.position,
hash = widget.javascriptHash,
}).sourcetext
end
)
end

return components
11 changes: 8 additions & 3 deletions lua/lean/widgets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ end
--- @return Widget
function Widget.unsupported(id)
return Widget:new {
element = function()
element = function(_, props)
local message = dedent [[
%q is not a supported Lean widget type.
If you think it could be, please file an issue with lean.nvim!
Props: %s
]]
vim.notify_once(message:format(id), vim.log.levels.DEBUG)
vim.notify_once(message:format(id, vim.inspect(props)), vim.log.levels.DEBUG)
end,
}
end
Expand Down Expand Up @@ -97,8 +100,10 @@ return {

---Render the given response to one or more TUI elements.
---@param response? UserWidgets
---@param source_of function(widget: UserWidget): string
---@return Element[]? elements
render_response = function(response)
---@diagnostic disable-next-line: unused-local
render_response = function(response, source_of)
if response then
---@param each UserWidgetInstance
return vim
Expand Down

0 comments on commit b829054

Please sign in to comment.