danielfalk / smart-open.nvim

Neovim plugin for fast file-finding
MIT License
498 stars 25 forks source link

mappings does not work #57

Closed fjchen7 closed 5 months ago

fjchen7 commented 8 months ago
return {
  "danielfalk/smart-open.nvim",
  -- branch = "0.2.x",
  dependencies = {
    "kkharji/sqlite.lua",
    "nvim-telescope/telescope.nvim",
    { "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
  },
  keys = {
    {
      "<leader>fs",
      function()
        require("telescope").extensions.smart_open.smart_open({
          prompt_title = "Smart Open",
          cwd_only = true,
          filename_first = true,
        })
      end,
      desc = "Smart Open File",
    },
  },
  config = function()
    local telescope = require("telescope")
    local hbac = function()
      vim.cmd("Telescope hbac buffers")
    end
    telescope.setup({
      extensions = {
        smart_open = {
          match_algorithm = "fzf",
          mappings = {
            i = {
              ["<C-g>"] = hbac,
            },
          },
        },
      },
    })
    telescope.load_extension("smart_open")
  end,
}

My customized <C-h> doesn't work. Seems the mapping is not registered.

NikolaM-Dev commented 8 months ago

@jimzk

Hi :wave:, I don't know why?

But if you want that config, you need some like this

local hbac = function()
    vim.cmd('Telescope hbac buffers')
end

local options = {
    match_algorithm = 'fzf',
    mappings = {
        i = {
            ['<C-i>'] = hbac,
        },
    },
}

return {
    'danielfalk/smart-open.nvim',
    keys = {
        {
            '<leader>ff',
            function()
                require('telescope').extensions.smart_open.smart_open(options)
            end,
            desc = '[F]ind Smart Open',
        },
    },
    config = function()
        require('telescope').load_extension('smart_open')

        vim.api.nvim_create_user_command('SmartOpen', function()
            require('telescope').extensions.smart_open.smart_open(options)
        end, {})
    end,
}
fjchen7 commented 8 months ago

Hey @NikolaM-Dev, Thanks for replay. However it still does not work for me. I am doubting that the mapping I configure in telescope override those in smart-open.

danielfalk commented 5 months ago

Hi, I've started a new branch 0.2.x where I have a fix for this. If you want to try it out and let me know, that would be great. I'll be updating that branch more hopefully in the near future and if it looks good, will start recommending it more broadly.

I'll close this for now, but if you want to try it out feel free to leave feedback here.