Print warning when git state is not recognized.

This commit is contained in:
Kristijan Husak 2020-08-06 11:48:00 +02:00 committed by Kiyan Yazdani
parent 9cad30f1be
commit 62846b1e31
2 changed files with 16 additions and 1 deletions

View File

@ -1,5 +1,6 @@
local colors = require'lib.colors'
local config = require'lib.config'
local utils = require'lib.utils'
local api = vim.api
@ -81,6 +82,7 @@ if vim.g.lua_tree_git_hl == 1 then
local icons = git_hl[git_status]
if icons == nil then
utils.echo_warning('Unrecognized git state "'..git_status..'". Please open up an issue on https://github.com/kyazdani42/nvim-tree.lua/issues with this message.')
icons = git_hl.dirty
end
@ -119,7 +121,13 @@ if icon_state.show_git_icon then
if not git_status then return "" end
local icon = ""
local icons = git_icon_state[git_status] or git_icon_state.dirty
local icons = git_icon_state[git_status]
if not icons then
if vim.g.lua_tree_git_hl ~= 1 then
utils.echo_warning('Unrecognized git state "'..git_status..'". Please open up an issue on https://github.com/kyazdani42/nvim-tree.lua/issues with this message.')
end
icons = git_icon_state.dirty
end
for _, v in ipairs(icons) do
table.insert(hl, { v.hl, line, depth+icon_len+#icon, depth+icon_len+#icon+#v.icon })
icon = icon..v.icon.." "

View File

@ -1,7 +1,14 @@
local M = {}
local api = vim.api
function M.path_to_matching_str(path)
return path:gsub('(%-)', '(%%-)'):gsub('(%.)', '(%%.)'):gsub('(%_)', '(%%_)')
end
function M.echo_warning(msg)
api.nvim_command('echohl WarningMsg')
api.nvim_command("echom '[LuaTree] "..msg:gsub("'", "''").."'")
api.nvim_command('echohl None')
end
return M