A Neovim plugin that integrates lf file manager with snacks.nvim terminal.
- π Floating terminal integration with lf
- β¨οΈ Smart keybindings for opening files (
<C-t>,<C-s>,<C-v>) - π Opens current file location or working directory
- π Handles file renames and buffer cleanup
- π¨ Configurable window size and opener modes
- π Auto-resize handling for terminal window changes
- Neovim >= 0.9.0
- snacks.nvim
- lf file manager installed
Using lazy.nvim
{
"jackielii/snacks-lf.nvim",
dependencies = {
"folke/snacks.nvim",
},
keys = {
{
"<leader>l",
function()
require("snacks-lf").toggle()
end,
desc = "Lf file manager",
},
},
opts = {
-- Configuration options (see below)
},
}Or use the provided lazy spec:
require("snacks-lf.lazy")Press <leader>l (or your configured key) to open lf in a floating terminal.
<C-t>- Open file in new tab<C-s>- Open file in horizontal split<C-v>- Open file in vertical splitl- Open file with selected mode (press after setting mode with above keys)q- Quit lf without opening files
Configure defaults using the opts table in lazy.nvim:
{
"jackielii/snacks-lf.nvim",
dependencies = { "folke/snacks.nvim" },
keys = { { "<leader>l", function() require("snacks-lf").toggle() end, desc = "Lf" } },
opts = {
-- Window options
width = 0.8, -- Window width (default: 0.8)
height = 0.9, -- Window height (default: 0.9)
title = "Lf", -- Terminal title (default: "Lf")
position = "float", -- Terminal position: "float", "bottom", "top", "left", "right" (default: "float")
-- Behavior options
opener = "edit", -- Default opener mode (default: "edit")
auto_insert = true, -- Start insert mode when entering terminal (default: true)
start_insert = true, -- Start insert mode when terminal starts (default: true)
cleanup_renamed = true, -- Cleanup buffers for renamed files (default: true)
resize_key = "\x0c", -- Key to send on resize (default: "\x0c" = Ctrl-L, "" to disable)
-- Lf configuration
lf_command = "map l open;map o ${{open $f}};set sortby name;set noreverse",
-- Keybindings for opening files
maps = {
["<C-t>"] = "tabedit",
["<C-s>"] = "split",
["<C-v>"] = "vsplit",
},
},
}You can override defaults when calling open():
require("snacks-lf").open({
path = "/some/path", -- Path to open in lf (default: current file or cwd)
opener = "split", -- Override default opener mode
width = 0.9, -- Override window width
-- ... other options
})opts = {
position = "bottom",
height = 0.4,
}opts = {
maps = {
["<C-x>"] = "split",
["<C-y>"] = "vsplit",
["<C-n>"] = "tabedit",
},
}opts = {
lf_command = "set hidden;set preview;map l open",
}opts = {
auto_insert = false,
start_insert = false,
}opts = {
resize_key = "R", -- Send 'R' key on resize (if you have it mapped to recol in lfrc)
-- or
resize_key = "", -- Disable auto-resize completely
}Setup function called by lazy.nvim to configure default options.
Parameters:
opts(snacks-lf.Config, optional): Default configuration options
Opens lf file manager in a terminal.
Parameters:
opts(snacks-lf.Config, optional): Configuration options (merged with defaults from setup)
Returns:
- Terminal instance from snacks.nvim
Available Options:
path- Path to open in lfwidth,height- Window dimensionstitle- Window titleposition- Terminal position ("float", "bottom", etc.)opener- Default open mode ("edit", "split", etc.)auto_insert,start_insert- Insert mode behaviorlf_command- Custom lf configurationmaps- Keybindings for open modescleanup_renamed- Whether to cleanup renamed file buffersresize_key- Key to send on terminal resize (default: "\x0c" = Ctrl-L, empty to disable)env- Environment variables to pass to terminal (TERM auto-added)
Toggles lf file manager (alias for open()).
Parameters:
opts(snacks-lf.Config, optional): Configuration options
Returns:
- Terminal instance from snacks.nvim
- Opens lf with
-selection-pathto capture file selections - Monitors terminal keybindings to track opener mode
- On lf exit (TermClose), reads selected files from temp file
- Opens files according to the selected opener mode
- Cleans up temp files and closes terminal
- Inspired by vim-floaterm lf integration
- Built on top of snacks.nvim
- Uses lf file manager
MIT