jscheid / prettier.el

Prettier code formatting for Emacs.
GNU General Public License v3.0
164 stars 11 forks source link

Problem w/ vue-mode, lsp-mode & global-prettier-mode #49

Closed claytonrcarter closed 3 years ago

claytonrcarter commented 3 years ago

Describe the bug Thanks for the vue/mmm-mode fix yesterday! Unfortunately, it appears to have introduced a different problem. It appears to be breaking vue-mode when used w/ lsp-mode, but only when started via (global-prettier-mode t)

Link to M-x prettier-info output https://gist.github.com/claytonrcarter/1563171475a5959cc99620f27cbd496f (also includes an init.el and error backtrace)

To Reproduce Using the init.el available in the above gist.

  1. emacs -q --load init.el
  2. Open test-cases/vue-mode/a.original.vue
  3. `M-: (setq debug-on-error t)
  4. M-x vue-mode-reparse

This will generate an error in lsp-buffer-language, which is called by prettier--guess-js-ish. This code was introduced yesterday in 6d787fe998a72d0995d1fcc717734d4a2d51619b.

Expected behavior If you edit the init.el to comment the :config line and uncomment the :hook line, the above steps will correctly reparse the buffer w/o error.

Additional context I noticed this because I noticed that vue-mode/mmm-mode was no longer correctly updating the mode line w/ the correct sub-mode as I moved around, and that syntax highlighting in the submodes was also broken. FWIW, prettier.el and formatting appear to work as expected and are not affected by this. 😄

jscheid commented 3 years ago

Thanks for the comprehensive bug report, it has all the details I needed to track this down quickly.

A fix is merged but for some reason hasn't made it onto MELPA yet. It sounds like you have a good workaround but if you can't wait, you could download and install the tarball from https://github.com/jscheid/prettier.el/actions/runs/363759131

jscheid commented 3 years ago

Landed in 20201115.20

claytonrcarter commented 3 years ago

Thank you, it's working perfectly!