From 5c9c6030daace867658ef6f47480881452ae92c5 Mon Sep 17 00:00:00 2001 From: Nic Roland Date: Sun, 1 Nov 2015 01:48:27 +0000 Subject: [PATCH 1/4] @bugfix. If g:rocannon_open_action is overridden, act becomes undefined. --- ftplugin/ansible.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftplugin/ansible.vim b/ftplugin/ansible.vim index c1d36fc..39d7e40 100644 --- a/ftplugin/ansible.vim +++ b/ftplugin/ansible.vim @@ -50,8 +50,8 @@ 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 act = g:rocannon_open_action " shorter for convenience herein "command! AnsVars split %:p:h/../vars/main.yml command! AnsVars split group_vars/all.yaml From 4b5ced05cac1ade0a515c3426aff364e3dcba9ec Mon Sep 17 00:00:00 2001 From: Nic Roland Date: Sun, 1 Nov 2015 01:50:22 +0000 Subject: [PATCH 2/4] Added logic to ensure g:rocannon_open_action value is legit. --- autoload/rocannon.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/autoload/rocannon.vim b/autoload/rocannon.vim index 8eba949..f731fb0 100644 --- a/autoload/rocannon.vim +++ b/autoload/rocannon.vim @@ -81,6 +81,10 @@ fun! rocannon#OpenAlternate(action, category) " 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 From fc975a0c17b00a43c7bc108389441e7dcf1ab953 Mon Sep 17 00:00:00 2001 From: Nic Roland Date: Sun, 1 Nov 2015 01:51:11 +0000 Subject: [PATCH 3/4] Some docs updates. --- autoload/rocannon.vim | 2 +- doc/rocannon.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/rocannon.vim b/autoload/rocannon.vim index f731fb0..bba0925 100644 --- a/autoload/rocannon.vim +++ b/autoload/rocannon.vim @@ -76,7 +76,7 @@ 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 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). From 134c86e5c5b2d7e4a903216605b5ebd20f68a2e1 Mon Sep 17 00:00:00 2001 From: Nic Roland Date: Sun, 1 Nov 2015 01:52:04 +0000 Subject: [PATCH 4/4] Made variable name a little more explicit. act -> open_action. --- ftplugin/ansible.vim | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ftplugin/ansible.vim b/ftplugin/ansible.vim index 39d7e40..08b83fd 100644 --- a/ftplugin/ansible.vim +++ b/ftplugin/ansible.vim @@ -51,23 +51,23 @@ endif if !exists('g:rocannon_open_action') let g:rocannon_open_action = 'split' endif -let act = g:rocannon_open_action " shorter for convenience herein +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