Replies: 3 comments 2 replies
-
;; formats the buffer before saving
(add-hook 'before-save-hook 'tide-format-before-save) Did you restart after commenting out the code? You either need a restart or manually remove the hook using As for aligning the formatting with other tools like prettier, this is something that is best asked to https://github.com/microsoft/TypeScript repo. Tide just passes along the config to tsserver and asks it for formatted text. |
Beta Was this translation helpful? Give feedback.
-
>>>> Anantha Kumaran ***@***.***>:
```elisp
;; formats the buffer before saving
(add-hook 'before-save-hook 'tide-format-before-save)
```
Did you restart after commenting out the code?
Yes, I started an entirely new emacs instance.
You either need a restart or manually remove the hook using `remove-hook` function. To check the current hook list, try `C-h v before-save-hook`.
It was nil in the restarted emacs instance. But still code was
reformatted on save. That's when I got confused.
As for aligning the formatting with other tools like prettier, this is something that is best asked to https://github.com/microsoft/TypeScript repo. Tide just passes along the config to tsserver and asks it for formatted text.
Ok, so tsserver is the place to look?
Thanks!
|
Beta Was this translation helpful? Give feedback.
-
Just FYI I got a debugging tip from Tassilo Horn on the help-gnu-emacs mailing list https://lists.gnu.org/archive/html/help-gnu-emacs/2021-09/msg00059.html I did
in a .tsx buffer in a restarted emacs with nil before-save-hook and I found that the reformatting is done by web-mode-on-post-command and is run immediately after my change, and not just before save. web-mode-on-post-command is run from the post-command-hook, and runs indent-region on the buffer when the command is a yank https://github.com/fxbois/web-mode/blob/master/web-mode.el#L2918 The formatting done by tide-format-before-save is different from the formatting done by indent-region in web-mode-on-post-command, and with tide-format-before-save in place, it's the tide-format-before-save formatting that wins. |
Beta Was this translation helpful? Give feedback.
-
Platform: Mac OSX, emacs 27.1, tide 20210517.507, web-mode-17
I have problems in that when I save, files are autoformatted into something prettier in eslint doesn't accept, and I need help debugging how to align autoformatting with prettier, and failing that: how to switch off autoformatting.
When I save .tsx files, then e.g. this
is turned into this:
My web-mode/tide config in .emacs, is:
My first attempt was to just switch off autoformatting, but I have failed to do so.
I have tried removing the tide-format-before-save setting. But emacs still formatted the file on save.
I then tried removing the flycheck-check-syntax-automatically setting. But emacs still formatted the file on save (it did seem to be worsening the formatting, though...?).
I then tried figuring out how tide picked up the prettier settings, and have found the code that locates the tsfmt.json file (tide-tsfmt-options and tide-project-root) and the top level directory has both an tsconfig.json file and a tsfmt.json.
The contents of the tsfmt.json file, is:
Any ideas as to what I can do...?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions