Skip to content

Instantly share code, notes, and snippets.

@jasonm23
Created August 16, 2023 09:24
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 jasonm23/b02b1833b0ad15c005288da079f97a37 to your computer and use it in GitHub Desktop.
Save jasonm23/b02b1833b0ad15c005288da079f97a37 to your computer and use it in GitHub Desktop.
Emacs github-actions-mode
;;; github-actions-mode --- Minor mode for github-actions
;;;
;;; Commentary:
;;; Used to add actionlint flycheck checker and github environment var names
;;;
;;; Code:
(require 'flycheck)
(require 'company-dabbrev)
(flycheck-define-checker yaml-actionlint
"A YAML syntax checker using actionlint."
:command ("actionlint" "-oneline" source)
:error-patterns ((error line-start (file-name) ":" line ":" column ": " (message) line-end))
:modes yaml-mode)
(add-to-list 'flycheck-checkers 'yaml-actionlint)
(define-minor-mode github-actions-mode
"Minor mode for GitHub Actions related features."
:init-value nil
:lighter " GH-Actions"
:keymap (let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c C-a c") 'github-actions-dabbrev-expand)
map)
(add-to-list 'company-backends '(company-capf company-dabbrev))
(yaml-actionlint-setup))
(defun yaml-actionlint-setup ()
"Setup actionlint as a Flycheck checker for yaml-mode."
(interactive)
(when (eq major-mode 'yaml-mode)
(flycheck-add-next-checker 'yaml-yamllint 'yaml-actionlint)))
(defvar github-actions-dabbrev-abbrevs
'(("summary" . "$GITHUB_STEP_SUMMARY")
("secrets" . "$GITHUB_SECRETS")))
(provide 'github-actions-mode)
;;; github-actions-mode.el ends here
@jasonm23
Copy link
Author

Just threw this together today and still user testing it before moving it to org:emacsfodder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment