Fix commenting JS in web-mode
This commit is contained in:
parent
4b8986cac4
commit
1ab9f8b99d
1 changed files with 21 additions and 0 deletions
|
@ -63,6 +63,27 @@
|
||||||
|
|
||||||
(add-to-list 'web-mode-engines-alist '("elixir" . "\\.eex\\'"))
|
(add-to-list 'web-mode-engines-alist '("elixir" . "\\.eex\\'"))
|
||||||
|
|
||||||
|
(let ((types '("javascript" "jsx")))
|
||||||
|
(setq web-mode-comment-formats
|
||||||
|
(cl-remove-if (lambda (item) (member (car item) types))
|
||||||
|
web-mode-comment-formats))
|
||||||
|
(dolist (type types)
|
||||||
|
(push (cons type "//") web-mode-comment-formats)))
|
||||||
|
|
||||||
|
(add-hook! 'web-mode-hook
|
||||||
|
(defun +web--fix-js-comments-h ()
|
||||||
|
"Fix comment handling in `web-mode' for JavaScript."
|
||||||
|
(when (member web-mode-content-type '("javascript" "jsx"))
|
||||||
|
;; For some reason the default is to insert HTML comments even
|
||||||
|
;; in JavaScript.
|
||||||
|
(setq-local comment-start "//")
|
||||||
|
(setq-local comment-end "")
|
||||||
|
;; Needed since otherwise the default value generated by
|
||||||
|
;; `comment-normalize-vars' will key off the syntax and think
|
||||||
|
;; that a single "/" starts a comment, which completely borks
|
||||||
|
;; auto-fill.
|
||||||
|
(setq-local comment-start-skip "// *"))))
|
||||||
|
|
||||||
(map! :map web-mode-map
|
(map! :map web-mode-map
|
||||||
(:localleader
|
(:localleader
|
||||||
:desc "Rehighlight buffer" "h" #'web-mode-buffer-highlight
|
:desc "Rehighlight buffer" "h" #'web-mode-buffer-highlight
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue