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: prevent conflicts with custom yazi config for <enter> (opt-in) #615

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

mikavilpas
Copy link
Owner

Issue

For custom ways to open files, such as "open in new vertical split",
"open in new tab", etc., yazi.nvim uses the <enter> key to open the
file. This is not very robust because the user might have set a custom
keybinding for the <enter> key in their yazi config. In this case, the
custom keybinding would be triggered instead of the file being opened.

Solution

Instead of relying on the <enter> key, yazi.nvim can now use ya emit open to make yazi open the file(s) that are currently selected. This
completely avoids the issue, but requires a recent version of yazi
(0.4.0 or later).

To opt into this behaviour, set the following in your config:

{
  -- example for lazy.nvim
  "mikavilpas/yazi.nvim",
  -- ... (other settings here) ...
  ---@type YaziConfig
  opts = {
    future_features = {
      ya_emit_open = true,
      -- 👆🏻 this is the new setting
    },
  },
}

This issue was found in
#611 where
smart-enter.yazi was found to have this behaviour by default:
https://github.com/yazi-rs/plugins/tree/main/smart-enter.yazi#advanced

@mikavilpas mikavilpas enabled auto-merge (rebase) December 12, 2024 06:27
Issue
=====

For custom ways to open files, such as "open in new vertical split",
"open in new tab", etc., yazi.nvim uses the `<enter>` key to open the
file. This is not very robust because the user might have set a custom
keybinding for the `<enter>` key in their yazi config. In this case, the
custom keybinding would be triggered instead of the file being opened.

Solution
========

Instead of relying on the `<enter>` key, yazi.nvim can now use `ya emit
open` to make yazi open the file(s) that are currently selected. This
completely avoids the issue, but requires a recent version of yazi
(0.4.0 or later).

To opt into this behaviour, set the following in your config:

```lua
{
  -- example for lazy.nvim
  "mikavilpas/yazi.nvim",
  -- ... (other settings here) ...
  ---@type YaziConfig
  opts = {
    future_features = {
      ya_emit_open = true,
      -- 👆🏻 this is the new setting
    },
  },
}
```

This issue was found in
#611 where
smart-enter.yazi was found to have this behaviour by default:
https://github.com/yazi-rs/plugins/tree/main/smart-enter.yazi#advanced
@mikavilpas mikavilpas force-pushed the prevent-enter-conflicts branch from 6059639 to 8f6276e Compare December 12, 2024 06:27
@mikavilpas mikavilpas merged commit e64d309 into main Dec 12, 2024
16 checks passed
@mikavilpas mikavilpas deleted the prevent-enter-conflicts branch December 12, 2024 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant