Handle undefined mode && fallback to normal mode highlighting (#47)

This commit is contained in:
Shadman 2021-01-08 09:52:30 +06:00 committed by GitHub
parent 7460fe5aa2
commit 75a9c5c317
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -13,7 +13,12 @@ local function mode()
['t'] = 'TERMINAL',
['s'] = 'SELECT',
}
return mode_map[vim.fn.mode()]
local function get_mode()
local mode_code = vim.api.nvim_get_mode().mode
if mode_map[mode_code] == nil then return mode_code end
return mode_map[mode_code]
end
return get_mode()
end
return mode

View File

@ -49,9 +49,9 @@ function M.format_highlight(is_focused, highlight_group)
elseif mode == 'V-REPLACE' then
highlight_group = highlight_group .. '_replace'
elseif mode == 'SELECT' then
highlight_group = highlight_group .. '_terminal'
highlight_group = highlight_group .. '_visual'
else
highlight_group = highlight_group .. '_' .. mode:lower()
highlight_group = highlight_group .. '_normal'
end
end
highlight_group = highlight_group .. [[#]]