doc: explain passing parameters to columns

This commit is contained in:
Steven Arcangeli 2023-01-08 22:22:47 -08:00
parent d8a1e7ca4e
commit adb2828c4f
2 changed files with 31 additions and 11 deletions

15
.github/generate.py vendored
View file

@ -81,7 +81,7 @@ class ColumnDef:
params: List["LuaParam"] = field(default_factory=list) params: List["LuaParam"] = field(default_factory=list)
HL = [LuaParam("highlight", "string|fun", "Highlight group")] HL = [LuaParam("highlight", "string|fun(value: string): string", "Highlight group, or function that returns a highlight group")]
TIME = [ TIME = [
LuaParam("format", "string", "Format string (see :help strftime)"), LuaParam("format", "string", "Format string (see :help strftime)"),
] ]
@ -91,7 +91,8 @@ COL_DEFS = [
"*", "*",
False, False,
"The type of the entry (file, directory, link, etc)", "The type of the entry (file, directory, link, etc)",
HL + [LuaParam("icons", "table<string, string>", "Mapping of entry type to icon")], HL
+ [LuaParam("icons", "table<string, string>", "Mapping of entry type to icon")],
), ),
ColumnDef( ColumnDef(
"icon", "icon",
@ -101,7 +102,9 @@ COL_DEFS = [
HL + [], HL + [],
), ),
ColumnDef("size", "files, ssh", False, "The size of the file", HL + []), ColumnDef("size", "files, ssh", False, "The size of the file", HL + []),
ColumnDef("permissions", "files, ssh", True, "Access permissions of the file", HL + []), ColumnDef(
"permissions", "files, ssh", True, "Access permissions of the file", HL + []
),
ColumnDef("ctime", "files", False, "Change timestamp of the file", HL + TIME + []), ColumnDef("ctime", "files", False, "Change timestamp of the file", HL + TIME + []),
ColumnDef( ColumnDef(
"mtime", "files", False, "Last modified time of the file", HL + TIME + [] "mtime", "files", False, "Last modified time of the file", HL + TIME + []
@ -140,6 +143,12 @@ def get_highlights_vimdoc() -> "VimdocSection":
def get_columns_vimdoc() -> "VimdocSection": def get_columns_vimdoc() -> "VimdocSection":
section = VimdocSection("Columns", "oil-columns", ["\n"]) section = VimdocSection("Columns", "oil-columns", ["\n"])
section.body.extend(
wrap(
'Columns can be specified as a string to use default arguments (e.g. `"icon"`), or as a table to pass parameters (e.g. `{"size", highlight = "Special"}`)'
)
)
section.body.append('\n')
for col in COL_DEFS: for col in COL_DEFS:
section.body.append(leftright(col.name, f"*column-{col.name}*")) section.body.append(leftright(col.name, f"*column-{col.name}*"))
section.body.extend(wrap(f"Adapters: {col.adapters}", 4)) section.body.extend(wrap(f"Adapters: {col.adapters}", 4))

View file

@ -158,12 +158,16 @@ setup({opts}) *oil.setu
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
COLUMNS *oil-columns* COLUMNS *oil-columns*
Columns can be specified as a string to use default arguments (e.g. `"icon"`),
or as a table to pass parameters (e.g. `{"size", highlight = "Special"}`)
type *column-type* type *column-type*
Adapters: * Adapters: *
The type of the entry (file, directory, link, etc) The type of the entry (file, directory, link, etc)
Parameters: Parameters:
{highlight} `string|fun` Highlight group {highlight} `string|fun(value: string): string` Highlight group, or
function that returns a highlight group
{icons} `table<string, string>` Mapping of entry type to icon {icons} `table<string, string>` Mapping of entry type to icon
icon *column-icon* icon *column-icon*
@ -171,14 +175,16 @@ icon *column-ico
An icon for the entry's type (requires nvim-web-devicons) An icon for the entry's type (requires nvim-web-devicons)
Parameters: Parameters:
{highlight} `string|fun` Highlight group {highlight} `string|fun(value: string): string` Highlight group, or
function that returns a highlight group
size *column-size* size *column-size*
Adapters: files, ssh Adapters: files, ssh
The size of the file The size of the file
Parameters: Parameters:
{highlight} `string|fun` Highlight group {highlight} `string|fun(value: string): string` Highlight group, or
function that returns a highlight group
permissions *column-permissions* permissions *column-permissions*
Adapters: files, ssh Adapters: files, ssh
@ -186,14 +192,16 @@ permissions *column-permission
Access permissions of the file Access permissions of the file
Parameters: Parameters:
{highlight} `string|fun` Highlight group {highlight} `string|fun(value: string): string` Highlight group, or
function that returns a highlight group
ctime *column-ctime* ctime *column-ctime*
Adapters: files Adapters: files
Change timestamp of the file Change timestamp of the file
Parameters: Parameters:
{highlight} `string|fun` Highlight group {highlight} `string|fun(value: string): string` Highlight group, or
function that returns a highlight group
{format} `string` Format string (see :help strftime) {format} `string` Format string (see :help strftime)
mtime *column-mtime* mtime *column-mtime*
@ -201,7 +209,8 @@ mtime *column-mtim
Last modified time of the file Last modified time of the file
Parameters: Parameters:
{highlight} `string|fun` Highlight group {highlight} `string|fun(value: string): string` Highlight group, or
function that returns a highlight group
{format} `string` Format string (see :help strftime) {format} `string` Format string (see :help strftime)
atime *column-atime* atime *column-atime*
@ -209,7 +218,8 @@ atime *column-atim
Last access time of the file Last access time of the file
Parameters: Parameters:
{highlight} `string|fun` Highlight group {highlight} `string|fun(value: string): string` Highlight group, or
function that returns a highlight group
{format} `string` Format string (see :help strftime) {format} `string` Format string (see :help strftime)
birthtime *column-birthtime* birthtime *column-birthtime*
@ -217,7 +227,8 @@ birthtime *column-birthtim
The time the file was created The time the file was created
Parameters: Parameters:
{highlight} `string|fun` Highlight group {highlight} `string|fun(value: string): string` Highlight group, or
function that returns a highlight group
{format} `string` Format string (see :help strftime) {format} `string` Format string (see :help strftime)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------