fix highlight for files without icons

This commit is contained in:
kiyan42 2020-02-18 18:38:42 +01:00
parent 0c382ebdc0
commit 1a473fb193

View File

@ -122,34 +122,34 @@ local function highlight_line(buffer)
vim.api.nvim_buf_add_highlight(buffer, -1, group, line, from, to) vim.api.nvim_buf_add_highlight(buffer, -1, group, line, from, to)
end end
return function(line, node) return function(line, node)
local text_start = node.depth * 2 + 4 local text_start = node.depth * 2
if node.dir then if node.dir then
if node.name ~= '..' then if node.name ~= '..' then
highlight('LuaTreeFolderIcon', line, 0, text_start) highlight('LuaTreeFolderIcon', line, 0, text_start + 4)
if highlight_git(highlight, node, line, text_start) == false then if highlight_git(highlight, node, line, text_start + 4) == false then
highlight('LuaTreeFolderName', line, text_start, -1) highlight('LuaTreeFolderName', line, text_start + 4, -1)
end end
else else
highlight('LuaTreeFolderName', line, 0, -1) highlight('LuaTreeFolderName', line, 0, -1)
end end
return return
elseif is_special(node.name) == true then elseif is_special(node.name) == true then
highlight('LuaTreeSpecialFile', line, 0, -1) highlight('LuaTreeSpecialFile', line, text_start, -1)
elseif is_executable(node.path .. node.name) then elseif is_executable(node.path .. node.name) then
highlight('LuaTreeExecFile', line, 0, -1) highlight('LuaTreeExecFile', line, text_start, -1)
elseif is_pic(node.path .. node.name) then elseif is_pic(node.path .. node.name) then
highlight('LuaTreeImageFile', line, 0, -1) highlight('LuaTreeImageFile', line, text_start, -1)
else else
for k, v in pairs(HIGHLIGHT_GROUPS) do for k, v in pairs(HIGHLIGHT_GROUPS) do
if string.match(node.name, k) ~= nil then if string.match(node.name, k) ~= nil then
highlight('LuaTree' .. v, line, 0, text_start) highlight('LuaTree' .. v, line, 0, text_start + 4)
highlight_git(highlight, node, line, text_start) highlight_git(highlight, node, line, text_start + 4)
return return
end end
end end
end end
highlight_git(highlight, node, line, text_start - 4) highlight_git(highlight, node, line, text_start)
end end
end end