nix-community / nixvim

Configure Neovim with Nix! [maintainer=@GaetanLepage, @traxys, @mattsturgeon, @khaneliman]
https://nix-community.github.io/nixvim
MIT License
1.69k stars 262 forks source link

[Fzf-lua] Difficulty in setting up a keymap #2425

Open Balssh opened 2 hours ago

Balssh commented 2 hours ago

Hi, I'm using the following configuration of fzf-lua in nixvim:

{
  programs.nixvim = {
    plugins = {
      fzf-lua = {
        enable = true;
        profile = "fzf-native";
        settings = {
          fzf_opts = {
            "--cycle" = "";
          };
        };
        keymaps = {
          "<leader>sg" = "live_grep";
          "<leader>sf" = "files";
          "<leader>sr" = "resume";
          "<leader><leader>" = "buffers";
          "<leader>sw" = "grep_cword";
          "<leader>s." = "oldfiles";
        };
        luaConfig.post = "require('fzf-lua').register_ui_select()";
      };
    };
  };
}

What I'm trying to add is the following part of a config (written in lua):

require('fzf-lua').setup {
        keymap = {
          fzf = {
            false, -- do not inherit from defaults
            ['ctrl-d'] = 'preview-half-page-down',
            ['ctrl-u'] = 'preview-half-page-up',
          },
        },
      }

Tried several ways but keep getting various errors.

MattSturgeon commented 2 hours ago

At the most fundamental level, you can always translate any lua passed to setup as a nix attrset assigned to settings:

settings = {
  keymap.fzf = {
    __unkeyed-1 = false; # do not inherit from defaults
    ctrl-d = "preview-half-page-down";
    ctrl-u = "preview-half-page-up";
  };
}

However you'd have to check what is produced using nixvim-print-init.

In particular I'm unsure how our plugins.fzf-lua.keymaps option will interact with the keymap.fzf table and/or if passing false will work as intended or if we'll define extra keymaps...

You may find the docs (plugin, settings, keymaps option, etc) and module source code useful for any further investigation :slightly_smiling_face: