diff --git a/autoload/rocannon.vim b/autoload/rocannon.vim index 8eba949..bba0925 100644 --- a/autoload/rocannon.vim +++ b/autoload/rocannon.vim @@ -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 diff --git a/doc/rocannon.txt b/doc/rocannon.txt index c47e503..2b54ba2 100644 --- a/doc/rocannon.txt +++ b/doc/rocannon.txt @@ -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). diff --git a/ftplugin/ansible.vim b/ftplugin/ansible.vim index c1d36fc..08b83fd 100644 --- a/ftplugin/ansible.vim +++ b/ftplugin/ansible.vim @@ -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