TimUntersberger/neofs

github github
file-explorer
stars 73
issues 4
subscribers 3
forks 3
CREATED

2020-10-29

UPDATED

2 years ago


neofs

A file manager for neovim written in lua

Mappings

Key Description
<CR> or l Open folder or open file in the previous window
0 Open the CWD
h Open the parent folder of the current path
f Create a new file
d Create a new directory
<c-r> Rename current item
<c-d> Delete current item
<m-c-d> Recursively delete current item
q Quit

Custom Mappings

If you want to have some custom mappings defined whenever the file browser is open you can set them using the setup function.

Each callback receives the file manager as its first argument.

To see what you can do with the file manager look at this section

local neofs = require('neofs')

neofs.setup {
  mappings = {
    ["<c-e>w"] = function(fm)
      fm.path = vim.fn.expand("~/Desktop/workspace")
      fm.refresh()
    end
  }
}

Devicons

Neofs supports devicons if you set devicons to true.

local neofs = require('neofs')

neofs.setup {
  devicons = true
}

This requires you to have kyazdani42/nvim-web-devicons installed.

File Manager

Fields

  • decorations (The border)
  • navigator (The left window)
  • preview (The right window)
  • path (The current path for the navigator)

To see more details about each field you can use print(vim.inspect(...))

Functions

open()

Takes an optional path parameter. If this is empty, the current working directory is opened.

This function should be bound to a keymap like

vim.keymap.set("n", "<leader>fs", function()
  require("neofs").open()
end, {noremap = true})

It can also be invoked by pressing :lua require("neofs").open("~/proj").

navigator.item()

Returns the item under the cursor.

An item has the following fields:

  • path (The absolute path of the item)
  • stat (fs_stat result)

refresh()

Refreshes the content of the navigator window using the path field and reloads the preview window.

refresh_preview()

Reloads the preview window using the item under the cursor.

parent()

Returns the parent folder of the current path.