telescope-file-browser.nvim

nvim-telescopeMIT长期未更新

给 telescope.nvim 加的文件浏览器扩展,在 Neovim 里以模糊搜索的方式浏览、管理和操作文件,不用离开编辑器就能完成文件管理。

File Browser extension for telescope.nvim

暂无版本1,947star107fork同步于 2026-11-07 07:33 UTC

怎么上手

由 README 提炼,执行前请确认
-- lazy
{
    "nvim-telescope/telescope-file-browser.nvim",
    dependencies = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" }
}
-- 之后需调用
require("telescope").load_extension "file_browser"
硬件要求按 README 说明

README 未说明,仅要求 Neovim >= 0.9.0

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

telescope.nvim 的文件浏览器扩展,让你在 Neovim 里直接浏览、增删改移文件

给 telescope.nvim 加的文件浏览器扩展,在 Neovim 里以模糊搜索的方式浏览、管理和操作文件,不用离开编辑器就能完成文件管理。

核心能力

  • 在 telescope 选择器中浏览文件与文件夹,支持模糊查找
  • 同步创建、删除、重命名、移动、复制文件与文件夹
  • 文件浏览器与文件夹浏览器可一键切换
  • 支持多选批量操作,并显示 git 状态与文件信息
  • nvim 0.10+ 下文件操作带 LSP 集成

容易踩的坑

必须同时安装 telescope.nvim 和 plenary.nvim 两个依赖;setup 后还需调用 load_extension 才会生效;fd 和 git 为可选依赖,不装则浏览器变慢且无 git 状态显示

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

0 个版本

