ansible项目的ctags

ctags for ansible project

我正在尝试通过 ctags. But it is still not picking the right strings. Bellow are params I am working with. What am I missing? After successful run I expect to have ./.tags file which will contain all of the tasks names. I am using ctags 5.8 from Homebrew 从我的 ansible 项目生成标签。

顺便说一句,我从这里开始 -- http://blog.iany.me/2015/02/ctags-for-ansible/

命令/usr/local/Cellar/ctags/5.8_1/bin/ctags -f .tags --recurse .

./.ctags

--langdef=ansible
--langmap=ansible:.yml.yaml
--regex-ansible=/^[ \t]*-[ \t]*name:[ \t]*([\w\s]+)\n//i
--languages=+ansible

示例任务文件

---
- name: install docker-py
  pip: name=docker-py version=1.7.2
  become: yes

- name: Install tmux
  yum:
    name:   tmux
    state:  present
    update_cache: yes
  become: yes

我不强求ctags。我的目标是为 Atom 编辑器提供符号,我可以用它来快速跳转我的 Ansible 项目。

恢复到链接页面上的示例,使其正常工作。我想我在从 Homebrew 安装 ctags 之前做了不必要的更改

ctags 命令有多种不同的实现方式。

使用 GNU Emacs 提供的 ctags,我取得了以下成功:

ctags --language=none --regex='^[ \t]*-[ \t]*name:[ \t]*\(.*?\)[ \t]*$' *.yml roles/*/tasks/*.yml roles/*/handlers/*.yml

这也适用于 etags

universal-ctags 内置(但不完整)ansible playbook 支持。

[jet@localhost]~/var/ctags% cat foo.yml
---
- name: install docker-py
  pip: name=docker-py version=1.7.2
  become: yes

- name: Install tmux
  yum:
    name:   tmux
    state:  present
    update_cache: yes
  become: yes
[jet@localhost]~/var/ctags% ./ctags --version                
Universal Ctags 0.0.0(5567535e), Copyright (C) 2015 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
  Compiled: Jul 26 2017, 04:24:17
  URL: https://ctags.io/
  Optional compiled features: +wildcards, +regex, +multibyte, +option-directory, +xpath, +json, +interactive, +sandbox, +yaml, +aspell
[jet@localhost]~/var/ctags% ./ctags --fields=+Kl -o - foo.yml
Install tmux    foo.yml /^- name: Install tmux$/;"  play    language:AnsiblePlaybook
install docker-py   foo.yml /^- name: install docker-py$/;" play    language:AnsiblePlaybook