Skip to content

coldpatch/lf-simple.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

lf-simple.nvim

A lightweight Neovim plugin for the lf file manager with automatic buffer cleanup.

Installation

Using neovim's built in package manager

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,
}
use {
    "ashaibani/lf-simple.nvim",
    config = function()
        require("lf-simple").setup()
    end
}

Requirements

  • Neovim >= 0.7.0
  • lf file manager

Configuration

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",
})

Usage

Commands

  • :Lf - Open lf in the current working directory
  • :Lf /path/to/directory - Open lf in a specific directory

Lua API

-- Open lf in current directory
require("lf-simple").open()

-- Open lf in specific directory
require("lf-simple").open("/path/to/directory")

Key Mappings

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" })

Inside lf

  • <Esc> - Close lf and return to Neovim
  • q - Quit lf (standard lf keybinding)
  • Select files normally in lf - they will be opened in Neovim when you quit

Buffer Management

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.

How it works:

  1. Before opening lf: Records all currently open file buffers
  2. During lf session: lf can navigate and open files normally
  3. 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages