I've added a control from a tree to it:
___________________
|>. |CMake |ATools|
| . | | |
| . | | |
|> | | |
| . | | |
-------------------
When the file is opened from the tree with the 'o' key, it opens it in the first split and the next corresponding file in the second split.
Tree filter is set to only show CMakeLists.txt, Makefile.am and configure.ac in the directories.
execute pathogen#infect()
syntax on
filetype plugin indent on
" toggle between relate files in dir
function! Alternative(cmd, ...) abort
let f = expand("%:p:gs?\\?/?")
let files = map(copy(get(g:, 'related_files', [])), 'fnamemodify(expand(v:val), ":gs?\\?/?")')
let files = a:0 && a:1 ? reverse(files) : files
let idx = index(map(copy(files), 'f[len(f)-len(v:val)-1:] ==# "/" . v:val'), 1)
if idx == -1
return 'echoerr "No alternative file"'
endif
let path = fnamemodify(expand('%:p:h:gs?\\?/?') . repeat("/..", len(split(files[idx], "/"))-1), ":p")
let files = files[idx+1 : ] + (idx ? files[0 : idx-1] : [])
call filter(files, 'filereadable(path . "/" . v:val)')
call map(files, 'a:cmd . " " . path . "/" . v:val')
return get(files, 0, 'echoerr "No alternative file"')
endfunction
let g:related_files = ['CMakeLists.txt', 'Makefile.am', 'configure.ac']
command! -bang A execute Alternative('edit<bang>')
command! -bang AS execute Alternative('vsplit<bang>')
" split to the right
set splitright
" launch the tree immediately
autocmd VimEnter * NERDTree
autocmd FileType nerdtree nnoremap <buffer> o :only^M :call nerdtree#ui_glue#invokeKeyMap("o")^M :AS^M :wincmd t^M
" filter tree for autotools-CMake porting
let NERDTreeIgnore = ['\(CMakeLists\.txt\|Makefile\.am\|configure\.ac\)\@<!$[[file]]']
Currently it is not adapted for displaying of all three files at once (but looking too much at configure.ac is not too useful anyways).
And one small thing that may be useful is to always display CMakeLists.txt in the left split and Makefile.am in the right regardless of which file was selected in the tree.