Skip to content

Commit

Permalink
feat(health): add instructions for open_for_directories (#281)
Browse files Browse the repository at this point in the history
When `open_for_directories` is set to `true`, the user should be
instructed to load yazi when Neovim starts. This is because the
autocmds that yazi sets up to load the directories need to be set up
before a directory is opened.
  • Loading branch information
mikavilpas authored Jul 28, 2024
1 parent 4b44d2f commit 0df9393
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lua/yazi/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ return {
end
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.'
)
end

vim.health.ok('yazi')
end,
}
24 changes: 24 additions & 0 deletions spec/yazi/health_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,28 @@ Options:
end
)
end)

describe('the checks for `open_for_directories`', function()
it(
'instructs the user to load yazi on startup when `open_for_directories` is set',
function()
require('yazi').setup({ open_for_directories = true })
vim.cmd('checkhealth yazi')

assert_buffer_contains_text(
'You have enabled `open_for_directories` in your config. Because of this, please make sure you are loading yazi when Neovim starts.'
)
end
)

it(
'does not instruct the user to load yazi on startup when `open_for_directories` is not set',
function()
require('yazi').setup({ open_for_directories = false })
vim.cmd('checkhealth yazi')

assert_buffer_does_not_contain_text('open_for_directories')
end
)
end)
end)

0 comments on commit 0df9393

Please sign in to comment.