Skip to content

Commit

Permalink
Add shell-scripts-shfmt-args variable
Browse files Browse the repository at this point in the history
This adds a variable to the `shell-scripts` layer to allow passing
arguments through to the `shfmt` package.
  • Loading branch information
Ralph7C2 authored and smile13241324 committed Oct 19, 2022
1 parent b9a52cc commit c821b66
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.develop
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ In org-agenda-mode
- Add ~o~ to link-hint-open-link in woman-mode
***** Shaders
- =shaders= layer has been moved to =gpu= layer.
***** Shell-scripts
- Add variable =shell-scripts-shfmt-args= to pass through arguments to =shfmt= package.
***** Syntax checking
- Key bindings (thanks to Loris Lucido):
- Key binding ~SPC e e~ is now for triggering a syntax check, the old action
Expand Down
4 changes: 4 additions & 0 deletions layers/+lang/shell-scripts/config.el
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ When `lsp' layer is used, defaults to `lsp'.")

(defvar shell-scripts-format-on-save nil
"If non-nil, automatically format code with shfmt on save.")

(defcustom shell-scripts-shfmt-args ()
"Arguments passed to shfmt."
:type '(list string))
5 changes: 4 additions & 1 deletion layers/+lang/shell-scripts/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@
;; therefore bind this function to "==" instead
(if (eq shell-scripts-backend 'lsp)
(spacemacs/set-leader-keys-for-major-mode 'sh-mode "==" 'shfmt-buffer)
(spacemacs/set-leader-keys-for-major-mode 'sh-mode "=" 'shfmt-buffer))))
(spacemacs/set-leader-keys-for-major-mode 'sh-mode "=" 'shfmt-buffer))
:config
(when shell-scripts-shfmt-args
(setq shfmt-arguments shell-scripts-shfmt-args))))

(defun shell-scripts/post-init-ggtags ()
(add-hook 'sh-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))
Expand Down

0 comments on commit c821b66

Please sign in to comment.