Skip to content

file_info

Zeioth edited this page Apr 3, 2024 · 15 revisions

You can add this component to the statusline section of heirline opts.

require("heirline-components.all").component.file_info()

You can see how this component look on the left of the next image: It will show a icon + the filetype your are currently editing. screenshot_2024-02-22_15-44-22_423566185

Available providers

These are the available providers for this component and its options.

file_icon = {                           -- if set, displays a icon depending the current filetype.
  hl = hl.file_icon "statusline",
  padding = { left = 1, right = 1 },
  condition = condition.is_file
},
filename = false,                       -- if set, displays the filename.
filetype = {},                          -- if set, displays the filetype.
file_modified = false,                  -- if set, displays a white dot if the file has been modified.
file_read_only = {                      -- if set, displays a lock icon if the file is read only.
  padding = { left = 1, right = 1 },
  condition = condition.is_file
},
surround = {
  separator = "left",
  color = "file_info_bg",
  condition = condition.has_filetype,
},
hl = hl.get_attributes "file_info",

Examples

You can explicitely pass providers to the component to modify the information it displays.

require("heirline-components.all").component.file_info({ filetype = false, filename = {}, file_modified = false }) -- icon+filename+extension
require("heirline-components.all").component.file_info({ file_icon = {}, filetype = false, filename = false, file_modified = false }) -- icon only

icon+filename+extension screenshot_2024-02-22_15-52-31_278241997 icon only screenshot_2024-02-22_15-53-12_526624273