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).
- [snacks.nvim][https://github.com/folke/snacks.nvim]
- fd (for faster browser)
{
"folke/snacks.nvim",
dependencies = { 'hasansujon786/snacks-file-browser.nvim' }
}
require('snacks-file-browser').browse(opts)
-- Or show cwd
require('snacks-file-browser').browse({ cwd = vim.fn.expand('%:h') })
-- 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' } },
},
},
},
}
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)
The plugin design is heavily inspired by this excellent plugins: