Skip to content

Commit

Permalink
Also check for supported neovim version in the health check.
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian committed Aug 29, 2024
1 parent 881eeef commit 4b8187b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
34 changes: 25 additions & 9 deletions lua/lean/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,32 @@

local subprocess_check_output = require('lean._util').subprocess_check_output

local function check_lean_runnable()
local lean = subprocess_check_output { command = 'lean', args = { '--version' } }
vim.health.ok '`lean --version`'
vim.health.info(table.concat(lean, '\n'))
local MIN_SUPPORTED_NVIM = '0.10'

local function neovim_is_new_enough()
local version = vim.version()
if vim.version.lt(vim.version(), MIN_SUPPORTED_NVIM) then
local message = 'Neovim %s is too old. %s is the earliest supported version.'
vim.health.error(message:format(version, MIN_SUPPORTED_NVIM))
else
vim.health.ok 'Neovim is new enough.'
end
end

local function lake_is_runnable()
local output = subprocess_check_output {
command = 'lake',
args = { '--version' },
}
vim.health.ok 'Lake is runnable.'
vim.health.info('`lake --version`:\n ' .. table.concat(output, ' \n'))
end

local function check_for_timers()
local function no_timers()
if not vim.tbl_isempty(vim.fn.timer_info()) then
vim.health.warn(
'You have active timers, which can degrade infoview (CursorMoved) '
.. 'performance. See https://github.com/Julian/lean.nvim/issues/92.'
'You have active timers, which can degrade infoview (CursorMoved) performance.',
{ 'See https://github.com/Julian/lean.nvim/issues/92' }
)
end
end
Expand All @@ -25,7 +40,8 @@ return {
--- Call me via `:checkhealth lean`.
check = function()
vim.health.start 'lean.nvim'
check_lean_runnable()
check_for_timers()
neovim_is_new_enough()
lake_is_runnable()
no_timers()
end,
}
8 changes: 5 additions & 3 deletions spec/checkhealth_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ local dedent = require('lean._util').dedent

describe('checkhealth', function()
it('passes the health check', function()
vim.cmd 'silent checkhealth lean'
vim.cmd.checkhealth 'lean'
assert.has_match(
dedent [[
.*lean.nvim.*
.*- .*OK.* `lean ----version`
.*-.* Lean .*version .+
.*- .*OK.* Neovim is new enough.
.*- .*OK.* Lake is runnable.
.*-.* `lake ----version`:
.*Lean .*version .+
]],
table.concat(vim.api.nvim_buf_get_lines(0, 0, -1, false), '\n')
)
Expand Down

0 comments on commit 4b8187b

Please sign in to comment.