Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add healthcheck #4

Merged
merged 1 commit into from
Mar 15, 2024
Merged
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
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,
}