diff --git a/modules/tools/terraform/config.el b/modules/tools/terraform/config.el index c9567b35f..280de98ef 100644 --- a/modules/tools/terraform/config.el +++ b/modules/tools/terraform/config.el @@ -1,18 +1,21 @@ ;;; 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) (add-hook 'terraform-mode-local-vars-hook #'lsp! 'append)) - (after! terraform-mode (set-docsets! 'terraform-mode "Terraform") + (setq-hook! 'terraform-mode-hook compile-command +terraform-runner) + (map! :map terraform-mode-map :localleader - :desc "terraform apply" "a" (cmd! (compile "terraform apply" t)) - :desc "terraform init" "i" (cmd! (compile "terraform init")) - :desc "terraform plan" "p" (cmd! (compile "terraform plan")))) - + :desc "apply" "a" (cmd! (compile (format "%s apply" +terraform-runner) t)) + :desc "init" "i" (cmd! (compile (format "%s init" +terraform-runner))) + :desc "plan" "p" (cmd! (compile (format "%s plan" +terraform-runner))))) (use-package! company-terraform :when (featurep! :completion company)