From b36d59149614e592cbe11aefeaf0a40d135aae0e Mon Sep 17 00:00:00 2001 From: Dmitry Chumak Date: Thu, 21 Mar 2024 12:09:22 +0300 Subject: [PATCH] [vim] yaml.ansible ftplugin --- vim/ftplugin/yaml.ansible.vim | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 vim/ftplugin/yaml.ansible.vim diff --git a/vim/ftplugin/yaml.ansible.vim b/vim/ftplugin/yaml.ansible.vim new file mode 100644 index 0000000..9a585fd --- /dev/null +++ b/vim/ftplugin/yaml.ansible.vim @@ -0,0 +1,25 @@ +" vim-plug example +"call plug#begin('~/.vim/bundle') +"Plug 'pearofducks/ansible-vim' +"call plug#end() + +let g:ansible_goto_role_paths = './roles,../_common/roles' + +function! FindAnsibleRoleUnderCursor() + echo "test!" + if exists("g:ansible_goto_role_paths") + let l:role_paths = g:ansible_goto_role_paths + else + let l:role_paths = "./roles" + endif + let l:tasks_main = expand("") . "/tasks/main.yml" + let l:found_role_path = findfile(l:tasks_main, l:role_paths) + if l:found_role_path == "" + echo l:tasks_main . " not found" + else + execute "edit " . fnameescape(l:found_role_path) + endif +endfunction + +nnoremap gd :call FindAnsibleRoleUnderCursor() +vnoremap gd :call FindAnsibleRoleUnderCursor()