help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Need assistance in figuring out what reformats my code on save


From: Steinar Bang
Subject: Need assistance in figuring out what reformats my code on save
Date: Sun, 05 Sep 2021 13:10:52 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (windows-nt)

I am trying to remove the configuration that causes web-mode to reformat
my code when saving, because the formatting breaks in the eslint build
step (because eslint prettier and web-mode disagrees).

I have tried to remove the code which looked like it was doing the
formatting, ie.
  (add-hook 'before-save-hook 'tide-format-before-save)

But even after removing this, and with before-save-hook having the value
nil, reformatting takes place on save.

The reformatting I get are changes to indentation, and are the same
changes I get, when I press TAB on the changed lines.

Are there any other hooks that could be involved?
Is there reformatting on save that don't use hooks?
(I'm assuming it is something in my config but I haven't been able to
determine what)

Thanks!


- Steinar

More detail here: https://github.com/ananthakumaran/tide/discussions/434
Emacs version is 27.1 on mac OS/X.

The web-mode/tide configuration in my .emacs, is:
(when (locate-library "web-mode")
  (defun setup-tide-mode ()
    (interactive)
    (tide-setup)
    (flycheck-mode +1)
    (setq flycheck-check-syntax-automatically '(save mode-enabled))
    (eldoc-mode +1)
    (tide-hl-identifier-mode +1)
    (company-mode +1))

  (setq company-tooltip-align-annotations t)

  ;; formats the buffer before saving
  (add-hook 'before-save-hook 'tide-format-before-save)

  (add-hook 'typescript-mode-hook #'setup-tide-mode)

  (require 'web-mode)
  (add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode))
  (add-hook 'web-mode-hook
            (lambda ()
              (when (string-equal "tsx" (file-name-extension buffer-file-name))
                (setup-tide-mode))))
  (flycheck-add-mode 'typescript-tslint 'web-mode))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]