Skip to content

Commit

Permalink
feat: add healthcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
mikavilpas committed Mar 15, 2024
1 parent 4beaec3 commit d644306
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ So far I have done some maintenance work:
- feat: yazi pre-selects the current file when opened
- test: add simple testing setup for future development
- feat: can optionally open yazi instead of netrw for directories
- feat: health check for yazi

If you'd like to collaborate, contact me via GitHub issues.

Expand Down Expand Up @@ -41,3 +42,5 @@ Using lazy.nvim:
},
}
```

You can run `:checkhealth yazi` to see if the plugin is installed and working.
32 changes: 32 additions & 0 deletions lua/yazi/health.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
-- see :help :checkhealth
-- https://github.com/neovim/neovim/blob/b7779c514632f8c7f791c92203a96d43fffa57c6/runtime/doc/pi_health.txt#L17
return {
check = function()
vim.health.start('yazi')

if vim.fn.executable('yazi') ~= 1 then
vim.health.warn('yazi not found on PATH')
end

-- example data:
-- 'yazi 0.2.4 (411ba2f 2024-03-15)'
local raw_version = vim.fn.system('yazi --version')

-- parse the version

local semver = raw_version:match('^yazi (%w+%.%w+%.%w+)')

if semver == nil then
vim.health.warn('yazi --version looks unexpected, saw ' .. raw_version)
end

local checker = require('vim.version')
if not checker.ge(semver, '0.1.5') then
return vim.health.warn(
'yazi version is too old, please upgrade to 0.1.5 or newer'
)
end

vim.health.ok('yazi')
end,
}

0 comments on commit d644306

Please sign in to comment.