Skip to content

Commit

Permalink
Merge pull request #23 from mattiaslundberg/more-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuco1 authored Mar 1, 2023
2 parents 1c70095 + 32234b7 commit d2aa5b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ You can install `terraform-mode.el` from [MELPA](https://melpa.org/) by `package
- Syntax highlighting
- Indentation
- imenu
- Formatting using `terraform fmt`


## Customize Variables
Expand All @@ -29,6 +30,10 @@ You can install `terraform-mode.el` from [MELPA](https://melpa.org/) by `package

Indentation size. You need to call `revert-buffer` if you change this value outer of hook such as `eval-expression`.

#### `terraform-format-on-save`(Default `nil`)

Set to `t` to automatically format the buffer on save.

## Sample Configuration

```lisp
Expand Down
9 changes: 8 additions & 1 deletion terraform-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

;; Format the current buffer with terraform-format-buffer. To always
;; format terraform buffers when saving, use:
;; (add-hook 'terraform-mode-hook #'terraform-format-on-save-mode)
;; (setq terraform-format-on-save t)

;;; Code:

Expand All @@ -44,6 +44,11 @@
"The tab width to use when indenting."
:type 'integer)

(defcustom terraform-format-on-save nil
"Format buffer on save"
:type 'boolean
:group 'terraform-mode)

(defface terraform-resource-type-face
'((t :foreground "medium sea green"))
"Face for resource names."
Expand Down Expand Up @@ -231,6 +236,8 @@
"Major mode for editing terraform configuration file"

(setq font-lock-defaults '((terraform-font-lock-keywords)))
(when terraform-format-on-save
(terraform-format-on-save-mode 1))

;; indentation
(make-local-variable 'terraform-indent-level)
Expand Down

0 comments on commit d2aa5b6

Please sign in to comment.