Skip to content

Commit

Permalink
DRY up the arguments to some infoview components.
Browse files Browse the repository at this point in the history
There's no need to pass URI twice, it's in the params.
  • Loading branch information
Julian committed Oct 9, 2024
1 parent 545432d commit 8adb90d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
8 changes: 4 additions & 4 deletions lua/lean/infoview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1090,10 +1090,10 @@ function Pin:__mk_data_elem(tick, opts)
local sess = rpc.open(uri, params)
local blocks = vim
.iter({
components.goal_at(uri, params, sess, self.__use_widgets) or {},
components.term_goal_at(uri, params, sess, self.__use_widgets) or {},
components.diagnostics_at(uri, params, sess, self.__use_widgets) or {},
components.user_widgets_at(uri, params, sess, self.__use_widgets) or {},
components.goal_at(params, sess, self.__use_widgets) or {},
components.term_goal_at(params, sess, self.__use_widgets) or {},
components.diagnostics_at(params, sess, self.__use_widgets) or {},
components.user_widgets_at(params, sess, self.__use_widgets) or {},
})
:flatten()
:totable()
Expand Down
23 changes: 11 additions & 12 deletions lua/lean/infoview/components.lua
Original file line number Diff line number Diff line change
Expand Up @@ -551,13 +551,14 @@ function components.interactive_diagnostics(diags, line, sess)
:totable()
end

---@param uri string
---@param params lsp.TextDocumentPositionParams
---@param sess? Subsession
---@param use_widgets? boolean
---@return Element[] goal
---@return LspError? error
function components.goal_at(uri, params, sess, use_widgets)
function components.goal_at(params, sess, use_widgets)
local uri = params.textDocument.uri

local goal, err
if use_widgets ~= false then
if sess == nil then
Expand All @@ -576,13 +577,14 @@ function components.goal_at(uri, params, sess, use_widgets)
return goal, err
end

---@param uri string
---@param params lsp.TextDocumentPositionParams
---@param sess? Subsession
---@param use_widgets? boolean
---@return Element[]
---@return LspError?
function components.term_goal_at(uri, params, sess, use_widgets)
function components.term_goal_at(params, sess, use_widgets)
local uri = params.textDocument.uri

local term_goal, err
if use_widgets ~= false then
if sess == nil then
Expand All @@ -601,13 +603,13 @@ function components.term_goal_at(uri, params, sess, use_widgets)
return term_goal, err
end

---@param uri string
---@param params lsp.TextDocumentPositionParams
---@param sess? Subsession
---@param use_widgets? boolean
---@return Element[]
---@return LspError?
function components.diagnostics_at(uri, params, sess, use_widgets)
function components.diagnostics_at(params, sess, use_widgets)
local uri = params.textDocument.uri
local line = params.position.line

if use_widgets == false then
Expand Down Expand Up @@ -642,17 +644,14 @@ function components.diagnostics_at(uri, params, sess, use_widgets)
return components.interactive_diagnostics(diagnostics, line, sess), err
end

---@param uri string
---@param params lsp.TextDocumentPositionParams
---@param sess? Subsession
---@param use_widgets? boolean
---@return Element[]? widgets
---@return LspError? error
function components.user_widgets_at(uri, params, sess, use_widgets)
-- REMOVEME: This validity check in a bunch of places is us seemingly
-- calculating components for a buffer that is gone.
-- We need to figure out where we're doing that and not doing it.
-- Possibly it's all related to us not detaching "pin" updating.
function components.user_widgets_at(params, sess, use_widgets)
local uri = params.textDocument.uri

if not use_widgets then
return {}
elseif sess == nil then
Expand Down

0 comments on commit 8adb90d

Please sign in to comment.