mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-07-27 16:04:39 +02:00
Added a cmake example
parent
7b0bfe35f2
commit
473eae24bf
@ -122,4 +122,32 @@ endfunction
|
|||||||
call airline#parts#define('linenr', {'function': 'MyLineNumber', 'accents': 'bold'})
|
call airline#parts#define('linenr', {'function': 'MyLineNumber', 'accents': 'bold'})
|
||||||
|
|
||||||
let g:airline_section_z = airline#section#create(['%3p%%: ', 'linenr', ':%3v'])
|
let g:airline_section_z = airline#section#create(['%3p%%: ', 'linenr', ':%3v'])
|
||||||
|
```
|
||||||
|
## Integrate with CMake build system
|
||||||
|
This example adds CMAKE_BUILD_TYPE and a custom defined cmake variable by peeking into the CMakeCache.txt
|
||||||
|
```viml
|
||||||
|
function! CMakeStat()
|
||||||
|
let l:cmake_build_dir = get(g:, 'cmake_build_dir', 'build')
|
||||||
|
let l:build_dir = finddir(l:cmake_build_dir, '.;')
|
||||||
|
|
||||||
|
let l:retstr = ""
|
||||||
|
if l:build_dir != ""
|
||||||
|
if filereadable(build_dir . '/CMakeCache.txt')
|
||||||
|
let cmcache = readfile(build_dir . '/CMakeCache.txt')
|
||||||
|
for line in cmcache
|
||||||
|
if line =~ "CMAKE_BUILD_TYPE"
|
||||||
|
let value = reverse(split(line, '='))[0]
|
||||||
|
let retstr = retstr . value . " "
|
||||||
|
elseif line =~ "RUN_TESTS"
|
||||||
|
let value = reverse(split(line, '='))[0]
|
||||||
|
let retstr = retstr . "T" . value . " "
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
return substitute(retstr, '^\s*\(.\{-}\)\s*$', '\1', '')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call airline#parts#define('cmake', {'function': 'CMakeStat'})
|
||||||
|
let g:airline_section_b = airline#section#create_left(['cmake'])
|
||||||
```
|
```
|
Loading…
x
Reference in New Issue
Block a user