feat: config to remove icon padding (#145)

This commit is contained in:
Steven Arcangeli 2023-08-08 23:14:47 -07:00
parent eaa20a6aee
commit b24380c0e1
4 changed files with 18 additions and 5 deletions

1
.github/generate.py vendored
View file

@ -119,6 +119,7 @@ COL_DEFS = [
+ [
LuaParam("default_file", "string", "Fallback icon for files when nvim-web-devicons returns nil"),
LuaParam("directory", "string", "Icon for directories"),
LuaParam("add_padding", "boolean", "Set to false to remove the extra whitespace after the icon"),
],
),
ColumnDef("size", "files, ssh", False, "The size of the file", HL + []),

View file

@ -260,6 +260,8 @@ icon *column-ico
{default_file} `string` Fallback icon for files when nvim-web-devicons
returns nil
{directory} `string` Icon for directories
{add_padding} `boolean` Set to false to remove the extra whitespace after
the icon
size *column-size*
Adapters: files, ssh
@ -383,6 +385,9 @@ HIGHLIGHTS *oil-highlight
OilDir *hl-OilDir*
Directories in an oil buffer
OilDirIcon *hl-OilDirIcon*
Icon for directories
OilSocket *hl-OilSocket*
Socket files in an oil buffer

View file

@ -208,16 +208,18 @@ if has_devicons then
type = meta.link_stat.type
end
end
local icon, hl
if type == "directory" then
local icon = conf and conf.directory or " "
return { icon, "OilDir" }
icon = conf and conf.directory or ""
hl = "OilDirIcon"
else
local icon
local hl
icon, hl = devicons.get_icon(name)
icon = icon or (conf and conf.default_file or "")
return { icon .. " ", hl }
end
if not conf or conf.add_padding ~= false then
icon = icon .. " "
end
return { icon, hl }
end,
parse = function(line, conf)

View file

@ -625,6 +625,11 @@ M._get_highlights = function()
link = "Directory",
desc = "Directories in an oil buffer",
},
{
name = "OilDirIcon",
link = "OilDir",
desc = "Icon for directories",
},
{
name = "OilSocket",
link = "Keyword",