From 72a19ed9edb252b685dcf14fe0724d37756cab65 Mon Sep 17 00:00:00 2001 From: Carlo Delle Donne Date: Fri, 17 Jul 2020 15:14:40 +0200 Subject: [PATCH] Add support for cdelledonne/vim-cmake --- CHANGELOG.md | 1 + README.md | 4 ++++ autoload/airline/extensions.vim | 6 +++++ autoload/airline/extensions/vimcmake.vim | 30 ++++++++++++++++++++++++ doc/airline.txt | 6 +++++ 5 files changed, 47 insertions(+) create mode 100644 autoload/airline/extensions/vimcmake.vim diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d0fbef5..620a04a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ This is the Changelog for the vim-airline project. - [OmniSharp](https://github.com/OmniSharp/omnisharp-vim) support - [searchcount](https://vim-jp.org/vimdoc-en/eval.html#searchcount()) support - [fern.vim](https://github.com/lambdalisue/fern.vim) support + - [Vim-CMake](https://github.com/cdelledonne/vim-cmake) support - Improvements - git branch can also be displayed using [gina.vim](https://github.com/lambdalisue/gina.vim) - coc extensions can also show additional status messages diff --git a/README.md b/README.md index c5d6a168..3e898f0b 100644 --- a/README.md +++ b/README.md @@ -188,6 +188,9 @@ vim-airline integrates with a variety of plugins out of the box. These extensio #### [LanguageClient][57] ![image](https://user-images.githubusercontent.com/9622/45275524-52f45c00-b48b-11e8-8b83-a66240b10747.gif) +#### [Vim-CMake][60] +![image](https://user-images.githubusercontent.com/24732205/87788512-c876a380-c83d-11ea-9ee3-5f639f986a8f.png) + ## Extras vim-airline also supplies some supplementary stand-alone extensions. In addition to the tabline extension mentioned earlier, there is also: @@ -353,3 +356,4 @@ If you are interested in becoming a maintainer (we always welcome more maintaine [57]: https://github.com/autozimu/LanguageClient-neovim [58]: https://github.com/vim-airline/vim-airline/blob/master/LICENSE [59]: https://github.com/neoclide/coc-git +[60]: https://github.com/cdelledonne/vim-cmake diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 3282a826..a801487d 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -181,6 +181,12 @@ function! airline#extensions#load() call add(s:loaded_ext, 'fzf') endif + " Vim-CMake buffers are also terminal buffers, so this must be above term. + if get(g:, 'loaded_cmake', 0) && get(g:, 'airline#extensions#vimcmake#enabled', 1) + call airline#extensions#vimcmake#init(s:ext) + call add(s:loaded_ext, 'vimcmake') + endif + if (has("terminal") || has('nvim')) && \ get(g:, 'airline#extensions#term#enabled', 1) call airline#extensions#term#init(s:ext) diff --git a/autoload/airline/extensions/vimcmake.vim b/autoload/airline/extensions/vimcmake.vim new file mode 100644 index 00000000..f455ea51 --- /dev/null +++ b/autoload/airline/extensions/vimcmake.vim @@ -0,0 +1,30 @@ +" MIT License. Copyright (c) 2013-2020 Bailey Ling et al. +" Plugin: https://github.com/cdelledonne/vim-cmake +" vim: et ts=2 sts=2 sw=2 + +scriptencoding utf-8 + +function! airline#extensions#vimcmake#init(ext) abort + call a:ext.add_statusline_func('airline#extensions#vimcmake#apply') + call a:ext.add_inactive_statusline_func('airline#extensions#vimcmake#inactive_apply') +endfunction + +function! airline#extensions#vimcmake#apply(...) abort + if &filetype ==# 'vimcmake' + let spc = g:airline_symbols.space + call a:1.add_section('airline_a', spc.'CMake'.spc) + call a:1.add_section('airline_b', spc.'%{cmake#statusline#GetBuildInfo(1)}'.spc) + call a:1.add_section('airline_c', spc.'%{cmake#statusline#GetCmdInfo()}'.spc) + return 1 + endif +endfunction + +function! airline#extensions#vimcmake#inactive_apply(...) abort + if getbufvar(a:2.bufnr, '&filetype') ==# 'vimcmake' + let spc = g:airline_symbols.space + call a:1.add_section('airline_a', spc.'[CMake]') + call a:1.add_section('airline_b', spc.'%{cmake#statusline#GetBuildInfo(0)}') + call a:1.add_section('airline_c', spc.'%{cmake#statusline#GetCmdInfo()}') + return 1 + endif +endfunction diff --git a/doc/airline.txt b/doc/airline.txt index 74083871..36fb592e 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -1311,6 +1311,12 @@ vimagit * enable/disable vimagit integration > let g:airline#extensions#vimagit#enabled = 1 < +------------------------------------- *airline-vimcmake* +Vim-CMake + +* enable/disable Vim-CMake integration > + let g:airline#extensions#vimcmake#enabled = 1 +< ------------------------------------- *airline-vimtex* vimtex