From faa15c136c86379e3bcee7fb2051670b9dd5452c Mon Sep 17 00:00:00 2001 From: Mathias Andersson Date: Mon, 28 Jul 2014 23:56:08 +0200 Subject: [PATCH] Added extension for tpope/vim-capslock --- autoload/airline/extensions.vim | 4 ++++ autoload/airline/extensions/capslock.vim | 14 ++++++++++++++ autoload/airline/init.vim | 3 ++- doc/airline.txt | 6 ++++++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 autoload/airline/extensions/capslock.vim diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index c6408d5..6456073 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -211,6 +211,10 @@ function! airline#extensions#load() call airline#extensions#nrrwrgn#init(s:ext) endif + if (get(g:, 'airline#extensions#capslock#enabled', 1) && exists('*CapsLockStatusline')) + call airline#extensions#capslock#init(s:ext) + endif + if !get(g:, 'airline#extensions#disable_rtp_load', 0) " load all other extensions, which are not part of the default distribution. " (autoload/airline/extensions/*.vim outside of our s:script_path). diff --git a/autoload/airline/extensions/capslock.vim b/autoload/airline/extensions/capslock.vim new file mode 100644 index 0000000..689b561 --- /dev/null +++ b/autoload/airline/extensions/capslock.vim @@ -0,0 +1,14 @@ +" MIT License. Copyright (c) 2014 Mathias Andersson. +" vim: et ts=2 sts=2 sw=2 +if !exists('*CapsLockStatusline') + finish +endif + +function! airline#extensions#capslock#status() + return CapsLockStatusline() == '[caps]' ? 'CAPS' : '' +endfunction + +function! airline#extensions#capslock#init(ext) + call airline#parts#define_function('capslock', 'airline#extensions#capslock#status') +endfunction + diff --git a/autoload/airline/init.vim b/autoload/airline/init.vim index a60774d..539f2c4 100644 --- a/autoload/airline/init.vim +++ b/autoload/airline/init.vim @@ -79,6 +79,7 @@ function! airline#init#bootstrap() call airline#parts#define_raw('linenr', '%{g:airline_symbols.linenr}%#__accent_bold#%4l%#__restore__#') call airline#parts#define_function('ffenc', 'airline#parts#ffenc') call airline#parts#define_empty(['hunks', 'branch', 'tagbar', 'syntastic', 'eclim', 'whitespace']) + call airline#parts#define_text('capslock', '') unlet g:airline#init#bootstrapping endfunction @@ -86,7 +87,7 @@ endfunction function! airline#init#sections() let spc = g:airline_symbols.space if !exists('g:airline_section_a') - let g:airline_section_a = airline#section#create_left(['mode', 'paste', 'iminsert']) + let g:airline_section_a = airline#section#create_left(['mode', 'paste', 'capslock', 'iminsert']) endif if !exists('g:airline_section_b') let g:airline_section_b = airline#section#create(['hunks', 'branch']) diff --git a/doc/airline.txt b/doc/airline.txt index 1206a65..d7e88a2 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -502,6 +502,12 @@ NrrwRgn * enable/disable NrrwRgn integration > let g:airline#extensions#nrrwrgn#enabled = 1 +------------------------------------- *airline-capslock* +vim-capslock + +* enable/disable vim-capslock integration > + let g:airline#extensions#capslock#enabled = 1 +< ============================================================================== ADVANCED CUSTOMIZATION *airline-advanced-customization*