diff --git a/README.md b/README.md index a542b2ad..ec4b5959 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,12 @@ The variant is updated: However, be advised that the plugin using nvim-web-devicons may have cached the icons. +### Case Sensitivity + +Filename icons e.g. `"Dockerfile"` are case insensitively matched. + +Extension icons e.g. `"lua"` are case sensitive. + ### Setup This adds all the highlight groups for the devicons diff --git a/lua/nvim-web-devicons.lua b/lua/nvim-web-devicons.lua index 44cbc7ec..1931d330 100644 --- a/lua/nvim-web-devicons.lua +++ b/lua/nvim-web-devicons.lua @@ -353,6 +353,24 @@ local function get_highlight_ctermfg(icon_data) return nvim_get_hl_by_name(get_highlight_name(icon_data), false).foreground end +---Change all keys in a table to lowercase +---@param t table +local function lowercase_keys(t) + if not t then + return + end + + for k, v in pairs(t) do + if type(k) == "string" then + local lower_k = k:lower() + if lower_k ~= k then + t[lower_k] = v + t[k] = nil + end + end + end +end + local loaded = false function M.has_loaded() @@ -396,6 +414,11 @@ function M.setup(opts) local user_desktop_environment_icons = user_icons.override_by_desktop_environment local user_window_manager_icons = user_icons.override_by_window_manager + -- filename matches are case insensitive + lowercase_keys(icons_by_filename) + lowercase_keys(user_icons.override) + lowercase_keys(user_icons.override_by_filename) + icons = vim.tbl_extend( "force", icons,