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

Default keymaps do not respond #578

Open
spring-haru opened this issue Nov 21, 2024 · 7 comments
Open

Default keymaps do not respond #578

spring-haru opened this issue Nov 21, 2024 · 7 comments

Comments

@spring-haru
Copy link

spring-haru commented Nov 21, 2024

I installed yazi.nvim with the default settings. But, I cannot open a file by pressing a default key, e.g. <c-t>.

:checkhealth yazi shows

yazi: require("yazi.health").check()

yazi ~
- Running yazi.nvim version 6.5.1
- Found `yazi` version `Yazi 0.3.3 (Homebrew 2024-11-16)` 👍
- yazi.nvim log file is at /Users/me/.local/state/nvim-test/yazi.log
-     hint: use `gf` to open the file path under the cursor
- Found `ya` version `Ya 0.3.3 (Homebrew 2024-11-16)` 👍

yazi.config ~
- hint: execute the following command to see your configuration: >
  :lua =require('yazi').config
  
- OK yazi

and :lua =require('yazi').config shows

keymaps = {
    change_working_directory = "<c-\\>",
    copy_relative_path_to_selected_files = "<c-y>",
    cycle_open_buffers = "<tab>",
    grep_in_directory = "<c-s>",
    open_file_in_horizontal_split = "<c-x>",
    open_file_in_tab = "<c-t>",
    open_file_in_vertical_split = "<c-v>",
    replace_in_directory = "<c-g>",
    send_to_quickfix_list = "<c-q>",
    show_help = "<f1>"
  },

Any advice would be appreciated.

@mikavilpas
Copy link
Owner

Hmm, I'm thinking it might be something else in your config that could be causing issues. Can you try to run the minimal reproduction setup here and see if you can reproduce the issue?

@spring-haru
Copy link
Author

The minimus setup works great and allows me to use the demault keymaps, i.e. the issue cannot be reproduced.

@mikavilpas
Copy link
Owner

Ok, that's a great finding. In that case, it's probably something in your config. Try to disable all plugins in your config and see if it can still be reproduced. If not, then gradually enable them until you find what plugin (or many plugins) have conflicts.

@spring-haru
Copy link
Author

spring-haru commented Nov 21, 2024

I did two things, and neither of them worked, i.e. the default keymaps did not respond. I will explain what I did below, and would appreciate if you could point out what I did wrong.

In my first attempt, I removed all plugins except lazy.nvim and yazi.nvim from my own current settings. But it did not work.

So, I decided to create another nvim, called nvim-test from scratch, closely following the Structured Setup at

https://lazy.folke.io/installation

  1. create ~/.config/nvim-test/init.lua
  2. create ~/.config/nvim-test/lua/config/lazy.lua
  3. create ~/.config/nvim-test/lua/plugins/yazi.nvim

where the content of yazi.nvim is

---@type LazySpec
return {
  "mikavilpas/yazi.nvim",
  event = "VeryLazy",
  keys = {
    -- 👇 in this section, choose your own keymappings!
    {
      "<leader>-",
      "<cmd>Yazi<cr>",
      desc = "Open yazi at the current file",
    },
    {
      -- Open in the current working directory
      "<leader>cw",
      "<cmd>Yazi cwd<cr>",
      desc = "Open the file manager in nvim's working directory" ,
    },
    {
      -- NOTE: this requires a version of yazi that includes
      -- https://github.com/sxyazi/yazi/pull/1305 from 2024-07-18
      '<c-up>',
      "<cmd>Yazi toggle<cr>",
      desc = "Resume the last yazi session",
    },
  },
  ---@type YaziConfig
  opts = {
    -- if you want to open yazi instead of netrw, see below for more info
    open_for_directories = false,
    keymaps = {
      show_help = '<f1>',
    },
  },
}

After adding alias nvimtt='NVIM_APPNAME=nvim-test nvim in .zshrc, I started nvimtt. The results of :checkhealth yazi and :lua=require('yazi').config are the same as before. But, the default keymaps did not work.

@mikavilpas
Copy link
Owner

Try to add this into the plugin spec, maybe next to opts = {} as a new property:

    config = function(_self, opts)
      vim.notify("Yazi is loaded with the following opts: " .. vim.inspect(require("yazi").config))
    end,

image

For me it prints this:

image

@spring-haru
Copy link
Author

When stated, It shows

Yazi is loaded with the following opts: {
  clipboard_register = "*",
  enable_mouse_support = false,
  floating_window_scaling_factor = 0.9,
  highlight_groups = {},
  highlight_hovered_buffers_in_same_directory = true,
  hooks = {
    yazi_closed_successfully = <function 1>,
    yazi_opened = <function 2>,
    yazi_opened_multiple_files = <function 3>
  },
  integrations = {
    grep_in_directory = <function 4>,
    grep_in_selected_files = <function 5>,
    replace_in_directory = <function 6>,
    replace_in_selected_files = <function 7>,
    resolve_relative_path_application = "grealpath"
  },
  keymaps = {
    change_working_directory = "<c-\\>",
    copy_relative_path_to_selected_files = "<c-y>",
    cycle_open_buffers = "<tab>",
    grep_in_directory = "<c-s>",
    open_file_in_horizontal_split = "<c-x>",
    open_file_in_tab = "<c-t>",
    open_file_in_vertical_split = "<c-v>",
    replace_in_directory = "<c-g>",
    send_to_quickfix_list = "<c-q>",
    show_help = "<f1>"
  },
  log_level = 5,
  open_file_function = <function 8>,
  open_for_directories = false,
  open_multiple_tabs = false,
  yazi_floating_window_border = "rounded",
  yazi_floating_window_winblend = 0
}

But the problem still remains.

@mikavilpas
Copy link
Owner

It looks like the keymaps are defined in yazi.nvim's config. If they have no effect for you, it might be something in your system.

Since it works with the minimal reproduction setup, I don't know what could be wrong.

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

No branches or pull requests

2 participants