- Notifications
You must be signed in to change notification settings - Fork35
Major mode of Terraform configuration file
License
hcl-emacs/terraform-mode
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Major mode ofTerraform configuration file
You can installterraform-mode.el
fromMELPA bypackage.el
.
- Syntax highlighting
- Indentation
- imenu
- Formatting using
terraform fmt
- Block folding
- easier access to Terraform resource documentation
terraform-mode
sets upoutline-mode
variables for block folding.To useoutline-mode
for block folding, enableoutline-minor-mode
interraform-mode-hook
:
(add-hook'terraform-mode-hook#'outline-minor-mode)
You can useoutline-toggle-children
bound toC-c C-f
to togglevisibility of a block at point.
We also provide functionterraform-toggle-or-indent
whichfolds-or-indents. It is not bound by default, but you can bind it toTAB
or any other key.
Within aresource
or adata
block, typeC-c C-d C-w
to open a newbrowser tab with the resource or data documentation page.
TypeC-c C-d C-c
to kill the URL (i.e. copy it to the clipboard) for the documentation page rather than directly open it in the browser.
You can also typeC-c C-d C-r
to insert a comment containing a link tothis documentation right above the resource or data block.
This feature requires either:
- a
required_provider
declaration in any.tf
file in current directory(seeTerraform doc) - a working
terraform providers
command. This command may require avalid token (at least for AWS).
Indentation size. You need to callrevert-buffer
if you change this value outer of hook such aseval-expression
.
Set tot
to automatically format the buffer on save.
(custom-set-variables '(terraform-indent-level4))
Withuse-package
(use-package terraform-mode;; if using straight;; :straight t;; if using package.el;; :ensure t:custom (terraform-indent-level4):config (defunmy-terraform-mode-init ();; if you want to use outline-minor-mode;; (outline-minor-mode 1) ) (add-hook'terraform-mode-hook'my-terraform-mode-init))
This major-mode inherits from hcl-mode. Most of syntax features, like highlighting, indentation are implemented in hcl-mode.
About
Major mode of Terraform configuration file