Skip to content

Commit

Permalink
feat!: require yazi 0.4.0 or later from 2024-12-08
Browse files Browse the repository at this point in the history
Now that yazi version 0.4.0 is older than a month, we're adapting to
some minor breaking changes.

https://github.com/sxyazi/yazi/releases/tag/v0.4.0
  • Loading branch information
mikavilpas committed Jan 10, 2025
1 parent e4364ea commit 5a78d8b
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 88 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,16 @@ You can optionally configure yazi.nvim by setting any of the options below.
future_features = {
-- Whether to use `ya emit reveal` to reveal files in the file manager.
-- Requires yazi 0.4.0 or later (from 2024-12-08).
ya_emit_reveal = false,
-- 2025-01-10: became on by default, not configurable in the future
-- https://github.com/sxyazi/yazi/pull/1979
ya_emit_reveal = true,

-- Use `ya emit open` as a more robust implementation for opening files
-- in yazi. This can prevent conflicts with custom keymappings for the enter
-- key. Requires yazi 0.4.0 or later (from 2024-12-08).
ya_emit_open = false,
-- 2025-01-10: became on by default, not configurable in the future
-- https://github.com/sxyazi/yazi/pull/1979
ya_emit_open = true,
},
},
}
Expand Down
14 changes: 7 additions & 7 deletions integration-tests/MyTestDirectory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ export const MyTestDirectorySchema = z.object({
extension: z.literal("lua"),
stem: z.literal("modify_yazi_config_do_not_use_ya_emit_open."),
}),
"modify_yazi_config_don't_use_ya_emit_reveal.lua": z.object({
name: z.literal("modify_yazi_config_don't_use_ya_emit_reveal.lua"),
type: z.literal("file"),
extension: z.literal("lua"),
stem: z.literal("modify_yazi_config_don't_use_ya_emit_reveal."),
}),
"modify_yazi_config_log_yazi_closed_successfully.lua": z.object({
name: z.literal(
"modify_yazi_config_log_yazi_closed_successfully.lua",
Expand All @@ -113,12 +119,6 @@ export const MyTestDirectorySchema = z.object({
extension: z.literal("lua"),
stem: z.literal("modify_yazi_config_use_fzf_lua."),
}),
"modify_yazi_config_use_ya_emit_reveal.lua": z.object({
name: z.literal("modify_yazi_config_use_ya_emit_reveal.lua"),
type: z.literal("file"),
extension: z.literal("lua"),
stem: z.literal("modify_yazi_config_use_ya_emit_reveal."),
}),
"notify_custom_events.lua": z.object({
name: z.literal("notify_custom_events.lua"),
type: z.literal("file"),
Expand Down Expand Up @@ -289,9 +289,9 @@ export const testDirectoryFiles = z.enum([
"config-modifications/modify_yazi_config_and_open_multiple_files.lua",
"config-modifications/modify_yazi_config_and_set_help_key.lua",
"config-modifications/modify_yazi_config_do_not_use_ya_emit_open.lua",
"config-modifications/modify_yazi_config_don't_use_ya_emit_reveal.lua",
"config-modifications/modify_yazi_config_log_yazi_closed_successfully.lua",
"config-modifications/modify_yazi_config_use_fzf_lua.lua",
"config-modifications/modify_yazi_config_use_ya_emit_reveal.lua",
"config-modifications/notify_custom_events.lua",
"config-modifications/notify_hover_events.lua",
"config-modifications/notify_rename_events.lua",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ describe("revealing another open split (buffer) in yazi", () => {
},
startupScriptModifications: [
"modify_yazi_config_and_add_hovered_buffer_background.lua",
"modify_yazi_config_use_ya_emit_reveal.lua",
],
}).then(() => {
// sanity check to make sure the files are open
Expand Down Expand Up @@ -87,7 +86,6 @@ describe("revealing another open split (buffer) in yazi", () => {
},
startupScriptModifications: [
"modify_yazi_config_and_add_hovered_buffer_background.lua",
"modify_yazi_config_use_ya_emit_reveal.lua",
],
}).then(() => {
isNotHoveredInNeovim(view.leftAndCenterFile.text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ describe("'cd' to another buffer's directory", () => {
},
startupScriptModifications: [
"modify_yazi_config_and_add_hovered_buffer_background.lua",
"modify_yazi_config_don't_use_ya_emit_reveal.lua",
],
}).then(() => {
assertDoesNotUseEmitReveal()
// sanity check to make sure the files are open
cy.contains(view.leftFile.text)
cy.contains(view.centerFile.text)
Expand Down Expand Up @@ -88,8 +90,10 @@ describe("'cd' to another buffer's directory", () => {
},
startupScriptModifications: [
"modify_yazi_config_and_add_hovered_buffer_background.lua",
"modify_yazi_config_don't_use_ya_emit_reveal.lua",
],
}).then(() => {
assertDoesNotUseEmitReveal()
isNotHoveredInNeovim(view.leftAndCenterFile.text)
isNotHoveredInNeovim(view.rightFile.text)

Expand Down Expand Up @@ -120,7 +124,11 @@ describe("'cd' to another buffer's directory", () => {
it("can tab to the directory of just a single buffer", () => {
cy.startNeovim({
filename: "file2.txt",
startupScriptModifications: [
"modify_yazi_config_don't_use_ya_emit_reveal.lua",
],
}).then((dir) => {
assertDoesNotUseEmitReveal()
cy.contains("Hello")

cy.typeIntoTerminal("{upArrow}")
Expand All @@ -141,3 +149,9 @@ describe("'cd' to another buffer's directory", () => {
})
})
})

function assertDoesNotUseEmitReveal() {
cy.runLuaCode({
luaCode: `assert(require("yazi").config.future_features.ya_emit_reveal == false)`,
})
}
1 change: 1 addition & 0 deletions integration-tests/test-environment/.config/nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ local plugins = {
log_level = vim.log.levels.DEBUG,
future_features = {
ya_emit_open = true,
ya_emit_reveal = true,
},
integrations = {
grep_in_directory = "telescope",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require("yazi").setup(
---@type YaziConfig
{
future_features = {
ya_emit_reveal = true,
ya_emit_reveal = false,
},
}
)
4 changes: 2 additions & 2 deletions lua/yazi/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ return {
end

local checker = require("vim.version")
if not checker.ge(yazi_semver, "0.3.0") then
if not checker.ge(yazi_semver, "0.4.0") then
return vim.health.warn(
"your yazi version is too old, please upgrade to the newest version of yazi"
)
Expand Down Expand Up @@ -70,7 +70,7 @@ return {
)
)
else
if not checker.ge(ya_semver, "0.3.0") then
if not checker.ge(ya_semver, "0.4.0") then
vim.health.warn(
"The `ya` executable version (yazi command line interface) is too old. Please upgrade to the newest version."
)
Expand Down
81 changes: 7 additions & 74 deletions spec/yazi/health_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe("the healthcheck", function()
before_each(function()
snapshot = assert:snapshot()
mock_app_versions = {
["yazi"] = "Yazi 0.3.0 (4112bf4 2024-08-15)",
["yazi"] = "Yazi 0.4.0 (4112bf4 2024-08-15)",
["yazi --help"] = [[Usage: yazi [OPTIONS] [ENTRY]
Arguments:
Expand All @@ -58,7 +58,7 @@ Options:
-V, --version Print version
-h, --help Print help
]],
["ya"] = "Ya 0.3.0 (4112bf4 2024-08-15)",
["ya"] = "Ya 0.4.0 (4112bf4 2024-08-15)",
["nvim-0.10.0"] = true,
}

Expand Down Expand Up @@ -94,8 +94,8 @@ Options:
it("reports everything is ok", function()
vim.cmd("checkhealth yazi")

assert_buffer_contains_text("Found `yazi` version `Yazi 0.3.0")
assert_buffer_contains_text("Found `ya` version `Ya 0.3.0")
assert_buffer_contains_text("Found `yazi` version `Yazi 0.4.0")
assert_buffer_contains_text("Found `ya` version `Ya 0.4.0")
assert_buffer_contains_text("OK yazi")
end)

Expand Down Expand Up @@ -151,8 +151,9 @@ Options:
end)

it("warns when the yazi version and yazi version are not the same", function()
mock_app_versions["yazi"] = "yazi 0.3.5 (f5a7ace 2024-07-23)"
mock_app_versions["ya"] = "Ya 0.3.4 (f5a7ace 2024-06-23)"
-- intentionally use versions that are way too large to not hit other checks
mock_app_versions["yazi"] = "yazi 1.3.5 (f5a7ace 2024-07-23)"
mock_app_versions["ya"] = "Ya 1.3.4 (f5a7ace 2024-06-23)"

vim.cmd("checkhealth yazi")

Expand Down Expand Up @@ -185,74 +186,6 @@ Options:
)
end)

describe("future_features", function()
it(
"warns when yazi is < 0.4.0 and `config.future_features.ya_emit_reveal` is enabled",
function()
yazi.setup({
future_features = {
ya_emit_reveal = true,
},
})

vim.cmd("checkhealth yazi")

assert_buffer_contains_text(
"You have enabled `future_features.ya_emit_reveal` in your config. This requires yazi.nvim version 0.4.0 or newer."
)
end
)

it(
"does not warn when yazi is >= 0.4.0 and `config.future_features.ya_emit_reveal` is enabled",
function()
mock_app_versions["yazi"] = "yazi 0.4.0 (f5a7ace 2024-07-23)"
yazi.setup({
future_features = {
ya_emit_reveal = true,
},
})

vim.cmd("checkhealth yazi")

assert_buffer_does_not_contain_text("future_features.ya_emit_reveal")
end
)

it(
"warns when yazi is < 0.4.0 and `config.future_features.ya_emit_open` is enabled",
function()
yazi.setup({
future_features = {
ya_emit_open = true,
},
})

vim.cmd("checkhealth yazi")

assert_buffer_contains_text(
"You have enabled `future_features.ya_emit_open` in your config. This requires yazi.nvim version 0.4.0 or newer."
)
end
)

it(
"does not warn when yazi is >= 0.4.0 and `config.future_features.ya_emit_open` is enabled",
function()
mock_app_versions["yazi"] = "yazi 0.4.0 (f5a7ace 2024-07-23)"
yazi.setup({
future_features = {
ya_emit_open = true,
},
})

vim.cmd("checkhealth yazi")

assert_buffer_does_not_contain_text("future_features.ya_emit_open")
end
)
end)

describe("the checks for resolve_relative_path_application", function()
it(
"warns when the keymap for this integration is set but the resolver is missing",
Expand Down

0 comments on commit 5a78d8b

Please sign in to comment.