prettier / prettier-emacs

Minor mode to format JS code on file save

Home Page:http://jlongster.com/A-Prettier-Formatter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Highlighting "flickering" while applying formatting

jonkri opened this issue · comments

Under some circumstances, lines lose their syntax highlighting for a while when formatting is applied.

The attached image illustrates it.

demo

I would like for the text not to temporarily turn to the foreground color.

prettier mode needs to request re-highlighting after changing the buffer. If you execute: M-x web-mode when highlights are broken, it will fix the highlights. To do this automatically after prettier does its thing:

(eval-after-load 'web-mode
    '(progn
       (add-hook 'web-mode-hook #'add-node-modules-path)
       (add-hook 'after-save-hook #'web-mode)
       (add-hook 'web-mode-hook #'prettier-js-mode)))

@keithgabryelski:

Thanks for your suggestion, but my problem isn't that the highlight becames broken in a way that the code snippet above fixes. My problem is the "flickering". For a fraction of a second, all the text turns to the foreground color (after which the syntax highlighting is restored automatically, with or without the code snippet that you posted). I would like to avoid this "flickering", if possible, so that the code is always rendered using the correct syntax highlighting, during all milliseconds. 🙂

I hope that clarifies my problem!