From dec9b8e65c842822ae9788e66825e1ab7a043916 Mon Sep 17 00:00:00 2001 From: Thomas Faivre Date: Fri, 19 Jan 2018 12:32:13 +0100 Subject: [PATCH] cursormode: allow custom mode names A new variable named cursormode_mode_func is used to store the function returning the current mode. This allows more customization in the mapping. The default value is the built-in mode function so there is no change in behavior. Add some documentation. Signed-off-by: Thomas Faivre --- autoload/airline/extensions/cursormode.vim | 6 +++++- doc/airline.txt | 20 ++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/autoload/airline/extensions/cursormode.vim b/autoload/airline/extensions/cursormode.vim index e1f227f..3f3f7f1 100644 --- a/autoload/airline/extensions/cursormode.vim +++ b/autoload/airline/extensions/cursormode.vim @@ -40,8 +40,12 @@ endfunction let s:iTerm_escape_template = '\033]Pl%s\033\\' let s:xterm_escape_template = '\033]12;%s\007' +function! s:get_mode() + return call(get(g:, 'cursormode_mode_func', 'mode'), []) +endfunction + function! airline#extensions#cursormode#set(...) - let mode = mode() + let mode = s:get_mode() if mode !=# s:last_mode let s:last_mode = mode call s:set_cursor_color_for(mode) diff --git a/doc/airline.txt b/doc/airline.txt index 10aac90..baba680 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -1035,12 +1035,28 @@ neomake ------------------------------------- *airline-cursormode* cursormode -Displays cursor in different colors depending on the current mode (only works -in terminals iTerm, AppleTerm and xterm) +Built-in extension to displays cursor in different colors depending on the +current mode (only works in terminals iTerm, AppleTerm and xterm) * enable cursormode integration > let g:airline#extensions#cursormode#enabled = 1 +* mode function. Return value is used as key for the color mapping. Default is + |mode()| + `let g:cursormode_mode_func = 'mode'` + +* color mapping. Keys come from `g:cursormode_mode_func` (background value can + be appended) + `let g:cursormode_color_map = {` + `\ "nlight": '#000000',` + `\ "ndark": '#BBBBBB',` + `\ "i": g:airline#themes#{g:airline_theme}#palette.insert.airline_a[1],` + `\ "R": g:airline#themes#{g:airline_theme}#palette.replace.airline_a[1],` + `\ "v": g:airline#themes#{g:airline_theme}#palette.visual.airline_a[1],` + `\ "V": g:airline#themes#{g:airline_theme}#palette.visual.airline_a[1],` + `\ "\": g:airline#themes#{g:airline_theme}#palette.visual.airline_a[1],` + `\ }` + ============================================================================== ADVANCED CUSTOMIZATION *airline-advanced-customization*