From 23e20bfadab2e82d4bbbd18c44a51e84d200b4aa Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Fri, 7 May 2021 22:43:00 +0200 Subject: [PATCH] autoload: handle bufnr as string explicitly This is some preparational work for evetually merging the vim9 script feature. Also while at it, remove those nasty `l:` prefixes --- autoload/airline.vim | 68 ++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index bb862d6a..60a4dc05 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -203,66 +203,66 @@ function! airline#check_mode(winnr) let context = s:contexts[a:winnr] if get(w:, 'airline_active', 1) - let l:m = mode(1) - if l:m ==# "i" - let l:mode = ['insert'] - elseif l:m[0] ==# "i" - let l:mode = ['insert'] - elseif l:m ==# "Rv" - let l:mode =['replace'] - elseif l:m[0] ==# "R" - let l:mode = ['replace'] - elseif l:m[0] =~# '\v(v|V||s|S|)' - let l:mode = ['visual'] - elseif l:m ==# "t" - let l:mode = ['terminal'] - elseif l:m[0] ==# "c" - let l:mode = ['commandline'] - elseif l:m ==# "no" " does not work, most likely, Vim does not refresh the statusline in OP mode - let l:mode = ['normal'] - elseif l:m[0:1] ==# 'ni' - let l:mode = ['insert'] - let l:m = 'ni' + let m = mode(1) + if m ==# "i" + let mode = ['insert'] + elseif m[0] ==# "i" + let mode = ['insert'] + elseif m ==# "Rv" + let mode =['replace'] + elseif m[0] ==# "R" + let mode = ['replace'] + elseif m[0] =~# '\v(v|V||s|S|)' + let mode = ['visual'] + elseif m ==# "t" + let mode = ['terminal'] + elseif m[0] ==# "c" + let mode = ['commandline'] + elseif m ==# "no" " does not work, most likely, Vim does not refresh the statusline in OP mode + let mode = ['normal'] + elseif m[0:1] ==# 'ni' + let mode = ['insert'] + let m = 'ni' else - let l:mode = ['normal'] + let mode = ['normal'] endif if exists("*VMInfos") && !empty(VMInfos()) " Vim plugin Multiple Cursors https://github.com/mg979/vim-visual-multi - let l:m = 'multi' + let m = 'multi' endif - if index(['Rv', 'no', 'ni', 'ix', 'ic', 'multi'], l:m) == -1 - let l:m = l:m[0] + if index(['Rv', 'no', 'ni', 'ix', 'ic', 'multi'], m) == -1 + let m = m[0] endif - let w:airline_current_mode = get(g:airline_mode_map, l:m, l:m) + let w:airline_current_mode = get(g:airline_mode_map, m, m) else - let l:mode = ['inactive'] + let mode = ['inactive'] let w:airline_current_mode = get(g:airline_mode_map, '__') endif if g:airline_detect_modified && &modified - call add(l:mode, 'modified') + call add(mode, 'modified') endif if g:airline_detect_paste && &paste - call add(l:mode, 'paste') + call add(mode, 'paste') endif if g:airline_detect_crypt && exists("+key") && !empty(&key) - call add(l:mode, 'crypt') + call add(mode, 'crypt') endif if g:airline_detect_spell && &spell - call add(l:mode, 'spell') + call add(mode, 'spell') endif if &readonly || ! &modifiable - call add(l:mode, 'readonly') + call add(mode, 'readonly') endif - let mode_string = join(l:mode) + let mode_string = join(mode) if get(w:, 'airline_lastmode', '') != mode_string - call airline#highlighter#highlight_modified_inactive(context.bufnr) - call airline#highlighter#highlight(l:mode, context.bufnr) + call airline#highlighter#highlight_modified_inactive(string(context.bufnr)) + call airline#highlighter#highlight(mode, string(context.bufnr)) call airline#util#doautocmd('AirlineModeChanged') let w:airline_lastmode = mode_string endif