feat(terraform): support terragrunt

This commit is contained in:
Peter Hoeg 2022-04-05 13:42:49 +08:00 committed by Henrik Lissner
parent d8c8f04f2f
commit 4f23a02877

View file

@ -1,18 +1,21 @@
;;; tools/terraform/config.el -*- lexical-binding: t; -*- ;;; tools/terraform/config.el -*- lexical-binding: t; -*-
(defvar +terraform-runner (if (executable-find "terragrunt") "terragrunt" "terraform")
"The default runner - terraform or terragrunt")
(when (featurep! +lsp) (when (featurep! +lsp)
(add-hook 'terraform-mode-local-vars-hook #'lsp! 'append)) (add-hook 'terraform-mode-local-vars-hook #'lsp! 'append))
(after! terraform-mode (after! terraform-mode
(set-docsets! 'terraform-mode "Terraform") (set-docsets! 'terraform-mode "Terraform")
(setq-hook! 'terraform-mode-hook compile-command +terraform-runner)
(map! :map terraform-mode-map (map! :map terraform-mode-map
:localleader :localleader
:desc "terraform apply" "a" (cmd! (compile "terraform apply" t)) :desc "apply" "a" (cmd! (compile (format "%s apply" +terraform-runner) t))
:desc "terraform init" "i" (cmd! (compile "terraform init")) :desc "init" "i" (cmd! (compile (format "%s init" +terraform-runner)))
:desc "terraform plan" "p" (cmd! (compile "terraform plan")))) :desc "plan" "p" (cmd! (compile (format "%s plan" +terraform-runner)))))
(use-package! company-terraform (use-package! company-terraform
:when (featurep! :completion company) :when (featurep! :completion company)