nvim-telescope / telescope.nvim

Find, Filter, Preview, Pick. All lua, all the time.
MIT License
15.88k stars 834 forks source link

[Bug] custom_layout doesnt work with mappings #3215

Closed Ajaymamtora closed 3 months ago

Ajaymamtora commented 3 months ago

Description

When defining a custom layout, the picker specific mappings don't work or apply

Neovim version

NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info

Operating system and version

MacOS Sonoma 14

Telescope version / branch / rev

Master 79552ef

checkhealth telescope

==============================================================================
telescope: health#telescope#check

Checking for required plugins ~
- OK plenary installed.
- OK nvim-treesitter installed.

Checking external dependencies ~
- OK rg: found ripgrep 14.1.0
- OK fd: found fd 10.1.0

===== Installed extensions ===== ~

Telescope Extension: `diff` ~
- No healthcheck provided

Telescope Extension: `file_browser` ~
- No healthcheck provided

Telescope Extension: `find_template` ~
- No healthcheck provided

Telescope Extension: `fzf` ~
- OK lib working as expected
- OK file_sorter correctly configured
- OK generic_sorter correctly configured

Telescope Extension: `lazygit` ~
- No healthcheck provided

Telescope Extension: `nerdy` ~
- No healthcheck provided

Telescope Extension: `notify` ~
- No healthcheck provided

Telescope Extension: `persisted` ~
- No healthcheck provided

Telescope Extension: `refactoring` ~
- No healthcheck provided

Telescope Extension: `smart_open` ~
- No healthcheck provided

Telescope Extension: `textcase` ~
- No healthcheck provided

Telescope Extension: `tmux` ~
- No healthcheck provided

Telescope Extension: `undo` ~
- No healthcheck provided

Steps to reproduce

-- setup defaults.pickers.live_grep where nui_hybrid_layout_fn is the hybrid layout in the recipes section:
...
          create_layout = require("utils.telescope_utils").nui_hybrid_layout_fn,
...
live_grep = {
          layout_strategy = "flex",
          layout_config = {
            horizontal = {
              size = {
                width = "90%",
                height = "90%",
              },
            },
            vertical = {
              size = {
                width = "90%",
                height = "90%",
              },
            },
          },
          hidden = true,
          only_sort_text = true,
          -- Handled in args
          use_regex = false,
          file_ignore_patterns = {},
          mappings = {
            i = {
              ["<M-l>"] = swap_regex_mode,
              ["<M-c>"] = swap_case_sensitive_mode,
              ["<M-x>"] = escape_regex_chars,
              ["<M-u>"] = refresh_picker,
              ["<M-r>"] = do_replace,
            },
            n = {
              ["<M-l>"] = swap_regex_mode,
              ["<M-c>"] = swap_case_sensitive_mode,
              ["<M-x>"] = escape_regex_chars,
              ["<M-u>"] = refresh_picker,
              ["<M-r>"] = do_replace,
            },
          },
        },
      },

Expected behavior

mappings should still apply

Actual behavior

they don't

Minimal config

where nui_hybrid_layout_fn is the hybrid layout in the recipes section

...
          create_layout = require("utils.telescope_utils").nui_hybrid_layout_fn,
...

```lua
        live_grep = {
          layout_strategy = "flex",
          layout_config = {
            horizontal = {
              size = {
                width = "90%",
                height = "90%",
              },
            },
            vertical = {
              size = {
                width = "90%",
                height = "90%",
              },
            },
          },
          hidden = true,
          only_sort_text = true,
          -- Handled in args
          use_regex = false,
          file_ignore_patterns = {},
          mappings = {
            i = {
              ["<M-l>"] = swap_regex_mode,
              ["<M-c>"] = swap_case_sensitive_mode,
              ["<M-x>"] = escape_regex_chars,
              ["<M-u>"] = refresh_picker,
              ["<M-r>"] = do_replace,
            },
            n = {
              ["<M-l>"] = swap_regex_mode,
              ["<M-c>"] = swap_case_sensitive_mode,
              ["<M-x>"] = escape_regex_chars,
              ["<M-u>"] = refresh_picker,
              ["<M-r>"] = do_replace,
            },
          },
        },
Ajaymamtora commented 3 months ago

nvm I messed up the nesting