Closed o0nd7ots closed 10 months ago
Try this: (setq format-all-formatters '(("Shell" (shfmt "-i" "4" "-ci"))))
I did what you suggested:
(use-package format-all
:diminish
:hook (prog-mode . format-all-mode)
:config
(setq format-all-formatters '(("Shell" (shfmt "-i" "4" "-ci"))))
)
also running describe-variable format-all-formatters
I get
format-all-formatters is a variable defined in ‘format-all.el’.
Its value is (("Shell" shfmt))
Local in buffer count-chars.sh; global value is nil
So I changed the setq
to setq-default
. Now it works fine.
Do you know why normal setq
works that way?
Ah. setq
must have set the buffer-local value.I'm not familiar with use-package
, so I don't know which buffer that would be.
I am not an expert of use-package
usage, but from what I gather :config
contains the code that gets executed after the package gets loaded.
I have swapped it to :init
which executes the code before (regardless of if) the package gets loaded and with setq
I get the same results as with :config
and setq-local
.
I do not know which way of doing it is better. On one hand :config
deffers the code execution, so the memory is cleaner. On the other I stray from using setq-default
for unknown reasons.
Could you weigh in on what solution might be better?
For use-package
my sources are this use-package github issue and this emacs stackexchange thread.
(use-package format-all
;; :commands (format-all-mode)
:defer
:config
(setq my/format-all-formatters '(("Verilog" verible)))
:hook (prog-mode . format-all-mode)
; (format-all-mode . format-all-ensure-formatter)
(format-all-mode . (lambda () (setq format-all-formatters my/format-all-formatters))))
I hope this example makes it clear. only change my/format-all-formatters
list.
I understand what you did there but I do not understand why. What are the benefits of this?
I haven't noticed your use of setq-default
, so my answer is useless, sorry
No problem. Either way thanks for weighing in!
Since I learned the basic syntax but I still have some problems I will be moving this to another issue.
Hello,
I would like to set shfmt as my default shell formatter. I want it to format with four spaces indent and do not have an
~/.editorconfig
file.I tried doing this:
but it does not seem to work.
With the
.editorconfig
it works but I want to keep the config local within emacs.Can anyone help me?