Add dynamic colors

This commit is contained in:
Olivier Roques
2020-12-24 13:41:30 +01:00
parent 7b0dd9a92c
commit 1505322bdd
8 changed files with 250 additions and 95 deletions

View File

@@ -1,5 +1,20 @@
local M = {}
local modes = {
['?'] = {text = '???', color = 'inactive'},
['n'] = {text = 'NORMAL', color = 'normal'},
['c'] = {text = 'COMMAND', color = 'normal'},
['i'] = {text = 'INSERT', color = 'insert'},
['R'] = {text = 'REPLACE', color = 'replace'},
['v'] = {text = 'VISUAL', color = 'visual'},
['V'] = {text = 'V-LINE', color = 'visual'},
[''] = {text = 'V-BLOCK', color = 'visual'},
['s'] = {text = 'SELECT', color = 'visual'},
['S'] = {text = 'S-LINE', color = 'visual'},
[''] = {text = 'S-BLOCK', color = 'visual'},
['t'] = {text = 'TERMINAL', color = 'normal'},
}
function M.echo(hlgroup, msg)
vim.cmd(string.format('echohl %s', hlgroup))
vim.cmd(string.format('echo "[hardline] %s"', msg))
@@ -10,8 +25,17 @@ function M.set_active(active)
vim.api.nvim_win_set_var(0, 'hardline_active', active)
end
function M.is_active()
function M.get_active()
return vim.api.nvim_win_get_var(0, 'hardline_active')
end
function M.is_active()
return M.get_active() == 'active'
end
function M.get_mode()
if not modes[vim.fn.mode()] then return modes['?'] end
return modes[vim.fn.mode()]
end
return M