Skip to content

feat: add desktop environment and window manager categories with icons #438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions lua/nvim-web-devicons.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
local M = {}

-- When adding new icons, remember to add an entry to the `filetypes` table, if applicable.
-- NOTE: When adding new icons, remember to add an entry to the `filetypes` table, if applicable.
local icons, icons_by_filename, icons_by_file_extension, icons_by_operating_system
local icons_by_desktop_environment, icons_by_window_manager

local default_icon = {
icon = "",
Expand Down Expand Up @@ -33,7 +34,17 @@ local function refresh_icons()
icons_by_filename = theme.icons_by_filename
icons_by_file_extension = theme.icons_by_file_extension
icons_by_operating_system = theme.icons_by_operating_system
icons = vim.tbl_extend("keep", {}, icons_by_filename, icons_by_file_extension, icons_by_operating_system)
icons_by_desktop_environment = theme.icons_by_desktop_environment
icons_by_window_manager = theme.icons_by_window_manager
icons = vim.tbl_extend(
"keep",
{},
icons_by_filename,
icons_by_file_extension,
icons_by_operating_system,
icons_by_desktop_environment,
icons_by_window_manager
)
icons = vim.tbl_extend("force", icons, global_opts.override)
icons[1] = default_icon
end
Expand Down Expand Up @@ -345,22 +356,28 @@ function M.setup(opts)
local user_filename_icons = user_icons.override_by_filename
local user_file_ext_icons = user_icons.override_by_extension
local user_operating_system_icons = user_icons.override_by_operating_system
local user_desktop_environment_icons = user_icons.override_by_desktop_environment
local user_window_manager_icons = user_icons.override_by_window_manager

icons = vim.tbl_extend(
"force",
icons,
user_icons.override or {},
user_filename_icons or {},
user_file_ext_icons or {},
user_operating_system_icons or {}
user_operating_system_icons or {},
user_desktop_environment_icons or {},
user_window_manager_icons or {}
)
global_opts.override = vim.tbl_extend(
"force",
global_opts.override,
user_icons.override or {},
user_filename_icons or {},
user_file_ext_icons or {},
user_operating_system_icons or {}
user_operating_system_icons or {},
user_desktop_environment_icons or {},
user_window_manager_icons or {}
)

if user_filename_icons then
Expand All @@ -372,6 +389,12 @@ function M.setup(opts)
if user_operating_system_icons then
icons_by_operating_system = vim.tbl_extend("force", icons_by_operating_system, user_operating_system_icons)
end
if user_desktop_environment_icons then
icons_by_desktop_environment = vim.tbl_extend("force", icons_by_desktop_environment, user_desktop_environment_icons)
end
if user_window_manager_icons then
icons_by_window_manager = vim.tbl_extend("force", icons_by_window_manager, user_window_manager_icons)
end

icons[1] = default_icon

Expand All @@ -390,7 +413,9 @@ function M.setup(opts)
global_opts.override,
icons_by_filename,
icons_by_file_extension,
icons_by_operating_system
icons_by_operating_system,
icons_by_desktop_environment,
icons_by_window_manager
)
end, {
desc = "nvim-web-devicons: highlight test",
Expand Down
16 changes: 14 additions & 2 deletions lua/nvim-web-devicons/hi-test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,17 @@ end
---@param icons_by_filename table[] filename "By File Name"
---@param icons_by_file_extension table[] extension "By File Extension"
---@param icons_by_operating_system table[] os "By Operating System"
return function(default_icon, global_override, icons_by_filename, icons_by_file_extension, icons_by_operating_system)
---@param icons_by_desktop_environment table[] os "By Desktop Environment"
---@param icons_by_window_manager table[] os "By Window Manager"
return function(
default_icon,
global_override,
icons_by_filename,
icons_by_file_extension,
icons_by_operating_system,
icons_by_desktop_environment,
icons_by_window_manager
)
-- create a buffer
local bufnr = vim.api.nvim_create_buf(false, true)

Expand All @@ -116,7 +126,9 @@ return function(default_icon, global_override, icons_by_filename, icons_by_file_
end
l = render_icons(bufnr, l, icons_by_filename, "By File Name")
l = render_icons(bufnr, l, icons_by_file_extension, "By File Extension")
render_icons(bufnr, l, icons_by_operating_system, "By Operating System")
l = render_icons(bufnr, l, icons_by_operating_system, "By Operating System")
l = render_icons(bufnr, l, icons_by_desktop_environment, "By Desktop Environment")
render_icons(bufnr, l, icons_by_window_manager, "By Window Manager")

-- finalise and focus the buffer
vim.api.nvim_buf_set_option(bufnr, "modifiable", false)
Expand Down
128 changes: 122 additions & 6 deletions lua/nvim-web-devicons/icons-default.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2171,12 +2171,6 @@ local icons_by_operating_system = {
cterm_color = "38",
name = "Artix",
},
["budgie"] = {
icon = "",
color = "#5195e3",
cterm_color = "68",
name = "Budgie",
},
["centos"] = {
icon = "",
color = "#a2518d",
Expand Down Expand Up @@ -2353,8 +2347,130 @@ local icons_by_operating_system = {
},
}

local icons_by_desktop_environment = {
["budgie"] = {
icon = "",
color = "#4e5361",
cterm_color = "240",
name = "Budgie",
},
["cinnamon"] = {
icon = "",
color = "#dc682e",
cterm_color = "166",
name = "Cinnamon",
},
["gnome"] = {
icon = "",
color = "#ffffff",
cterm_color = "231",
name = "GNOME",
},
["lxde"] = {
icon = "",
color = "#a4a4a4",
cterm_color = "248",
name = "LXDE",
},
["lxqt"] = {
icon = "",
color = "#0191d2",
cterm_color = "32",
name = "LXQt",
},
["mate"] = {
icon = "",
color = "#9bda5c",
cterm_color = "113",
name = "MATE",
},
["plasma"] = {
icon = "",
color = "#1b89f4",
cterm_color = "33",
name = "KDEPlasma",
},
["xfce"] = {
icon = "",
color = "#00aadf",
cterm_color = "74",
name = "Xfce",
},
}

local icons_by_window_manager = {
["awesomewm"] = {
icon = "",
color = "#535d6c",
cterm_color = "59",
name = "awesome",
},
["bspwm"] = {
icon = "",
color = "#4f4f4f",
cterm_color = "239",
name = "BSPWM",
},
["dwm"] = {
icon = "",
color = "#1177aa",
cterm_color = "31",
name = "dwm",
},
["enlightenment"] = {
icon = "",
color = "#ffffff",
cterm_color = "231",
name = "Enlightenment",
},
["fluxbox"] = {
icon = "",
color = "#555555",
cterm_color = "240",
name = "Fluxbox",
},
["hyprland"] = {
icon = "",
color = "#00aaae",
cterm_color = "37",
name = "Hyprland",
},
["i3"] = {
icon = "",
color = "#e8ebee",
cterm_color = "255",
name = "i3",
},
["jwm"] = {
icon = "",
color = "#0078cd",
cterm_color = "32",
name = "JWM",
},
["qtile"] = {
icon = "",
color = "#ffffff",
cterm_color = "231",
name = "Qtile",
},
["sway"] = {
icon = "",
color = "#68751c",
cterm_color = "64",
name = "Sway",
},
["xmonad"] = {
icon = "",
color = "#fd4d5d",
cterm_color = "203",
name = "xmonad",
},
}

return {
icons_by_filename = icons_by_filename,
icons_by_file_extension = icons_by_file_extension,
icons_by_operating_system = icons_by_operating_system,
icons_by_desktop_environment = icons_by_desktop_environment,
icons_by_window_manager = icons_by_window_manager,
}
Loading