1# Node Types
2
3This configuration defines how to deal with different kinds of nodes (files,
4directories, symlinks etc.) in a directory.
5
6This can be configured using the `xplr.config.node_types` Lua API.
7
8It contains the following fields:
9
10- [directory][1]
11- [file][2]
12- [symlink][3]
13- [mime_essence][4]
14- [extension][5]
15- [special][6]
16
17One node can fall into multiple categories. For example, a node can have the
18extension `md`, and be a `file`. In that case, the properties from the more
19specific category i.e. extension will be used.
20
21The priority is:
22
23**special** > **extension** > **mime_essence** > **symlink** > **file** > **directory**
24
25### directory
26
27Type: [NodeType Config][7]
28
29Properties related to directories are defined here.
30
31Contains the following fields:
32
33Example:
34
35```lua
36xplr.config.node_types.directory.meta.icon = ""
37xplr.config.node_types.directory.style.add_modifiers = { "Bold" }
38```
39
40### file
41
42Type: [NodeType Config][7]
43
44Properties related to regular files are defined here.
45
46Contains the following fields:
47
48Example:
49
50```lua
51xplr.config.node_types.file.meta.icon = ""
52xplr.config.node_types.file.style.fg = "White"
53```
54
55### symlink
56
57Type: [NodeType Config][7]
58
59Properties related to symlink are defined here.
60
61Example:
62
63```lua
64xplr.config.node_types.symlink.meta.icon = ""
65xplr.config.node_types.symlink.style.add_modifiers = { "Italic" }
66```
67
68### mime_essence
69
70Type: mapping of mime-type and mapping of mime-subtype and [NodeType Config][7]
71
72Properties related to files with specific mime types are defined here.
73
74It is possible to use the wildcard `*` to match all mime subtypes. It will be
75overwritten by the more specific sub types that are defined.
76
77Example:
78
79```lua
80xplr.config.node_types.mime_essence = {
81  application = {
82    -- application/*
83    ["*"] = { meta = { icon = "a" } }
84
85    -- application/pdf
86    pdf = { meta = { icon = "" } },
87
88    -- application/zip
89    zip = { meta = { icon = ""} },
90  },
91}
92```
93
94### extension
95
96Type: mapping of extension and [NodeType Config][7]
97
98Properties related to files with specific extension are defined here.
99
100Example:
101
102```lua
103xplr.config.node_types.extension.md = { meta = { icon = "" } }
104xplr.config.node_types.extension.rs = { meta = { icon = "��" } }
105```
106
107### special
108
109Type: mapping of name and [NodeType Config][7]
110
111Properties related to files and directories with special names are defined
112here.
113
114Example:
115
116```lua
117xplr.config.node_types.special["Cargo.toml"] = { meta = { icon = "" } }
118xplr.config.node_types.special["Downloads"] = { meta = { icon = "" } }
119```
120
121## NodeType Config
122
123A node-type config contains the following fields:
124
125- [meta][8]
126- [style][9]
127
128### meta
129
130Type: mapping of string and string
131
132A meta field can contain custom metadata about a node. By default, the "icon"
133metadata is set for the [directory][1], [file][2], and
134[symlink][3] nodes.
135
136Example:
137
138```lua
139xplr.config.node_types.file = {
140  meta = {
141    icon = "f",
142    foo = "bar",
143  }
144}
145```
146
147[1]: #directory
148[2]: #file
149[3]: #symlink
150[4]: #mime_essence
151[5]: #extension
152[6]: #special
153[7]: #nodetype-config
154[8]: #meta
155[9]: style.md
156