Skip to content

Commit

Permalink
feat: config to remove icon padding (stevearc#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc committed Aug 9, 2023
1 parent eaa20a6 commit b24380c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class ColumnDef:
+ [
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 + []),
Expand Down
5 changes: 5 additions & 0 deletions doc/oil.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
12 changes: 7 additions & 5 deletions lua/oil/columns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions lua/oil/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit b24380c

Please sign in to comment.