暂无 release 数据(可能没有发版,或尚未同步)。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    telescope-file-browser.nvim

    telescope-file-browser.nvim is a file browser extension for telescope.nvim. It supports synchronized creation, deletion, renaming, and moving of files and folders (with LSP integration with nvim 0.10+) powered by telescope.nvim and plenary.nvim.

    Demo More demo examples can be found in the showcase issue.

    Table of Contents


    Requirements

    • Neovim >= 0.9.0
    • fd (optional, for faster browser)
    • git (optional, for display git status)

    Installation

    Install the plugin with your preferred package manager.

    --lazy
    {
        "nvim-telescope/telescope-file-browser.nvim",
        dependencies = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" }
    }
    
    -- packer
    use {
        "nvim-telescope/telescope-file-browser.nvim",
        requires = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" }
    }
    
    Plug 'nvim-lua/plenary.nvim'
    Plug 'nvim-telescope/telescope.nvim'
    Plug 'nvim-telescope/telescope-file-browser.nvim'
    

    Setup and Configuration

    You can configure the telescope-file-browser like any other telescope.nvim picker. Please see :h telescope-file-browser.picker for the full set of options dedicated to the picker. Unless otherwise stated, you can pass these options either to your configuration at extension setup or picker startup. For instance, you can map theme and mappings as you are used to from telescope.nvim.

    -- You don't need to set any of these options.
    -- IMPORTANT!: this is only a showcase of how you can set default options!
    require("telescope").setup {
      extensions = {
        file_browser = {
          theme = "ivy",
          -- disables netrw and use telescope-file-browser in its place
          hijack_netrw = true,
          mappings = {
            ["i"] = {
              -- your custom insert mode mappings
            },
            ["n"] = {
              -- your custom normal mode mappings
            },
          },
        },
      },
    }
    -- To get telescope-file-browser loaded and working with telescope,
    -- you need to call load_extension, somewhere after setup function:
    require("telescope").load_extension "file_browser"
    

    Non-primative options are commented out. See :h telescope-file-browser.picker.file_browser()

    local fb_actions = require "telescope._extensions.file_browser.actions"
    
    require("telescope").setup {
      extensions = {
        file_browser = {
          path = vim.loop.cwd(),
          cwd = vim.loop.cwd(),
          cwd_to_path = false,
          grouped = false,
          files = true,
          add_dirs = true,
          depth = 1,
          auto_depth = false,
          select_buffer = false,
          hidden = { file_browser = false, folder_browser = false },
          respect_gitignore = vim.fn.executable "fd" == 1,
          no_ignore = false,
          follow_symlinks = false,
          browse_files = require("telescope._extensions.file_browser.finders").browse_files,
          browse_folders = require("telescope._extensions.file_browser.finders").browse_folders,
          hide_parent_dir = false,
          collapse_dirs = false,
          prompt_path = false,
          quiet = false,
          dir_icon = "",
          dir_icon_hl = "Default",
          display_stat = { date = true, size = true, mode = true },
          hijack_netrw = false,
          use_fd = true,
          git_status = true,
          mappings = {
            ["i"] = {
              ["<A-c>"] = fb_actions.create,
              ["<S-CR>"] = fb_actions.create_from_prompt,
              ["<A-r>"] = fb_actions.rename,
              ["<A-m>"] = fb_actions.move,
              ["<A-y>"] = fb_actions.copy,
              ["<A-d>"] = fb_actions.remove,
              ["<C-o>"] = fb_actions.open,
              ["<C-g>"] = fb_actions.goto_parent_dir,
              ["<C-e>"] = fb_actions.goto_home_dir,
              ["<C-w>"] = fb_actions.goto_cwd,
              ["<C-t>"] = fb_actions.change_cwd,
              ["<C-f>"] = fb_actions.toggle_browser,
              ["<C-h>"] = fb_actions.toggle_hidden,
              ["<C-s>"] = fb_actions.toggle_all,
              ["<bs>"] = fb_actions.backspace,
            },
            ["n"] = {
              ["c"] = fb_actions.create,
              ["r"] = fb_actions.rename,
              ["m"] = fb_actions.move,
              ["y"] = fb_actions.copy,
              ["d"] = fb_actions.remove,
              ["o"] = fb_actions.open,
              ["g"] = fb_actions.goto_parent_dir,
              ["e"] = fb_actions.goto_home_dir,
              ["w"] = fb_actions.goto_cwd,
              ["t"] = fb_actions.change_cwd,
              ["f"] = fb_actions.toggle_browser,
              ["h"] = fb_actions.toggle_hidden,
              ["s"] = fb_actions.toggle_all,
            },
          },
        },
      },
    }
    

    Usage

    You can use the telescope-file-browser as follows:

    vim.keymap.set("n", "<space>fb", ":Telescope file_browser<CR>")
    
    -- open file_browser with the path of the current buffer
    vim.keymap.set("n", "<space>fb", ":Telescope file_browser path=%:p:h select_buffer=true<CR>")
    
    -- Alternatively, using lua API
    vim.keymap.set("n", "<space>fb", function()
    	require("telescope").extensions.file_browser.file_browser()
    end)
    

    Mappings

    telescope-file-browser.nvim comes with a lot of default mappings for discoverability. You can use telescope's which_key (insert mode: <C-/>, normal mode: ?) to list mappings attached to your picker.

    • path denotes the folder the file_browser is currently in
    • fb_actions refers to the table of provided telescope-file-browser.actions accessible via require "telescope".extensions.file_browser.actions
    Insert / Normalfb_actionsDescription
    <A-c>/ccreateCreate file/folder at current path (trailing path separator creates folder)
    <S-CR>create_from_promptCreate and open file/folder from prompt (trailing path separator creates folder)
    <A-r>/rrenameRename multi-selected files/folders
    <A-m>/mmoveMove multi-selected files/folders to current path
    <A-y>/ycopyCopy (multi-)selected files/folders to current path
    <A-d>/dremoveDelete (multi-)selected files/folders
    <C-o>/oopenOpen file/folder with default system application
    <C-g>/ggoto_parent_dirGo to parent directory
    <C-e>/egoto_home_dirGo to home directory
    <C-w>/wgoto_cwdGo to current working directory (cwd)
    <C-t>/tchange_cwdChange nvim's cwd to selected folder/file(parent)
    <C-f>/ftoggle_browserToggle between file and folder browser
    <C-h>/htoggle_hiddenToggle hidden files/folders
    <C-s>/stoggle_allToggle all entries ignoring ./ and ../
    <Tab>see telescope.nvimToggle selection and move to next selection
    <S-Tab>see telescope.nvimToggle selection and move to prev selection
    <bs>/backspaceWith an empty prompt, goes to parent dir. Otherwise acts normally

    fb_actions.create_from_prompt requires that your terminal recognizes these keycodes (e.g. kitty). See :h tui-input for more information.

    Remappings

    As part of the setup, you can remap actions as you like. The default mappings can also be found in this file.

    local fb_actions = require "telescope".extensions.file_browser.actions
    
    require("telescope").setup {
      defaults = { --[[ your defaults]] },
      extensions = {
        file_browser = {
          mappings = {
            ["i"] = {
              -- remap to going to home directory
              ["<C-h>"] = fb_actions.goto_home_dir,
              ["<C-x>"] = function(prompt_bufnr)
                -- your custom function
              end,
            },
            ["n"] = {
              -- unmap toggling `fb_actions.toggle_browser`
              f = false,
            },
          },
        },
      },
    }
    

    Documentation

    The documentation of telescope-file-browser can be be accessed from within Neovim via:

    TopicVimdocComment
    Introduction:h telescope-file-browser.nvim
    Picker options:h telescope-file-browser.picker.file_browserFor extension setup
    Actions:h telescope-file-browser.actionsExplore mappable actions
    Finders:h telescope-file-browser.findersLower level for customization

    The documentation can be easily explored via :Telescope help_tags. Search for fb_actions, for instance, nicely lists available actions from within vimdocs. Very much recommended!

    Please make sure to consult the docs prior to raising issues for asking questions.

    Workflow

    telescope-file-browser.nvim unifies a file_browser and a folder_browser into a single finder that can be toggled between:

    1. file_browser: finds files and folders in the (currently) selected folder (denoted as path, default: cwd)
    2. folder_browser: swiftly fuzzy find folders from cwd downwards to switch folders for the file_browser (i.e. set path to selected folder)

    Within a single session, path always refers to the folder the file_browser is currently in and changes by selecting folders from within the file or folder_browser.

    If you want to open the file_browser from within the folder of your current buffer, you should pass path = "%:p:h" to the opts table of the picker (Vimscript: :Telescope file_browser path=%:p:h) or to the extension setup configuration. Strings passed to path or cwd are expanded automatically.

    By default, the folder_browser always launches from cwd, but it can be configured to launch from path via passing the cwd_to_path = true to picker opts table or at extension setup. The former corresponds to a more project-centric file browser workflow, whereas the latter typically facilitates file and folder browsing across the entire file system.

    In practice, it mostly affects how you navigate the file system in multi-hop scenarios, for instance, when moving files from varying folders into a separate folder. The default works well in projects from which the folder_browser can easily reach any folder. cwd_to_path = true would possibly require returning to parent directories or cwd intermittently. However, if you move deeply through the file system, launching the folder_browser from cwd every time is tedious. Hence, it can be configured to follow path instead.

    In general, telescope-file-browser.nvim intends to enable any workflow without comprise via opting in as virtually any component can be overriden.

    Multi-Selections

    Multiple files and directories can be selected at the same time using default bindings (<Tab>/<S-Tab>) from telescope.nvim.

    One distinct difference to telescope.nvim is that multi-selections are preserved between browsers.

    Hence, whenever you (de-)select a file or folder within {file, folder}_browser, respectively, this change persists across browsers (in a single session).

    File System Operations

    Note: path corresponds to the folder the file_browser is currently in.

    Warning: Batch renaming or moving files with path inter-dependencies are not resolved! For instance, moving a folder somewhere while moving another file into the original folder in later order within same action will fail.

    Action (incl. GIF)DocsComment
    creation:h telescope-file-browser.actions.createCreate file or folder (with trailing OS separator) at path (file_browser) or at selected directory (folder_browser)
    copying:h telescope-file-browser.actions.copySupports copying current selection & multi-selections to path (file_browser) or selected directory (folder_browser)
    moving:h telescope-file-browser.actions.moveMove multi-selected files to path (file_browser) or selected directory (folder_browser)
    removing:h telescope-file-browser.actions.removeRemove (multi-)selected files
    renaming:h telescope-file-browser.actions.renameRename (multi-)selected files

    See fb_actions for a list of native actions and inspiration on how to write your own custom action. As additional reference, plenary's Path library powers a lot of the built-in actions.

    For more information on telescope actions and remappings, see also the upstream documentation and associated vimdocs at :h telescope.defaults.mappings.

    Additional information can also be found in telescope's developer documentation.

    Exports

    The extension exports the following attributes via :lua require "telescope".extensions.file_browser:

    ExportDescription
    file_browsermain picker
    actionsfile browser actions for e.g. remapping
    finderfile, folder, and unified finder for user customization
    _pickerUnconfigured equivalent of file_browser

    Roadmap & Contributing

    Please see the associated issue on more immediate open TODOs for telescope-file-browser.nvim.

    That said, the primary work surrounds on enabling users to tailor the extension to their individual workflow, primarily through opting in and possibly overriding specific components.