From 267b14fc5fc446dd583832ee56fc1a459e713e87 Mon Sep 17 00:00:00 2001 From: kiyan42 Date: Thu, 20 Feb 2020 21:48:16 +0100 Subject: [PATCH] fix coloring without vim-devicons --- README.md | 7 +++---- lua/lib/format.lua | 6 ++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ea9c35b3..b45f2727 100644 --- a/README.md +++ b/README.md @@ -52,10 +52,9 @@ nnoremap n :LuaTreeRefresh ![alt text](.github/tree.png?raw=true "file explorer") ## TODO -- add docs -- fix coloring when no dev icons +- use libuv functions instead of `touch` and `mkdir` in `create_file()` and allow file creation with path like `foo/bar/baz` +- better vim help docs - cd command to move faster accross the fs if needed - quickly find file in the directory structure -- use libuv functions instead of `touch` and `mkdir` in `create_file()` and allow file creation with path like `foo/bar/baz` -- tree should always stay on the left no matter what +- tree should always stay on the side no matter what diff --git a/lua/lib/format.lua b/lua/lib/format.lua index 5696bdff..9bf5ddbc 100644 --- a/lua/lib/format.lua +++ b/lua/lib/format.lua @@ -1,5 +1,7 @@ local api = vim.api +local HAS_DEV_ICONS = api.nvim_call_function('exists', { "*WebDevIconsGetFileTypeSymbol" }) == 1 + local function get_padding(depth) local str = "" @@ -57,7 +59,7 @@ local function dev_icons(pathname, isdir, open) end local function get_icon_func_gen() - if api.nvim_call_function('exists', { "*WebDevIconsGetFileTypeSymbol" }) == 1 then + if HAS_DEV_ICONS then return dev_icons else return default_icons @@ -136,7 +138,7 @@ local function highlight_line(buffer) elseif is_pic(node.path .. node.name) then highlight('LuaTreeImageFile', line, text_start + gitlen, -1) - else + elseif HAS_DEV_ICONS then for k, v in pairs(HIGHLIGHT_GROUPS) do if string.match(node.name, k) ~= nil then text_start = text_start + 4