A lightweight Neovim plugin for the lf file manager with automatic buffer cleanup.
vim.pack.add({
"https://github.com/coldpatch/lf-simple.nvim",
})
require("lf-simple").setup()Using lazy.nvim
{
"ashaibani/lf-simple.nvim",
config = function()
require("lf-simple").setup()
end,
}Using packer.nvim
use {
"ashaibani/lf-simple.nvim",
config = function()
require("lf-simple").setup()
end
}- Neovim >= 0.7.0
- lf file manager
require("lf-simple").setup({
-- Replace netrw with lf (default: true)
replace_netrw = true,
-- Setup ESC quit with lf (default: true)
escape_quit = true,
-- Custom selection file path (optional)
selection_file = vim.fn.stdpath("cache") .. "/lf_selection",
}):Lf- Open lf in the current working directory:Lf /path/to/directory- Open lf in a specific directory
-- Open lf in current directory
require("lf-simple").open()
-- Open lf in specific directory
require("lf-simple").open("/path/to/directory")You can create custom key mappings:
-- Basic mapping
vim.keymap.set("n", "<leader>lf", "<cmd>Lf<cr>", { desc = "Open lf" })
-- Open lf in current file's directory
vim.keymap.set("n", "<leader>ld", function()
require("lf-simple").open(vim.fn.expand("%:p:h"))
end, { desc = "Open lf in current directory" })<Esc>- Close lf and return to Neovimq- Quit lf (standard lf keybinding)- Select files normally in lf - they will be opened in Neovim when you quit
This plugin automatically tracks file buffers before opening lf and cleans up any directory buffers that were created during the lf session. This prevents the common issue of having lingering directory buffers after using a file manager.
- Before opening lf: Records all currently open file buffers
- During lf session: lf can navigate and open files normally
- After closing lf:
- Opens any files selected in lf
- Closes directory buffers that no longer point to existing files
- Returns focus to the original window