Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion autoload/rocannon.vim
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,15 @@ endfun
" with :RVars

fun! rocannon#OpenAlternate(action, category)
" Action should be one of: split, edit, tabnew
" Action should be one of: split, vsplit, edit, tabnew
" TODO: - should have some smarts about whether matching files names exists,
" and fall back to main.yaml
" - open dir (browser) for files and templates
" NOTE: connecting vars with / to avoid "not a file" message
if index(['split', 'vsplit', 'edit', 'tabnet'], a:action) == -1
echom "Can't open " . a:category . " with g:rocannon_open_action=" . a:action
return
endif
let fname = expand('%:p:t')
let role = expand('%:p:h:h:t') . '/'
"echom 'will look for: roles/' . role . a:category . '/' . fname
Expand Down
2 changes: 1 addition & 1 deletion doc/rocannon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ Related maps are available if you enable them with:
The commands all open new window splits by default. If you would instead like
them to just open the file in the active buffer, or a in new tab, use: >

:let g:rocannon_open_action = 'split' " alternatives: tabnew, edit
:let g:rocannon_open_action = 'split' " alternatives: vsplit, tabnew, edit

Note that the standard bouncing actions will also work. With your cursor on
the `o` you can do |gf| (go to file) or |CTRL-W_F| (go to in split).
Expand Down
18 changes: 9 additions & 9 deletions ftplugin/ansible.vim
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,24 @@ endif
""" Bouncing around (navigation)
if !exists('g:rocannon_open_action')
let g:rocannon_open_action = 'split'
let act = g:rocannon_open_action " shorter for convenience herein
endif
let open_action = g:rocannon_open_action " shorter for convenience herein

"command! AnsVars split %:p:h/../vars/main.yml
command! AnsVars split group_vars/all.yaml

" Inside role
command! RHandler call rocannon#OpenAlternate(act, 'handlers')
command! RVars call rocannon#OpenAlternate(act, 'vars')
command! RPlates call rocannon#OpenAlternate(act, 'templates')
command! RTasks call rocannon#OpenAlternate(act, 'tasks')
command! RFiles call rocannon#OpenAlternate(act, 'files')
command! RDefaults call rocannon#OpenAlternate(act, 'defaults')
command! RMeta call rocannon#OpenAlternate(act, 'meta')
command! RHandler call rocannon#OpenAlternate(open_action, 'handlers')
command! RVars call rocannon#OpenAlternate(open_action, 'vars')
command! RPlates call rocannon#OpenAlternate(open_action, 'templates')
command! RTasks call rocannon#OpenAlternate(open_action, 'tasks')
command! RFiles call rocannon#OpenAlternate(open_action, 'files')
command! RDefaults call rocannon#OpenAlternate(open_action, 'defaults')
command! RMeta call rocannon#OpenAlternate(open_action, 'meta')

" Any complexity means main is just a bunch of includes.
" RM would be nice for "M"ain but "M"eta might be more important
command! RIncludes exe act . expand('%:p:h') . '/main.yaml'
command! RIncludes exe open_action . expand('%:p:h') . '/main.yaml'

" Top level
command! Rglobals split group_vars/all.yaml
Expand Down