Skip to content

Commit

Permalink
Merge pull request #89 from jscheid/fix-svelte
Browse files Browse the repository at this point in the history
Fix svelte sub-mode handling
  • Loading branch information
jscheid authored Jun 6, 2021
2 parents a37b710 + c032f5b commit 85c9349
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
7 changes: 5 additions & 2 deletions prettier-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

;; Copyright (c) 2018-present Julian Scheid

;; Package-Requires: ((web-mode "20200501") (elm-mode "20200406") (pug-mode "20180513") (svelte-mode "20200327") (toml-mode "20161107") (solidity-mode "20200418") (vue-mode "20190415") (lsp-mode "20201111") (noflet "20141102") (f "20191110") (json-mode "20190123") (ert-async "0.1"))
;; Package-Requires: ((web-mode "20200501") (elm-mode "20200406") (pug-mode "20180513") (svelte-mode "20210222") (toml-mode "20161107") (solidity-mode "20200418") (vue-mode "20190415") (lsp-mode "20201111") (noflet "20141102") (f "20191110") (json-mode "20190123") (typescript-mode "20201002") (ert-async "0.1"))

;;; Commentary:

Expand All @@ -16,6 +16,8 @@
(require 'noflet)
(require 'thingatpt)
(require 'prettier)
(require 'svelte-mode)
(require 'typescript-mode)

(eval-when-compile
(require 'ert-async))
Expand Down Expand Up @@ -47,7 +49,8 @@
(prettier--eval-file-if-exists "setup.elisp")
(prettier-prettify)
(prettier--eval-file-if-exists "test.elisp")
(buffer-string)))
(buffer-substring-no-properties (point-min)
(point-max))))
(expected
(with-temp-buffer
(insert-file-contents
Expand Down
8 changes: 6 additions & 2 deletions prettier.el
Original file line number Diff line number Diff line change
Expand Up @@ -826,9 +826,10 @@ Additional considerations were:
(lambda (proc event)
(unless (and (eq (process-status proc) 'signal)
(eq (process-exit-status proc) 3))
(message "prettier-process (%s) quit unexpectedly: %s"
(message "prettier-process (%s) quit unexpectedly: %s (%s)"
(process-get proc :server-id)
(string-trim event)))
(string-trim event)
(buffer-string)))
(unless prettier-keep-server-buffer-flag
(kill-buffer (process-buffer proc)))
(remhash node-command prettier-processes)))
Expand Down Expand Up @@ -1382,6 +1383,9 @@ for derived modes.)"
(or (and (fboundp 'mhtml-mode)
(get-text-property (point) 'mhtml-submode)
'mhtml-mode)
(and (fboundp 'svelte-mode)
(get-text-property (point) 'svelte-submode)
'svelte-mode)
(and (boundp 'mmm-primary-mode)
mmm-primary-mode)
major-mode)))))
Expand Down
2 changes: 1 addition & 1 deletion test-cases/svelte-mode/a.original.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script>
<script lang="ts">
let name = "world" ;
</script>

Expand Down
2 changes: 1 addition & 1 deletion test-cases/svelte-mode/a.prettier.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script>
<script lang="ts">
let name = "world";
</script>

Expand Down
7 changes: 7 additions & 0 deletions test-cases/svelte-mode/setup.elisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(progn
;; needed for enabling svelte sub-modes
(font-lock-fontify-buffer)
;; go to typescript section
(goto-char 23)
;; activate sveltse sub-mode at point
(run-hooks 'post-command-hook))

0 comments on commit 85c9349

Please sign in to comment.