From 3a5a40730af74d8bb2f230f4de4903f1c1616d17 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Tue, 10 Sep 2013 15:37:25 +0000 Subject: [PATCH 1/2] check guard for all extensions. resolves #241. --- autoload/airline/extensions/branch.vim | 12 ++++++++---- autoload/airline/extensions/bufferline.vim | 4 ++++ autoload/airline/extensions/commandt.vim | 4 ++++ autoload/airline/extensions/csv.vim | 4 ++++ autoload/airline/extensions/ctrlp.vim | 4 ++++ autoload/airline/extensions/example.vim | 3 +++ autoload/airline/extensions/hunks.vim | 4 ++++ autoload/airline/extensions/syntastic.vim | 4 ++++ autoload/airline/extensions/tagbar.vim | 4 ++++ autoload/airline/extensions/undotree.vim | 4 ++++ autoload/airline/extensions/unite.vim | 4 ++++ autoload/airline/extensions/virtualenv.vim | 4 ++++ 12 files changed, 51 insertions(+), 4 deletions(-) diff --git a/autoload/airline/extensions/branch.vim b/autoload/airline/extensions/branch.vim index 8a83a31..4edeedd 100644 --- a/autoload/airline/extensions/branch.vim +++ b/autoload/airline/extensions/branch.vim @@ -1,14 +1,18 @@ " MIT License. Copyright (c) 2013 Bailey Ling. " vim: et ts=2 sts=2 sw=2 -let s:empty_message = get(g:, 'airline#extensions#branch#empty_message', - \ get(g:, 'airline_branch_empty_message', '')) -let s:symbol = get(g:, 'airline#extensions#branch#symbol', g:airline_symbols.branch) - let s:has_fugitive = exists('*fugitive#head') let s:has_fugitive_detect = exists('*fugitive#detect') let s:has_lawrencium = exists('*lawrencium#statusline') +if !s:has_fugitive && !s:has_lawrencium + finish +endif + +let s:empty_message = get(g:, 'airline#extensions#branch#empty_message', + \ get(g:, 'airline_branch_empty_message', '')) +let s:symbol = get(g:, 'airline#extensions#branch#symbol', g:airline_symbols.branch) + function! airline#extensions#branch#get_head() let head = '' diff --git a/autoload/airline/extensions/bufferline.vim b/autoload/airline/extensions/bufferline.vim index cc13ec0..cb9e1b3 100644 --- a/autoload/airline/extensions/bufferline.vim +++ b/autoload/airline/extensions/bufferline.vim @@ -1,6 +1,10 @@ " MIT License. Copyright (c) 2013 Bailey Ling. " vim: et ts=2 sts=2 sw=2 +if !exists('*bufferline#get_status_string') + finish +endif + let s:overwrite = get(g:, 'airline#extensions#bufferline#overwrite_variables', 1) function! airline#extensions#bufferline#init(ext) diff --git a/autoload/airline/extensions/commandt.vim b/autoload/airline/extensions/commandt.vim index c1e7890..1353940 100644 --- a/autoload/airline/extensions/commandt.vim +++ b/autoload/airline/extensions/commandt.vim @@ -1,6 +1,10 @@ " MIT License. Copyright (c) 2013 Bailey Ling. " vim: et ts=2 sts=2 sw=2 +if !get(g:, 'command_t_loaded', 0) + finish +endif + function! airline#extensions#commandt#apply(...) if bufname('%') ==# 'GoToFile' call airline#extensions#apply_left_override('CommandT', '') diff --git a/autoload/airline/extensions/csv.vim b/autoload/airline/extensions/csv.vim index 99702d0..e171732 100644 --- a/autoload/airline/extensions/csv.vim +++ b/autoload/airline/extensions/csv.vim @@ -1,6 +1,10 @@ " MIT License. Copyright (c) 2013 Bailey Ling. " vim: et ts=2 sts=2 sw=2 +if !get(g:, 'loaded_csv', 0) + finish +endif + let s:column_display = get(g:, 'airline#extensions#csv#column_display', 'Number') function! airline#extensions#csv#get_column() diff --git a/autoload/airline/extensions/ctrlp.vim b/autoload/airline/extensions/ctrlp.vim index d3a696b..a39c70b 100644 --- a/autoload/airline/extensions/ctrlp.vim +++ b/autoload/airline/extensions/ctrlp.vim @@ -1,6 +1,10 @@ " MIT License. Copyright (c) 2013 Bailey Ling. " vim: et ts=2 sts=2 sw=2 +if !get(g:, 'loaded_ctrlp', 0) + finish +endif + let s:color_template = get(g:, 'airline#extensions#ctrlp#color_template', 'insert') function! airline#extensions#ctrlp#generate_color_map(dark, light, white) diff --git a/autoload/airline/extensions/example.vim b/autoload/airline/extensions/example.vim index 735fbe9..09083dd 100644 --- a/autoload/airline/extensions/example.vim +++ b/autoload/airline/extensions/example.vim @@ -1,6 +1,9 @@ " MIT License. Copyright (c) 2013 Bailey Ling. " vim: et ts=2 sts=2 sw=2 +" we don't actually want this loaded :P +finish + " Extension specific variables can be defined the usual fashion. if !exists('g:airline#extensions#example#number_of_cats') let g:airline#extensions#example#number_of_cats = 42 diff --git a/autoload/airline/extensions/hunks.vim b/autoload/airline/extensions/hunks.vim index 57e0832..73c0e2e 100644 --- a/autoload/airline/extensions/hunks.vim +++ b/autoload/airline/extensions/hunks.vim @@ -1,6 +1,10 @@ " MIT License. Copyright (c) 2013 Bailey Ling. " vim: et ts=2 sts=2 sw=2 +if !get(g:, 'loaded_signify', 0) && !get(g:, 'loaded_gitgutter', 0) + finish +endif + let s:non_zero_only = get(g:, 'airline#extensions#hunks#non_zero_only', 0) let s:hunk_symbols = get(g:, 'airline#extensions#hunks#hunk_symbols', ['+', '~', '-']) diff --git a/autoload/airline/extensions/syntastic.vim b/autoload/airline/extensions/syntastic.vim index a91ec66..4e35f0d 100644 --- a/autoload/airline/extensions/syntastic.vim +++ b/autoload/airline/extensions/syntastic.vim @@ -1,6 +1,10 @@ " MIT License. Copyright (c) 2013 Bailey Ling. " vim: et ts=2 sts=2 sw=2 +if !exists(':SyntasticCheck') + finish +endif + function! airline#extensions#syntastic#get_warnings() let errors = SyntasticStatuslineFlag() if strlen(errors) > 0 diff --git a/autoload/airline/extensions/tagbar.vim b/autoload/airline/extensions/tagbar.vim index 5eb0868..d786abf 100644 --- a/autoload/airline/extensions/tagbar.vim +++ b/autoload/airline/extensions/tagbar.vim @@ -1,6 +1,10 @@ " MIT License. Copyright (c) 2013 Bailey Ling. " vim: et ts=2 sts=2 sw=2 +if !exists(':TagbarToggle') + finish +endif + let s:flags = get(g:, 'airline#extensions#tagbar#flags', '') " Arguments: current, sort, fname diff --git a/autoload/airline/extensions/undotree.vim b/autoload/airline/extensions/undotree.vim index 3de1712..d897f04 100644 --- a/autoload/airline/extensions/undotree.vim +++ b/autoload/airline/extensions/undotree.vim @@ -1,6 +1,10 @@ " MIT License. Copyright (c) 2013 Bailey Ling. " vim: et ts=2 sts=2 sw=2 +if !exists(':UndotreeToggle') + finish +endif + function! airline#extensions#undotree#apply(...) if exists('t:undotree') if &ft == 'undotree' diff --git a/autoload/airline/extensions/unite.vim b/autoload/airline/extensions/unite.vim index 217309c..4db3858 100644 --- a/autoload/airline/extensions/unite.vim +++ b/autoload/airline/extensions/unite.vim @@ -1,6 +1,10 @@ " MIT License. Copyright (c) 2013 Bailey Ling. " vim: et ts=2 sts=2 sw=2 +if !get(g:, 'loaded_unite', 0) + finish +endif + function! airline#extensions#unite#apply(...) if &ft == 'unite' call a:1.add_section('airline_a', ' Unite ') diff --git a/autoload/airline/extensions/virtualenv.vim b/autoload/airline/extensions/virtualenv.vim index 1e7435e..7b564a9 100644 --- a/autoload/airline/extensions/virtualenv.vim +++ b/autoload/airline/extensions/virtualenv.vim @@ -1,6 +1,10 @@ " MIT License. Copyright (c) 2013 Bailey Ling. " vim: et ts=2 sts=2 sw=2 +if !get(g:, 'virtualenv_loaded', 0) + finish +endif + function! airline#extensions#virtualenv#init(ext) call a:ext.add_statusline_func('airline#extensions#virtualenv#apply') endfunction From 2702015544ceec305242a9b1494c33a33397fa48 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Tue, 10 Sep 2013 16:00:31 +0000 Subject: [PATCH 2/2] hide errors (#241). --- autoload/airline/extensions.vim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 54a05a4..ee98617 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -204,7 +204,10 @@ function! airline#extensions#load() if !get(g:, 'airline#extensions#'.name.'#enabled', 1) continue endif - call airline#extensions#{name}#init(s:ext) + try + call airline#extensions#{name}#init(s:ext) + catch + endtry endif endfor endfunction