{"id":13773115,"url":"https://github.com/pearofducks/ansible-vim","last_synced_at":"2025-05-16T10:07:15.290Z","repository":{"id":2008064,"uuid":"42228479","full_name":"pearofducks/ansible-vim","owner":"pearofducks","description":"A vim plugin for syntax highlighting Ansible's common filetypes","archived":false,"fork":false,"pushed_at":"2024-06-08T04:44:56.000Z","size":88,"stargazers_count":805,"open_issues_count":6,"forks_count":98,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-04-09T04:06:58.175Z","etag":null,"topics":["ansible","vim-plugin"],"latest_commit_sha":null,"homepage":"","language":"Vim Script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pearofducks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-09-10T07:06:58.000Z","updated_at":"2025-04-06T09:20:07.000Z","dependencies_parsed_at":"2024-01-15T04:05:41.342Z","dependency_job_id":"36971231-2644-43fc-a1e3-c7337eff9dea","html_url":"https://github.com/pearofducks/ansible-vim","commit_stats":{"total_commits":82,"total_committers":39,"mean_commits":"2.1025641025641026","dds":0.5487804878048781,"last_synced_commit":"93798e8c89c441d29d4678da0c0d5e1429eb43b0"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pearofducks%2Fansible-vim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pearofducks%2Fansible-vim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pearofducks%2Fansible-vim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pearofducks%2Fansible-vim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pearofducks","download_url":"https://codeload.github.com/pearofducks/ansible-vim/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254509476,"owners_count":22082891,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","vim-plugin"],"created_at":"2024-08-03T17:01:11.572Z","updated_at":"2025-05-16T10:07:10.278Z","avatar_url":"https://github.com/pearofducks.png","language":"Vim Script","funding_links":[],"categories":["Tools","vim Things","Vim Script","Recently Updated","Editor and IDE Integrations"],"sub_categories":["Syntax Highlighting","[Dec 16, 2024](/content/2024/12/16/README.md)","French"],"readme":"## introduction\n\nThis is a vim syntax plugin for Ansible 2.x, it supports YAML playbooks, Jinja2 templates, and Ansible's `hosts` files.\n\n- YAML playbooks are detected if:\n  - they are in the `group_vars` or `host_vars` folder\n  - they are in the `tasks`, `roles`, or `handlers` folder and have either a *.yml* or *.yaml* suffix\n  - they are named `playbook.y(a)ml`, `site.y(a)ml`, or `main.y(a)ml`\n- Jinja2 templates are detected if they have a *.j2* suffix\n- Files named `hosts` will be treated as Ansible hosts files\n\nYou can also set the filetype to `yaml.ansible`, `*.jinja2`, or `ansible_hosts` if auto-detection does not work (e.g. `:set ft=yaml.ansible` or `:set ft=ruby.jinja2`). **Note**: If you want to detect a custom pattern of your own, you can easily add this in your `.vimrc` using something like this:\n\n```vim\nau BufRead,BufNewFile */playbooks/*.yml set filetype=yaml.ansible\n```\n\nIf you want to override the default file type detection you can easily do this in your `.vimrc`. For example if you use YAML syntax for `hosts` include something like this:\n\n```vim\naugroup ansible_vim_fthosts\n  autocmd!\n  autocmd BufNewFile,BufRead hosts setfiletype yaml.ansible\naugroup END\n```\n\nThis plugin should be quite reliable, as it sources the original formats and simply modifies the highlights as appropriate. This also enables a focus on simplicity and configurability instead of patching bad syntax detection.\n\n##### examples (with [solarized](https://github.com/altercation/vim-colors-solarized) colorscheme)\n\nBright (and selective highlight)     |  Dim\n:-----------------------------------:|:-------------------------:\n![](http://i.imgur.com/whBOZZK.png)  |  ![](http://i.imgur.com/XS0T00e.png)\n\n##### installation\n\nUse your favorite plugin manager, or try [vim-plug](https://github.com/junegunn/vim-plug) if you're looking for a really nice one!\n\n**vim-plug:** `Plug 'pearofducks/ansible-vim'`\n\n**vim-plug with post-update hook:** `Plug 'pearofducks/ansible-vim', { 'do':\n'./UltiSnips/generate.sh' }`\n\n*Note: Because of Ansible API changes, `generate.sh` may require the latest (or near-latest) version of Ansible.*\n\n*Note2: `generate.sh` can receive some parameters, for more info see its [Readme](https://github.com/pearofducks/ansible-vim/tree/master/UltiSnips#script-parameters)*\n\n**vundle:** `Plugin 'pearofducks/ansible-vim'`\n\n**pathogen:** `git clone https://github.com/pearofducks/ansible-vim ~/.vim/bundle/ansible-vim`\n\n**Arch Linux:** Package [vim-ansible](https://www.archlinux.org/packages/community/any/vim-ansible/) is available in the *community* repository.\n\n**Fedora:** The [vim-ansible](https://src.fedoraproject.org/rpms/vim-ansible) package is available in the default repository.\n\n**RHEL/CentOS:** The [vim-ansible](https://src.fedoraproject.org/rpms/vim-ansible) package is available in the [EPEL](https://fedoraproject.org/wiki/EPEL) repository.\n\n## options\n\n##### g:ansible_unindent_after_newline\n\n`let g:ansible_unindent_after_newline = 1`\n\nWhen this variable is set, indentation will completely reset (unindent to column 0) after two newlines in insert-mode. The normal behavior of YAML is to always keep the previous indentation, even across multiple newlines with no content.\n\n##### g:ansible_yamlKeyName\n\n`let g:ansible_yamlKeyName = 'yamlKey'`\n\nThis option exists to provide additional compatibility with [stephpy/vim-yaml](https://github.com/stephpy/vim-yaml).\n\n##### g:ansible_attribute_highlight\n`let g:ansible_attribute_highlight = \"ob\"`\n\nAnsible modules use a `key=value` format for specifying module-attributes in playbooks. This highlights those as specified. This highlight option is also used when highlighting key/value pairs in `hosts` files.\n\nAvailable flags (bold are defaults):\n\n- **a**: highlight *all* instances of `key=`\n- o: highlight *only* instances of `key=` found on newlines\n- **d**: *dim* the instances of `key=` found\n- b: *brighten* the instances of `key=` found\n- n: turn this highlight off completely\n\n##### g:ansible_name_highlight\n`let g:ansible_name_highlight = 'd'`\n\nAnsible modules commonly start with a `name:` key for self-documentation of playbooks. This option enables/changes highlight of this.\n\nAvailable flags (this feature is off by default):\n\n- d: *dim* the instances of `name:` found\n- b: *brighten* the instances of `name:` found\n\n##### g:ansible_extra_keywords_highlight\n`let g:ansible_extra_keywords_highlight = 1`\n\n*Note:* This option is enabled when set, and disabled when not set.\n\nHighlight the following additional keywords: `become become_exe become_flags become_method become_user become_pass prompt_l10n debugger always_run check_mode diff no_log args tags force_handlers vars vars_files vars_prompt delegate_facts delegate_to any_errors_fatal ignore_errors ignore_unreachable max_fail_percentage connection hosts port remote_user module_defaults environment fact_path gather_facts gather_subset gather_timeout async poll throttle timeout order run_once serial strategy`.\n\nBy default we only highlight: `include include_role include_tasks include_vars import_role import_playbook import_tasks when changed_when failed_when block rescue always notify listen register action local_action post_tasks pre_tasks tasks handlers roles collections` and loop keywords `with_.+`, `loop`, `loop_control`, `until`, `retries`, `delay`.\n\n##### g:ansible_extra_keywords_highlight_group\n`let g:ansible_extra_keywords_highlight_group = 'Statement'`\n\nAccepts any syntax group name from `:help E669` - e.g. _Comment_, _Constant_, _Identifier_\n\n*Note:* Defaults to 'Structure' when not set.\n\n##### g:ansible_fqcn_highlight\n`let g:ansible_fqcn_highlight = 'Constant'`\n\nAccepts any syntax group name from `:help E669` - e.g. _Comment_, _Constant_, _Identifier_\n\n*Note:* Defaults to 'Statement' when not set.\n\n*Note:* The `.` in the FCQN can also be highlighted via a modification to a [Vim syntax internal](https://stackoverflow.com/questions/69781626/how-to-do-syntax-highlighting-for-a-keyword-containing-a-period). This plugin will not do this automatically.\n\n##### g:ansible_normal_keywords_highlight\n`let g:ansible_normal_keywords_highlight = 'Constant'`\n\nAccepts any syntax group name from `:help E669` - e.g. _Comment_, _Constant_, _Identifier_\n\n*Note:* Defaults to 'Statement' when not set.\n\nThis option change the highlight of the following common keywords: `include include_role include_tasks include_vars import_role import_playbook import_tasks when changed_when failed_when block rescue always notify listen register action local_action post_tasks pre_tasks tasks handlers roles collections`.\n\n##### g:ansible_loop_keywords_highlight\n`let g:ansible_loop_keywords_highlight = 'Constant'`\n\nAccepts any syntax group-name from `:help E669` - e.g. _Comment_, _Constant_, _Identifier_\n\n*Note:* Defaults to 'Statement' when not set.\n\nThis option changes the highlight of all `with_.+`, `loop`, `loop_control`, `until`, `retries` and `delay` keywords.\n\n##### g:ansible_template_syntaxes\n`let g:ansible_template_syntaxes = { '*.rb.j2': 'ruby' }`\n\nAccepts a dictionary in the form of `'regex-for-file': 'filetype'`.\n- _regex-for-file_ will receive the full filepath, so directory matching can be done.\n- _filetype_ is the root filetype to be applied, `jinja2` will be automatically appended\n\nAll files ending in `*.j2` that aren't matched will simply get the `jinja2` filetype.\n\n##### g:ansible_ftdetect_filename_regex\n`let g:ansible_ftdetect_filename_regex = '\\v(playbook|site|main|local|requirements)\\.ya?ml$'`\n\nAccepts a regex string that is used to match the filename to determine if the file should use the Ansible filetype\n\nCan be used to avoid clashes with other files that are named the same - e.g. main.yaml used in github workflows by removing `main` from the regex\n\n## goto role under cursor (similar to gf)\n\nThis behavior is not supported out of the box, but you can use [this snippet](https://gist.github.com/mtyurt/3529a999af675a0aff00eb14ab1fdde3) in your vimrc.\n\nYou'll then be able to go to a role's definition with `\u003cleader\u003egr`.\n\n## bugs, suggestions/requests, \u0026 contributions\n\n##### bugs\n\nIt's unlikely that there will be bugs in highlighting that don't exist in the core format. Where appropriate these will be fixed in this plugin, but if the problem is with the original syntax we should probably focus on fixing that instead.\n\nIndenting a full document - e.g with `gg=G` - will not be supported and is not a goal of this plugin (unless someone else develops it!). Please do not file a bug report on this.\n\n##### suggestions/requests\n\nSuggestions for improvements are welcome, pull-requests with completed features even more so. :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpearofducks%2Fansible-vim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpearofducks%2Fansible-vim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpearofducks%2Fansible-vim/lists"}