Skip to content

Instantly share code, notes, and snippets.

@jdelStrother
Created May 12, 2022 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdelStrother/f24e4091c4c696c0038f4ec83d781ac9 to your computer and use it in GitHub Desktop.
Save jdelStrother/f24e4091c4c696c0038f4ec83d781ac9 to your computer and use it in GitHub Desktop.
(define-derived-mode cfn-mode yaml-mode
"Cloudformation"
"Cloudformation template mode.")
(add-to-list 'magic-mode-alist
'("\\(---\n\\)?AWSTemplateFormatVersion:" . cfn-mode))
(when (featurep 'flycheck)
(flycheck-define-checker cfn-lint
"AWS CloudFormation linter using cfn-lint.
Install cfn-lint first: pip install cfn-lint
See `https://github.com/aws-cloudformation/cfn-python-lint'."
:command ("cfn-lint" "-f" "parseable" source)
:error-patterns ((warning line-start (file-name) ":" line ":" column
":" (one-or-more digit) ":" (one-or-more digit) ":"
(id "W" (one-or-more digit)) ":" (message) line-end)
(error line-start (file-name) ":" line ":" column
":" (one-or-more digit) ":" (one-or-more digit) ":"
(id "E" (one-or-more digit)) ":" (message) line-end))
:modes (cfn-mode))
(add-to-list 'flycheck-checkers 'cfn-lint)
(add-hook 'cfn-mode-hook 'flycheck-mode))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment