diff --git a/README.md b/README.md
index 99830ba..82bb2ef 100644
--- a/README.md
+++ b/README.md
@@ -15,73 +15,56 @@ a layer of *✨bling✨* and configuration to your favorite file explorer.
## Requirements
- Neovim >= 0.5.0
-- [nvim-web-devicons](https://github.com/nvim-tree/nvim-web-devicons) (optional)
+- One of the following icon provider plugin (optional):
+ - [mini.icons](https://github.com/echasnovski/mini.icons)
+ - [nvim-web-devicons](https://github.com/nvim-tree/nvim-web-devicons)
- [A patched font](https://www.nerdfonts.com/) (optional)
## Installing
Install the plugin with your preferred package manager:
-[vim-plug](https://github.com/junegunn/vim-plug)
+
+lazy.nvim
+{ 'prichrd/netrw.nvim', opts = {} }
+
-```vim
-Plug 'prichrd/netrw.nvim'
-```
+
+vim-plug
+Plug 'prichrd/netrw.nvim'
+
+
+
+packer
+use 'prichrd/netrw.nvim'
+
-[packer](https://github.com/wbthomason/packer.nvim)
+## Configuration
+Enable the plugin with the default configuration:
```lua
-use 'prichrd/netrw.nvim'
+require("netrw").setup({})
```
-## Usage
-
-Enable the plugin:
-
+Or customize the options to fit your needs:
```lua
-require'netrw'.setup{
- -- Put your configuration here, or leave the object empty to take the default
- -- configuration.
+require("netrw").setup({
+ -- File icons to use when `use_devicons` is false or if
+ -- no icon is found for the given file type.
icons = {
- symlink = '', -- Symlink icon (directory and file)
- directory = '', -- Directory icon
- file = '', -- File icon
+ symlink = '',
+ directory = '',
+ file = '',
},
- use_devicons = true, -- Uses nvim-web-devicons if true, otherwise use the file icon specified above
- mappings = {}, -- Custom key mappings
-}
-```
-
-Custom key mappings:
-
-```lua
-require'netrw'.setup{
- -- your config ...
-
- -- Define normal mode mapping
+ -- Uses mini.icon or nvim-web-devicons if true, otherwise use the file icon specified above
+ use_devicons = true,
mappings = {
- -- Function mappings
- ['p'] = function(payload)
- -- Payload is an object describing the node under the cursor, the object
- -- has the following keys:
- -- - dir: the current netrw directory (vim.b.netrw_curdir)
- -- - node: the name of the file or directory under the cursor
- -- - link: the referenced file if the node under the cursor is a symlink
- -- - extension: the file extension if the node under the cursor is a file
- -- - type: the type of node under the cursor (0 = dir, 1 = file, 2 = symlink)
- -- - col: the column of the node (for liststyle 3)
- print(vim.inspect(payload))
- end,
- -- String command mappings
- [''] = ":echo 'string command'",
- -- more mappings ...
- }
- -- your config ...
-}
-```
-
-The plugin documentation can be found at [doc/netrw.nvim.txt](doc/netrw.nvim.txt).
-You can also use the :help netrw.nvim command inside of Neovim.
+ -- Function mappings receive an object describing the node under the cursor
+ ['p'] = function(payload) print(vim.inspect(payload)) end,
+ -- String mappings are executed as vim commands
+ ['p'] = ":echo 'hello world'",
+ },
+})
## Contributing
diff --git a/doc/netrw.nvim.txt b/doc/netrw.nvim.txt
index 38561ba..9af8ebd 100644
--- a/doc/netrw.nvim.txt
+++ b/doc/netrw.nvim.txt
@@ -5,7 +5,7 @@ CONTENTS
*netrw-contents*
1. Intro (|netrw-intro|)
- 2. Configure (|netrw-configure|)
+ 2. Configuration (|netrw-configuration|)
==============================================================================
INTRO
@@ -19,49 +19,36 @@ explorer:
It requires Neovim 0.5.0 and other optional dependencies:
+* mini.icons
* nvim-web-devicons
* A patched font (see README.md for links to install)
==============================================================================
-CONFIGURE
-*netrw-configure*
-
-Enable the plugin: >
- require'netrw'.setup{
- -- Put your configuration here, or leave the object empty to take the default
- -- configuration.
+CONFIGURATION
+*netrw-configuration*
+
+Enable the plugin with the default configuration:
+>lua
+ require("netrw").setup({})
+
+Or customize the options to fit your needs:
+>lua
+ require("netrw").setup({
+ -- File icons to use when `use_devicons` is false or if
+ -- no icon is found for the given file type.
icons = {
- symlink = '', -- Symlink icon (directory and file)
- directory = '', -- Directory icon
- file = '', -- File icon
+ symlink = '',
+ directory = '',
+ file = '',
},
- use_devicons = true, -- Uses nvim-web-devicons if true, otherwise use the file icon specified above
- mappings = {}, -- Custom key mappings
- }
-
-Custom key mappings: >
- require'netrw'.setup{
- -- your config ...
-
- -- Define normal mode mapping
+ -- Uses mini.icon or nvim-web-devicons if true, otherwise use the file icon specified above
+ use_devicons = true,
mappings = {
- -- Function mappings
- ['p'] = function(payload)
- -- Payload is an object describing the node under the cursor, the object
- -- has the following keys:
- -- - dir: the current netrw directory (vim.b.netrw_curdir)
- -- - node: the name of the file or directory under the cursor
- -- - link: the referenced file if the node under the cursor is a symlink
- -- - extension: the file extension if the node under the cursor is a file
- -- - type: the type of node under the cursor (0 = dir, 1 = file, 2 = symlink)
- -- - col: the column of the node (for liststyle 3)
- print(vim.inspect(payload))
- end,
- -- String command mappings
- [''] = ":echo 'string command'",
- -- more mappings ...
- }
- -- your config ...
- }
+ -- Function mappings receive an object describing the node under the cursor
+ ['p'] = function(payload) print(vim.inspect(payload)) end,
+ -- String mappings are executed as vim commands
+ ['p'] = ":echo 'hello world'",
+ },
+ })
vim: ft=help tw=78 et ts=2 sw=2 sts=2 norl
diff --git a/lua/netrw/ui.lua b/lua/netrw/ui.lua
index 78c2bfb..93ec7b6 100644
--- a/lua/netrw/ui.lua
+++ b/lua/netrw/ui.lua
@@ -10,8 +10,16 @@ local get_icon = function(node)
if node.type == parse.TYPE_FILE then
icon = config.options.icons.file
if config.options.use_devicons then
+ local has_miniicons, miniicons = pcall(require, "mini.icons")
local has_devicons, devicons = pcall(require, "nvim-web-devicons")
- if has_devicons then
+
+ if has_miniicons then
+ local ic, hi = miniicons.get("file", node.node)
+ if ic then
+ icon = ic
+ hl_group = hi
+ end
+ elseif has_devicons then
local ic, hi = devicons.get_icon(node.node, nil, { strict = true, default = false })
if ic then
icon = ic