Skip to content

Commit 3a9f161

Browse files
committed
Automatically enable inlay hints in Lean buffers.
leanprover/lean4#6768 is now merged (hooray!) and means that Lean shows useful information like the use of auto-implicits via inlay hints. This functionality is already available on Lean4 HEAD, and will shortly be available in nightlies (and then in a release candidate). Note that Neovim does not enable them by default, but this is mostly because exactly what is shown in inlay hints varies widely by language -- and here, it seems more reasonable that they be enabled by default in Lean. We do so only buffer-locally, and users can opt out of this by setting `enabled = false` in the new `inlay_hint` config table. (This also shouldn't interfere if any user is calling `vim.lsp.inlay_hint.enable()` themselves already).
1 parent e9d9a35 commit 3a9f161

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

ftplugin/lean/lean.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,8 @@ if config.mappings == true then
3737
require('lean').use_suggested_mappings(0)
3838
end
3939

40+
if config.inlay_hint.enabled then
41+
vim.lsp.inlay_hint.enable(true, { bufnr = 0 })
42+
end
43+
4044
vim.bo.modifiable = config.ft:should_modify()

lua/lean/config.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
---@field ft? lean.ft.Config filetype configuration
1212
---@field abbreviations? lean.abbreviations.Config abbreviaton configuration
1313
---@field infoview? lean.infoview.Config infoview configuration
14+
---@field inlay_hint? lean.inlay_hint.Config inlay hint configuration
1415
---@field lsp? table language server configuration
1516
---@field progress_bars? table progress bar configuration
1617
---@field stderr? table stderr window configuration
@@ -21,6 +22,7 @@
2122

2223
---@class lean.MergedConfig: lean.Config
2324
---@field ft lean.ft.MergedConfig filetype configuration
25+
---@field inlay_hint lean.inlay_hint.Config inlay hint configuration
2426
---@field log Log log any messages from lean.nvim's internals
2527

2628
---@class lean.abbreviations.Config
@@ -38,6 +40,14 @@
3840
---@field view_options? InfoviewViewOptions
3941
---@field severity_markers? table<lsp.DiagnosticSeverity, string> characters to use for denoting diagnostic severity
4042

43+
---Lean uses inlay hints to surface things like auto-implicits of a function.
44+
---
45+
---We enable them by default in Lean buffers, but they can be disabled if
46+
---desired below. Note that they are not enabled globally in Neovim by default
47+
---(as what exactly is shown in inlay hints can vary widely by language).
48+
---@class lean.inlay_hint.Config
49+
---@field enabled? boolean whether to automatically enable inlay hints
50+
4151
---@type lean.MergedConfig
4252
local DEFAULTS = {
4353
mappings = false,
@@ -89,6 +99,9 @@ local DEFAULTS = {
8999
'hint:\n',
90100
},
91101
},
102+
103+
---@type lean.inlay_hint.Config
104+
inlay_hint = { enabled = true },
92105
}
93106

94107
---Load our merged configuration merging user configuration with any defaults.

0 commit comments

Comments
 (0)