nvim-telescope / telescope-file-browser.nvim

File Browser extension for telescope.nvim
MIT License
1.68k stars 92 forks source link

feat: Changing behaviour to ranger-like #332

Closed bogdan-the-great closed 10 months ago

bogdan-the-great commented 10 months ago

Is your feature request related to a problem? Please describe. I'm using ranger-like file manager and like to navigate the file tree using h j k l keys.

Describe the solution you'd like On open I'd like to have:

  1. Cursor focused on files, not on search bar.
  2. Being able to move to parent directory by h and to selected directory by l.

Describe alternatives you've considered Remapping ctrl + g, but there isn't anything for going into directory. I think you could make this work with making custom function, but I don't know where to start with it.

jamestrew commented 10 months ago

I think you can achieve this with just remaps.

local fb_actions = require("telescope._extensions.file_browser.actions")
local actions = require("telescope.actions")
require("telescope").setup({
  extensions = {
    file_browser = {
      initial_mode = "normal",
      mappings = {
        n = {
          h = fb_actions.goto_parent_dir,
          j = actions.move_selection_worse,
          k = actions.move_selection_better,
          l = actions.select_default, -- action for going into directories and opening files
        }
      },
    },
  },
})

You can also just use ranger inside neovim if you'd prefer as well. https://github.com/kevinhwang91/rnvimr

I think this is good to close. Feel free to reopen if I've missed something.

bogdan-the-great commented 10 months ago

Thank you! Changing j with k, and its perfect!