Skip to content
Open
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
1 change: 1 addition & 0 deletions lua/lean/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
---@class lean.infoview.Config
---@field mappings? { [string]: ElementEvent }
---@field orientation? "auto"|"vertical"|"horizontal" what orientation to use for opened infoviews
---@field keep_stale_goal? boolean preserve the last goal state while Lean is processing instead of clearing it
---@field view_options? InfoviewViewOptions
---@field severity_markers? table<lsp.DiagnosticSeverity, string> characters to use for denoting diagnostic severity

Expand Down
40 changes: 37 additions & 3 deletions lua/lean/infoview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ local options = {
autopause = false,
indicators = 'auto',
show_processing = true,
keep_stale_goal = true,
show_no_info_message = false,
show_term_goals = true,
use_widgets = true,
Expand Down Expand Up @@ -885,6 +886,7 @@ function Pin:new(obj)
vim.tbl_extend('keep', obj, {
paused = paused,
__data_element = Element.EMPTY,
__data_element_uri = nil,
__element = Element:new { name = 'pin' },
__info = obj.parent,
__tick = 0,
Expand Down Expand Up @@ -1084,10 +1086,13 @@ end
---
---@param params lsp.TextDocumentPositionParams
---@param use_widgets boolean
---@return Element
---@return Element?
local function contents_for(params, use_widgets)
local processing = progress.at(params)
if processing == progress.Kind.processing then
if options.keep_stale_goal then
return nil
end
-- When Lean is processing, diagnostics indicate what's building,
-- but those diagnostics show up at the top of the file.
--
Expand Down Expand Up @@ -1135,7 +1140,7 @@ local function contents_for(params, use_widgets)
elseif options.show_no_info_message then
return components.NO_INFO
else
return components.EMPTY
return Element.EMPTY
end
end

Expand Down Expand Up @@ -1192,7 +1197,36 @@ Pin.update = a.void(function(self)
self.loading = true
self.__info:render()
end
self.__data_element = contents_for(self.__position_params, self.__use_widgets)
local current_uri = self.__position_params.textDocument.uri
local new_element = contents_for(self.__position_params, self.__use_widgets)
if new_element == nil then
local has_stale = self.__data_element ~= Element.EMPTY
and self.__data_element ~= components.NO_INFO
and self.__data_element ~= components.PROCESSING
and self.__data_element_uri == current_uri
if has_stale then
-- Preserve stale goal, indicate staleness visually.
if self.__info.__infoview.window then
self.__info.__infoview.window.o.winhighlight = 'NormalNC:leanInfoProcessing'
end
if self.__tick == tick and self.__info and self.loading then
self.loading = false
self.__info:render()
end
else
-- No stale state for this file, show "Processing file..." but keep
-- loading so that wait_for_loading_pins continues to wait for real content.
self.__data_element = components.PROCESSING
self.__data_element_uri = current_uri
self.__element:set_children { self.__data_element }
if self.__tick == tick and self.__info then
self.__info:render()
end
end
return
end
self.__data_element = new_element
self.__data_element_uri = current_uri
-- FIXME: we don't have the right separation here for knowing when we're dead
if self.__data_element == components.LSP_HAS_DIED then
self.__info.__infoview.window.o.winhighlight = 'NormalNC:leanInfoLSPDead'
Expand Down
1 change: 1 addition & 0 deletions lua/lean/stderr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ local function open_window(stderr_buffer)

local stderr_window = Window:current()
stderr_window:set_height(stderr_height)
stderr_window.o.winhighlight = 'NormalNC:Normal'
stderr_buffer.o.filetype = 'leanstderr'
initial_window:make_current()
return stderr_window
Expand Down
4 changes: 0 additions & 4 deletions spec/infoview/contents_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,6 @@ describe('interactive infoview', function()
⊢ 𝔽 = 𝔽
]]

helpers.move_cursor { to = { 1, 44 } }
assert.infoview_contents.are [[
]]

helpers.move_cursor { to = { 1, 46 } }
assert.infoview_contents.are [[
▼ expected type (1:40-1:43)
Expand Down
4 changes: 0 additions & 4 deletions spec/infoview/plain_contents_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,6 @@ describe('plain infoviews', function()
⊢ 𝔽 = 𝔽
]]

helpers.move_cursor { to = { 1, 44 } }
assert.infoview_contents.are [[
]]

helpers.move_cursor { to = { 1, 46 } }
assert.infoview_contents.are [[
▼ expected type (1:40-1:43)
Expand Down
1 change: 1 addition & 0 deletions spec/std/nvim/window_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ describe('Window', function()
border = config.border,
focusable = config.focusable,
mouse = config.mouse,
style = config.style,
zindex = config.zindex,
}, config)
float:close()
Expand Down
1 change: 1 addition & 0 deletions spec/widgets/core_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ describe('Lean core widgets', function()
]]

infoview.go_to()
vim.api.nvim_win_set_cursor(0, { 1, 0 })
helpers.search 'apply] '
helpers.feed '<CR>'

Expand Down
1 change: 1 addition & 0 deletions syntax/leaninfo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ vim.api.nvim_set_hl(0, 'leanInfoExpectedType', { default = true, link = 'Special
vim.api.nvim_set_hl(0, 'leanInfoNCWarn', { default = true, link = 'Folded' })
vim.api.nvim_set_hl(0, 'leanInfoNCError', { default = true, link = 'NormalFloat' })
vim.api.nvim_set_hl(0, 'leanInfoPaused', { default = true, link = 'leanInfoNCWarn' })
vim.api.nvim_set_hl(0, 'leanInfoProcessing', { default = true, link = 'leanInfoNCWarn' })
vim.api.nvim_set_hl(0, 'leanInfoLSPDead', { default = true, link = 'leanInfoNCError' })

-- Diagnostics
Expand Down
Loading