git clone \
https://codeberg.org/mfussenegger/nvim-ansible.git \
~/.config/nvim/pack/plugins/start/nvim-ansibleSmall plugin to make working with Ansible playbooks or roles more convenient:
- Adds
ftdetectpattern to recognize playbooks/roles and setfiletypetoyaml.ansible. - Sets
keywordprgtoansible-docif available - Sets
pathto be able to jump to files usinggfwhich arefiles/next to atasks/role file. - Provides a
run()function to execute playbooks or roles usingansible-playbookoransible localhost -m import_role. See:help ansible
You may want to setup keymaps for the run() function, for example in ftplugin/ansible.lua add:
vim.keymap.set('v', '<leader>te', function() require('ansible').run() end, { buffer = true, silent = true })
vim.keymap.set('n', '<leader>te', ":w<CR> :lua require('ansible').run()<CR>", { buffer = true, silent = true })Best used together with ansible-language-server