Skip to content
Rizwanelansyah edited this page May 25, 2024 · 8 revisions

Configuration Option

this the avaible option on the setup function opts

border: table

this field determines how the border style of file explorer is the border table avaible fields is up, left, main, right with the value is border style like nvim_open_win() border config

default value:

{
    main = "double",
    left = "rounded",
    right = "rounded",
    up = { "", "", "", ":", "", "", "", ":" },
}

example:

require("simplyfile").setup {
    border = {
        up = { "", "", "", "|", "/", "_", "\\", "|" },
        main = {
            { "#", "MyMainCorner" },
            { "+", "MyMainBorder" },
        },
    },
}

default_keymaps: boolean

determine the plugin should use default keymaps or not, see default keymaps, default true.

keymaps: table

key maps for the file explorer, this keymaps override default_keymaps field. default is empty table {},

example keymap: map d to remove file/folder using trash-cli:

require("simplyfile").setup {
    keymaps = {
        d = function(dir)
            os.execute("trash " .. dir.absolute)
        end,
    }
}

open_on_enter: boolean

open file explorer on enter neovim

preview: table

preview have this fields

  • show: determine if the file is can show on the preview window(right window) on explorer or not, show must be boolean or function that return boolean and passed one selected dir, default true.

    Example:

    require("simplyfile").setup {
        preview = {
            show = function(dir)
                if dir.is_folder then
                    -- don't show node_mopdules and .git
                    -- folder on preview window
                    if dir.name == "node_modules" then
                        return false
                    elseif dir.name == ".git" then
                        return false
                    else
                        return true
                    end
                else
                    -- don't preview image on preview window
                    if dir.name:match("%.png$") then
                        return false
                    else
                        return true
                    end
                end,
            end
        },
    }
  • max_lines: max lines that can be shown on the preview the value can be a integer or function that not take any argument and return an integer.

    default:

    function()
        return vim.o.lines
    end

    example:

    require("simplyfile").setup {
        preview = {
            max_lines = 1,
        },
    }

clipboard: table

clipboard option for file explorer the values is a table that have field

  • notify: a boolean value that determine if the simplyfile clipboard must notify or not

example:

require("simplyfile").setup {
    clipboard = {
        notify = true,
    }
}

filters: table

a table that have a field as the filtername and the value is the function that receive one SimplyFile.Directory and return boolean that determine if the file/directory must be show or not on file explorer

example:

require("simplyfile").setup {
    filters = {
        folder = function(dir)
            return dir.is_folder
        end,
    },
}

default_filter: function

a function that used for default filter on file explorer open

example:

require("simplyfile").setup {
    default_filter = function(dir)
        return not vim.endswith(dir.name, ".")
    end,
}

sorts: table

a table that have a field as the sortname and the value is the function like second parameter on table.sort() with two SimplyFile.Directory as the parameter

example:

require("simplyfile").setup {
    sorts = {
        name_length = function(a, b)
            return #a.name < #b.name
        end,
    },
}

default_sort: function

a function that used for default sort on file explorer open

example:

require("simplyfile").setup {
    default_sort = function(a, b)
        return vim.fn.getfsize(a.name) < vim.fn.getfsize(b.name)
    end,
}

(v0.4+) up_bar: table

fields avaible on up_bar:

  • events: events for trigerring callback function the events is table with the key is the neovim events and the value is the nvim_create_augroup() opts

  • callback: function that called when the event is trigerred the function first parameter is SimplyFile.ExplState the return is two list that contain a { text, hl }

example:

require("simplyfile").setup {
    up_bar = {
        events = {
            -- user defined event from plugin simplyfile.nvim 
            User = { pattern = "SimplyFileStateChange"  },
        },
        callback = function(expl)
            return {
                { expl.path, "Directory" },
                { " |>",     "FloatBorder" },
            }, {
                { "<| ",       "FloatBorder" },
                { "Search: ",  "@field" },
                { expl.search, "CursorLine" },
            }
        end
    },
}

Clone this wiki locally