diff options
Diffstat (limited to 'lua/netrw-icons/init.lua')
| -rw-r--r-- | lua/netrw-icons/init.lua | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/lua/netrw-icons/init.lua b/lua/netrw-icons/init.lua index 9c031ef..0ddc9a8 100644 --- a/lua/netrw-icons/init.lua +++ b/lua/netrw-icons/init.lua @@ -43,7 +43,8 @@ local function get_icon_from_provider(name) local provider = icon_provider.provider; local provider_type = icon_provider.provider_type; if provider_type == "devicons" then - local symbol, hi = provider.get_icon(name, nil, { strict = true, default = M.options.icon_fallback }); + local symbol, hi = provider.get_icon(name, nil, + { strict = true, default = M.options.icon_fallback }); if symbol then return { symbol = symbol .. " ", hi = hi }; end @@ -149,21 +150,24 @@ function M.setup(options) icon_provider = get_icon_provider(M.options.prefer) if not icon_provider then - error("[netrw-icons] No icon provider found"); + error("[netrw-icons] No icon provider found") end - vim.api.nvim_create_autocmd("BufModifiedSet", { - pattern = { "*" }, + vim.api.nvim_create_autocmd("OptionSet", { + pattern = "modified", group = vim.api.nvim_create_augroup("netrw_icons", { clear = false }), - callback = function(args) - if not (vim.bo and vim.bo.filetype == "netrw") then + callback = function() + local buf = vim.api.nvim_get_current_buf() + + if vim.bo[buf].filetype ~= "netrw" then return end - if vim.b.netrw_liststyle == 0 or vim.b.netrw_liststyle == 1 or vim.b.netrw_liststyle == 3 then - draw(args.buf) + local liststyle = vim.b[buf].netrw_liststyle + if liststyle == 0 or liststyle == 1 or liststyle == 3 then + draw(buf) end - end + end, }) end |
