nvim-telescope / telescope-file-browser.nvim

File Browser extension for telescope.nvim
MIT License
1.6k stars 89 forks source link

`goto_parent_dir` is not reliable #352

Closed azzamsa closed 3 months ago

azzamsa commented 6 months ago

Hi 👋🏼

I am having a hard time assigning a key for 'go back to the parent directory.' It is not reliable; most of the time, it doesn't work. With the configuration provided below, it just flashes the screen and does nothing. However, when I press '' once, suddenly all keys assigned to 'fb_actions.goto_parent_dir' work.

["n"] = {
    ["<Left>"] = fb_actions.goto_parent_dir,
    ["g"] = fb_actions.goto_parent_dir,
    ["<Right>"] = actions.select_default,
{
    "nvim-telescope/telescope-file-browser.nvim",
    commit = "4bd5657b14b58e069287f5ac591a647bb860b2ed",
    config = function()
        local oil = require("oil")
        local fb_actions = require("telescope._extensions.file_browser.actions")
        local actions = require("telescope.actions")
        local action_state = require("telescope.actions.state")

        require("telescope").setup({
            extensions = {
                file_browser = {
                    mappings = {
                        ["i"] = {},
                        ["n"] = {
                            ["<Left>"] = fb_actions.goto_parent_dir,
                            ["g"] = fb_actions.goto_parent_dir,
                            ["<Right>"] = actions.select_default,
                        },
                    },
                },
            },
        })
    end,
},
NVIM v0.9.4

https://github.com/nvim-telescope/telescope-file-browser.nvim/assets/17734314/0b395185-1425-40e8-bb1f-ce0500e9142f

jamestrew commented 6 months ago

I'm not able to reproduce this with this minimal config based on your config

local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  {
    "nvim-telescope/telescope-file-browser.nvim",
    commit = "4bd5657b14b58e069287f5ac591a647bb860b2ed",
    dependencies = {
      "nvim-telescope/telescope.nvim",
      "nvim-lua/plenary.nvim",
    },
    config = function()
      local fb_actions = require("telescope._extensions.file_browser.actions")
      local actions = require("telescope.actions")

      require("telescope").setup({
        extensions = {
          file_browser = {
            mappings = {
              ["i"] = {},
              ["n"] = {
                ["<Left>"] = fb_actions.goto_parent_dir,
                ["g"] = fb_actions.goto_parent_dir,
                ["<Right>"] = actions.select_default,
              },
            },
          },
        },
      })
      require("telescope").load_extension("file_browser")
    end,
  },
}

require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

Please try this config. You can save it to a /tmp and run nvim -u /tmp/min.lua. <Left> works fine for me. g works but with a slight delay since g in normal mode technically clashes with many builtin g commands.

jamestrew commented 3 months ago

Closing this due to no response.