~enan/dotfiles

8e49c8758e08f51861a7637ccff2874bc751b42f — Enan Ajmain 1 year, 7 months ago 0189671 master
vim: chelper supports h{,h,pp}/c{,c,pp}
1 files changed, 14 insertions(+), 9 deletions(-)

M .config/nvim/after/autoload/chelper.vim
M .config/nvim/after/autoload/chelper.vim => .config/nvim/after/autoload/chelper.vim +14 -9
@@ 1,12 1,17 @@
function! chelper#SwitchToHeader() abort
    let l:root = expand('%:t:r')
    let l:ext = expand('%:t:e')
  let l:root = expand('%:t:r')
  let l:ext = expand('%:t:e')

    if l:ext ==# 'cpp'
        " exe "e inc/" . l:root . ".h"
        exe "find " . l:root . ".h"
    elseif l:ext ==# 'h' && filereadable('src/'.l:root.'.cpp')
        " exe "e src/" . l:root . ".cpp"
        exe "find " . l:root . ".cpp"
    endif
  let l:header_exts = ['h', 'hh', 'hpp']
  let l:source_exts = ['c', 'cc', 'cpp']

  if index(l:source_exts, l:ext) >=0
    for ext in l:header_exts
      silent! exe "find " . l:root . "." . ext
    endfor
  elseif index(l:header_exts, l:ext) >=0
    for ext in l:source_exts
      silent! exe "find " . l:root . "." . ext
    endfor
  endif
endfunction