Skip to content

Commit

Permalink
feat(health): suggest enabling new features for yazi >= 0.3.0 (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikavilpas committed Aug 11, 2024
1 parent b87e772 commit 8cd2f71
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lua/yazi/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,22 @@ return {
end
end

if
checker.ge(yazi_semver, "0.3.0") and not config.use_ya_for_events_reading
then
vim.health.info(
"You can enable `use_ya_for_events_reading` in your config to get access to new features. This is available for yazi versions >= 0.3.0."
)
end

if
checker.ge(yazi_semver, "0.3.0") and not config.use_yazi_client_id_flag
then
vim.health.info(
"You can enable `use_yazi_client_id_flag` in your config to get access to new features. This is available for yazi versions >= 0.3.0."
)
end

if config.open_for_directories == true then
vim.health.info(
"You have enabled `open_for_directories` in your config. Because of this, please make sure you are loading yazi when Neovim starts."
Expand Down
74 changes: 74 additions & 0 deletions spec/yazi/health_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,78 @@ Options:
end
)
end)

describe("suggestions for `use_ya_for_events_reading`", function()
it(
"suggests enabling `use_ya_for_events_reading` when yazi version is >= 0.3.0",
function()
mock_app_versions["yazi"] = "yazi 0.3.0 (f5a7ace 2024-06-23)"
yazi.setup({ use_ya_for_events_reading = false })
vim.cmd("checkhealth yazi")

assert_buffer_contains_text(
"You can enable `use_ya_for_events_reading` in your config to get access to new features. This is available for yazi versions >= 0.3.0."
)
end
)

it(
"does not suggest enabling `use_ya_for_events_reading` when yazi version is < 0.3.0",
function()
mock_app_versions["yazi"] = "yazi 0.2.5 (f5a7ace 2024-06-23)"
yazi.setup({ use_ya_for_events_reading = false })
vim.cmd("checkhealth yazi")

assert_buffer_does_not_contain_text("use_ya_for_events_reading")
end
)

it(
"does not suggest enabling `use_ya_for_events_reading` when it is already enabled",
function()
mock_app_versions["yazi"] = "yazi 0.3.0 (f5a7ace 2024-06-23)"
yazi.setup({ use_ya_for_events_reading = true })
vim.cmd("checkhealth yazi")

assert_buffer_does_not_contain_text("use_ya_for_events_reading")
end
)
end)

describe("suggestions for `use_yazi_client_id_flag`", function()
it(
"suggests enabling `use_yazi_client_id_flag` when yazi version is >= 0.3.0",
function()
mock_app_versions["yazi"] = "yazi 0.3.0 (f5a7ace 2024-06-23)"
yazi.setup({ use_yazi_client_id_flag = false })
vim.cmd("checkhealth yazi")

assert_buffer_contains_text(
"You can enable `use_yazi_client_id_flag` in your config to get access to new features. This is available for yazi versions >= 0.3.0."
)
end
)

it(
"does not suggest enabling `use_yazi_client_id_flag` when yazi version is < 0.3.0",
function()
mock_app_versions["yazi"] = "yazi 0.2.5 (f5a7ace 2024-06-23)"
yazi.setup({ use_yazi_client_id_flag = false })
vim.cmd("checkhealth yazi")

assert_buffer_does_not_contain_text("use_yazi_client_id_flag")
end
)

it(
"does not suggest enabling `use_yazi_client_id_flag` when it is already enabled",
function()
mock_app_versions["yazi"] = "yazi 0.3.0 (f5a7ace 2024-06-23)"
yazi.setup({ use_yazi_client_id_flag = true })
vim.cmd("checkhealth yazi")

assert_buffer_does_not_contain_text("use_yazi_client_id_flag")
end
)
end)
end)

0 comments on commit 8cd2f71

Please sign in to comment.