Improve regexp for detecting Ansible files

Additional path names are now detected.

However, the patterns have also been anchored more tightly, meaning they
are more accurate, so they will match less slop (this may affect certain
edge cases where people unknowingly depended on false-positives, e.g.,
`parasite.yml').

Technical details about regexp changes:
  * Remove unnecessary `.*' at beginning
  * Anchor file names with leading `/' to prevent partial matches
      - (eg., don't match `not-main.yml')
  * Restructure capture groups so that `\\.yml' extension is at very end
  * Support `.yaml' extensions as well
  * Anchor the very end with `$'
This commit is contained in:
Brett Campbell 2019-09-12 15:01:21 -07:00 committed by smile13241324
parent 42296a91df
commit f170c732d7
2 changed files with 4 additions and 2 deletions

View File

@ -1,6 +1,6 @@
#+COMMENT -*- mode: org -*-
This file containes the change log for the next major version of Spacemacs.
This file contains the change log for the next major version of Spacemacs.
Use the following template structure and fill it in with your changes.
When a release will be drafted, the notes will be copied at the top of
@ -1095,6 +1095,8 @@ Other:
- Added support for multiple vault password files, see the layer =README.org=
(thanks to Sylvain Benner)
- Simplified filename matching re (thanks to Anatoli Babenia)
- Added additional YAML paths and refactored =spacemacs--ansible-filename-re=
(thanks to Brett Campbell)
- Fixes:
- Fixed ansible-doc-mode error on ~SPC h d k~
(thanks to Codruț Constantin Gușoi)

View File

@ -19,4 +19,4 @@ If non-nil then encrypted files are automatically decrypted when opened and
;; detect filenames compatible with Ansible's recommended layout.
;; http://docs.ansible.com/playbooks_best_practices.html#directory-layout
(setq spacemacs--ansible-filename-re
".*\\(\\(main\\|site\\|encrypted\\|roles/.+\\)\\.yml\\|group_vars/.+\\|host_vars/.+\\)")
"/\\(main\\|site\\|encrypted\\|\\(\\(roles\\|tasks\\|handlers\\|vars\\|defaults\\|meta\\|group_vars\\|host_vars\\)/.+\\)\\)\\.ya?ml$")