fix: make fname resolution more robust;
This commit is contained in:
parent
d07145eeae
commit
747e7b6222
2 changed files with 16 additions and 7 deletions
|
|
@ -107,7 +107,7 @@ function M.apply()
|
||||||
local function override_tables()
|
local function override_tables()
|
||||||
local by_ext = devicons.get_icons_by_extension()
|
local by_ext = devicons.get_icons_by_extension()
|
||||||
for ext, data in pairs(by_ext) do
|
for ext, data in pairs(by_ext) do
|
||||||
local name = resolve_mod.ext_map[ext]
|
local name = resolve_mod.ext_map[ext] or resolve_mod.ext_map[ext:lower()]
|
||||||
if name then
|
if name then
|
||||||
data.icon = char(name) or fallback_icon
|
data.icon = char(name) or fallback_icon
|
||||||
else
|
else
|
||||||
|
|
@ -117,7 +117,7 @@ function M.apply()
|
||||||
|
|
||||||
local by_filename = devicons.get_icons_by_filename()
|
local by_filename = devicons.get_icons_by_filename()
|
||||||
for fname, data in pairs(by_filename) do
|
for fname, data in pairs(by_filename) do
|
||||||
local name = resolve_mod.filename_map[fname]
|
local name = resolve_mod.filename_map[fname] or resolve_mod.filename_map[fname:lower()]
|
||||||
if name then
|
if name then
|
||||||
data.icon = char(name) or fallback_icon
|
data.icon = char(name) or fallback_icon
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ M.ext_map = {
|
||||||
pm = 'perl',
|
pm = 'perl',
|
||||||
|
|
||||||
r = 'r',
|
r = 'r',
|
||||||
R = 'r',
|
r = 'r',
|
||||||
rmd = 'r',
|
rmd = 'r',
|
||||||
|
|
||||||
scala = 'scala',
|
scala = 'scala',
|
||||||
|
|
@ -121,7 +121,7 @@ M.ext_map = {
|
||||||
tf = 'terraform',
|
tf = 'terraform',
|
||||||
tfvars = 'terraform',
|
tfvars = 'terraform',
|
||||||
|
|
||||||
Dockerfile = 'docker',
|
dockerfile = 'docker',
|
||||||
dockerignore = 'docker',
|
dockerignore = 'docker',
|
||||||
|
|
||||||
angular = 'angular',
|
angular = 'angular',
|
||||||
|
|
@ -443,9 +443,18 @@ function M.resolve_name(name, ext)
|
||||||
if M.filename_map[lower] then
|
if M.filename_map[lower] then
|
||||||
return M.filename_map[lower]
|
return M.filename_map[lower]
|
||||||
end
|
end
|
||||||
local dot_ext = lower:match('%.(.+)$')
|
local last_ext = lower:match('%.([^%.]+)$')
|
||||||
if dot_ext and M.ext_map[dot_ext] then
|
if last_ext and M.ext_map[last_ext] then
|
||||||
return M.ext_map[dot_ext]
|
return M.ext_map[last_ext]
|
||||||
|
end
|
||||||
|
local compound = lower:match('%.(.+)$')
|
||||||
|
if compound and compound ~= last_ext then
|
||||||
|
while compound do
|
||||||
|
if M.ext_map[compound] then
|
||||||
|
return M.ext_map[compound]
|
||||||
|
end
|
||||||
|
compound = compound:match('%.(.+)$')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue