Column Renderer

A column renderer is a Lua function that receives a special argument and returns a string that will be displayed in each specific field of the files table.

xplr by default provides the following column renderers:

  • xplr.fn.builtin.fmt_general_table_row_cols_0
  • xplr.fn.builtin.fmt_general_table_row_cols_1
  • xplr.fn.builtin.fmt_general_table_row_cols_2
  • xplr.fn.builtin.fmt_general_table_row_cols_3
  • xplr.fn.builtin.fmt_general_table_row_cols_4

You can either overwrite these functions, or create new functions in xplr.fn.custom and point to them.

Terminal colors are supported.

Table Renderer Argument

The special argument contains the following fields

parent

Type: string

The parent path of the node.

relative_path

Type: string

The path relative to the parent, i.e. the file/directory name with extension.

absolute_path

Type: string

The absolute path (without resolving symlinks) of the node.

extension

Type: string

The extension of the node.

Type: boolean

true if the node is a symlink.

is_broken

Type: boolean

true if the node is a broken symlink.

is_dir

Type: boolean

true if the node is a directory.

is_file

Type: boolean

true if the node is a file.

is_readonly

Type: boolean

true if the node is real-only.

mime_essence

Type: string

The mime type of the node. For e.g. text/csv, image/jpeg etc.

size

Type: integer

The size of the exact node. The size of a directory won't be calculated recursively.

human_size

Type: string

Like size but in human readable format.

permissions

Type: Permission

The permissions applied to the node.

created

Type: nullable integer

Creation time in nanosecond since UNIX epoch.

last_modified

Type: nullable integer

Last modification time in nanosecond since UNIX epoch.

uid

Type: integer

User ID of the file owner.

gid

Type: integer

Group ID of the file owner.

canonical

Type: nullable Resolved Node Metadata

If the node is a symlink, it will hold information about the symlink resolved node. Else, it will hold information the actual node. It the symlink is broken, it will be null.

Type: nullable Resolved Node Metadata

If the node is a symlink and is not broken, it will hold information about the symlink resolved node. However, it will never hold information about the actual node. It will instead be null.

index

Type: integer

Index (starting from 0) of the node.

relative_index

Type: integer

Relative index from the focused node (i.e. 0th node).

is_before_focus

Type: boolean

true if the node is before the focused node.

is_after_focus

Type: boolean

true if the node is after the focused node.

tree

Type: string

The tree component based on the node's index.

prefix

Type: string

The prefix applicable for the node.

suffix

Type: string

The suffix applicable for the node.

is_selected

Type: boolean

true if the node is selected.

is_focused

Type: boolean

true if the node is under focus.

total

Type: integer

The total number of the nodes.

meta

Type: mapping of string and string

The applicable meta object for the node.

Permission

Permission contains the following fields:

  • user_read
  • user_write
  • user_execute
  • group_read
  • group_write
  • group_execute
  • other_read
  • other_write
  • other_execute
  • sticky
  • setgid
  • setuid

Each field holds a boolean value.

Resolved Node Metadata

It contains the following fields.

Example: Customizing Table Renderer

xplr.fn.custom.fmt_simple_column = function(m)
  return m.prefix .. m.relative_path .. m.suffix
end

xplr.config.general.table.header.cols = {
  { format = "  path" }
}

xplr.config.general.table.row.cols = {
  { format = "custom.fmt_simple_column" }
}

xplr.config.general.table.col_widths = {
  { Percentage = 100 }
}

-- With this config, you should only see a single column displaying the
-- relative paths.