Skip to content

hasansujon786/snacks-file-browser.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

📂 snacks-file-browser.nvim

snacks-file-browser.nvim is a file browser picker for snacks.nvim. This project was created as an alternative to telescope-file-browser to fill the void I felt after switching to snacks.nvim.

Important

The plugin is a work in progress (WIP).

⚡️ Requirements

📦 Installation

{
    "folke/snacks.nvim",
    dependencies = { 'hasansujon786/snacks-file-browser.nvim' }
}

📚 Usage

require('snacks-file-browser').browse(opts)

-- Or show cwd
require('snacks-file-browser').browse({ cwd = vim.fn.expand('%:h') })

📚 Setup

-- lazy.nvim
{
    "folke/snacks.nvim",
    dependencies = { 'hasansujon786/snacks-file-browser.nvim' }
    keys = {
        { '<leader>.', function() require('snacks-file-browser').browse({ cwd = vim.fn.expand('%:h') }) end, desc = 'Browse current directory' },
        { '<leader>fb', function() require('snacks-file-browser').browse() end, desc = 'Browser directory' },
    }
    ---@type snacks.Config
    opts = {
        picker = {
            sources = {
                ---@type snacks.picker.file_browser.Config
                file_browser = {
                    -- Put config here
                },
            }

        }
    }
}
Default Options
---@type snacks.picker.file_browser.Config
file_browser = {
    -- file_browser specific opts
    title = 'File browser',
    depth = 1,
    add_dirs = true,
    prompt_prefix = true,

    -- General picker opts
    format = 'file',
    finder = 'files',
    source = 'file_browser',
    supports_live = false,
    layout = 'ivy',
    matcher = {
        sort_empty = true,
    },
    win = {
        input = {
            keys = {
                ['<c-t>'] = { 'goto_parent', mode = { 'i', 'n' } },
                ['<c-u>'] = { 'clear_prompt_or_goto_cwd', mode = { 'i' } },
                ['<bs>'] = { 'backspace', mode = { 'i', 'n' } },
            },
        },
    },
}

Supported actions

Insert / Normal fb_actions Description
<c-t> goto_parent Go to parent directory
<bs> backspace When input is empty, goes to parent dir. Otherwise acts normally
<c-u> clear_prompt_or_goto_cwd When input is empty, goes to root of cwd. Otherwise acts normally

(File manipulating actions such as delete,move in WIP)

Acknowledgements

The plugin design is heavily inspired by this excellent plugins:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages