Skip to content

Commit

Permalink
Fixed default colors.
Browse files Browse the repository at this point in the history
  • Loading branch information
X3eRo0 committed Dec 19, 2023
1 parent 5f14349 commit b93f3c5
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ The default color configuration is given below
DiredDotfile = { link = {}, bg = "NONE", fg = "626262" },
DiredFadeText1 = { link = {}, bg = "NONE", fg = "626262", gui = "NONE" },
DiredFadeText2 = { link = {}, bg = "NONE", fg = "444444", gui = "NONE" },
DiredSize = { link = {}, bg = "NONE", fg = "306844", gui = "NONE" },
DiredSize = { link = { "Normal" }, bg = "NONE", fg = "None", gui = "NONE" },
DiredUsername = { link = {}, bg = "NONE", fg = "87CEFA", gui = "bold" },
DiredMonth = { link = {}, bg = "NONE", fg = "696969", gui = "bold" },
DiredDay = { link = {}, bg = "NONE", fg = "778899", gui = "bold" },
DiredMonth = { link = { "Normal" }, bg = "NONE", fg = "None", gui = "bold" },
DiredDay = { link = { "Normal" }, bg = "NONE", fg = "None", gui = "bold" },
DiredFileName = { link = {}, bg = "NONE", fg = "NONE", gui = "NONE" },
DiredFileSuid = { link = {}, bg = "ff6666", fg = "000000", gui = "bold" },
DiredNormal = { link = { "Normal" }, bg = "NONE", fg = "NONE", gui = "NONE" },
Expand Down
8 changes: 6 additions & 2 deletions lua/dired/colors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ function M.get_filename_color(component)
return hl.BROKEN_LINK, hl.BROKEN_LINK_TARGET
end
else
if ut.bitand(fs_t.mode, fs.fs_masks.S_ISUID) > 0 and ut.bitand(fs_t.mode, fs.fs_masks.S_ISGID) > 0 then
if
ut.bitand(fs_t.mode, fs.fs_masks.S_ISUID) > 0
and ut.bitand(fs_t.mode, fs.fs_masks.S_ISGID) > 0
then
-- if file is suid
return hl.FILE_SUID
elseif
Expand Down Expand Up @@ -97,7 +100,8 @@ function M.get_component_str(component)
component = component,
line = string.format(
"%s %s %s %s %s %s %s %s %s",
component.permissions,
-- component.permissions,
hl.get_highlighted_string(component.permissions, M.get_permission_color()),
component.nlinks,
component.owner,
component.group,
Expand Down
6 changes: 3 additions & 3 deletions lua/dired/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ local CONFIG_SPEC = {
DiredDotfile = { link = {}, bg = "NONE", fg = "626262" },
DiredFadeText1 = { link = {}, bg = "NONE", fg = "626262", gui = "NONE" },
DiredFadeText2 = { link = {}, bg = "NONE", fg = "444444", gui = "NONE" },
DiredSize = { link = {}, bg = "NONE", fg = "306844", gui = "NONE" },
DiredSize = { link = { "Normal" }, bg = "NONE", fg = "None", gui = "NONE" },
DiredUsername = { link = {}, bg = "NONE", fg = "87CEFA", gui = "bold" },
DiredMonth = { link = {}, bg = "NONE", fg = "696969", gui = "bold" },
DiredDay = { link = {}, bg = "NONE", fg = "778899", gui = "bold" },
DiredMonth = { link = { "Normal" }, bg = "NONE", fg = "None", gui = "bold" },
DiredDay = { link = { "Normal" }, bg = "NONE", fg = "None", gui = "bold" },
DiredFileName = { link = {}, bg = "NONE", fg = "NONE", gui = "NONE" },
DiredFileSuid = { link = {}, bg = "ff6666", fg = "000000", gui = "bold" },
DiredNormal = { link = { "Normal" }, bg = "NONE", fg = "NONE", gui = "NONE" },
Expand Down
1 change: 1 addition & 0 deletions lua/dired/dired.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function M.init_dired()
vim.api.nvim_buf_set_name(0, path) -- 0 is current buffer

vim.bo.filetype = "dired"
vim.bo.swapfile = false
vim.bo.buftype = "acwrite"
vim.bo.bufhidden = "wipe"
vim.bo.modifiable = true
Expand Down
36 changes: 32 additions & 4 deletions lua/dired/highlight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ M.get_faded_highlight_group = function(hl_group_name, fade_percentage)
local green = (f_green * fade_percentage) + (b_green * (1 - fade_percentage))
local blue = (f_blue * fade_percentage) + (b_blue * (1 - fade_percentage))

local new_foreground = string.format("%s%s%s", dec_to_hex(red, 2), dec_to_hex(green, 2), dec_to_hex(blue, 2))
local new_foreground =
string.format("%s%s%s", dec_to_hex(red, 2), dec_to_hex(green, 2), dec_to_hex(blue, 2))

create_highlight_group(key, {}, hl_group.background, new_foreground, gui)
faded_highlight_group_cache[key] = key
Expand Down Expand Up @@ -212,16 +213,34 @@ M.setup = function()
clr.DiredFadeText2.gui
)

create_highlight_group(M.SIZE, clr.DiredSize.link, clr.DiredSize.bg, clr.DiredSize.fg, clr.DiredSize.gui)
create_highlight_group(
M.SIZE,
clr.DiredSize.link,
clr.DiredSize.bg,
clr.DiredSize.fg,
clr.DiredSize.gui
)
create_highlight_group(
M.USERNAME,
clr.DiredUsername.link,
clr.DiredUsername.bg,
clr.DiredUsername.fg,
clr.DiredUsername.gui
)
create_highlight_group(M.MONTH, clr.DiredMonth.link, clr.DiredMonth.bg, clr.DiredMonth.fg, clr.DiredMonth.gui)
create_highlight_group(M.DAY, clr.DiredDay.link, clr.DiredDay.bg, clr.DiredDay.fg, clr.DiredDay.gui)
create_highlight_group(
M.MONTH,
clr.DiredMonth.link,
clr.DiredMonth.bg,
clr.DiredMonth.fg,
clr.DiredMonth.gui
)
create_highlight_group(
M.DAY,
clr.DiredDay.link,
clr.DiredDay.bg,
clr.DiredDay.fg,
clr.DiredDay.gui
)
create_highlight_group(
M.FILE_NAME,
clr.DiredFileName.link,
Expand Down Expand Up @@ -309,4 +328,13 @@ M.setup = function()
end
end

function M.get_highlighted_string(str, hl, restore)
restore = restore == nil or restore
if restore then
return table.concat({ "%#", hl or "", "#", str or "", "%*" })
else
return table.concat({ "%#", hl or "", "#", str or "" })
end
end

return M

0 comments on commit b93f3c5

Please sign in to comment.