fxbois / web-mode

web template editing mode for emacs
https://web-mode.org
GNU General Public License v3.0
1.63k stars 262 forks source link

web-mode-comment-indent-new-line do not indent #1270

Closed ncaq closed 1 year ago

ncaq commented 1 year ago

It seems that web-mode-comment-indent-new-line, which used to work properly, is not working properly.

For now, I checked with .ts and .tsx.

For example, prepare the following code.

function foo() {
}

Now set the cursor position to the end of the first line, inside the opening parenthesis. Then run web-mode-comment-indent-new-line.

The expected result is

function foo() {

}

would be indented with a space.

But now the indentation is not done and the cursor goes to the beginning of the line.

My web-mode related settings are as follows.

(leaf web-mode
  :ensure t
  :mode
  "\\. [agj]sp\'"
  "\\. [cm]? [jt]sx?\\'"
  "\\.as[cp]x\\'"
  "\\.djhtml\'"
  "\\.ejs\'"
  "\\.erb\'"
  "\\.html?\\'"
  "\\.mustache\'"
  "\\.php\'"
  "\\.phtml\'"
  "\\.tpl\'"
  "\\.vue\'"
  ;;; Ensure that web-mode is specified in interpreters where js-mode is specified.
  :interpreter
  `,(seq-filter 'stringp (seq-map (lambda (regex-mode) (pcase regex-mode (`(,regex . js-mode) regex)) interpreter-mode-alist))
  :custom
  (web-mode-enable-auto-indentation . nil))
  (web-mode-enable-auto-quoting . . nil)
  (web-mode-enable-current-column-highlight . . t)
  (web-mode-enable-current-element-highlight . t)
  :custom-face
  (web-mode-jsx-depth-1-face . '((t (:background "#073844"))))
  (web-mode-jsx-depth-2-face . '((t (:background "#083C49"))))
  (web-mode-jsx-depth-3-face . '((t (:background "#08404F"))))
  (web-mode-jsx-depth-4-face . '((t (:background "#094554"))))
  (web-mode-jsx-depth-5-face . '((t (:background "#0A4D5E"))))
  :init
  (defun web-mode-setup ()
    (setq-local lsp-enabled-clients '(ts-ls eslint))
    (lsp)
    (prettier-mode-toggle-setup)))
  :hook (web-mode-hook . web-mode-setup))
  :bind
  (:web-mode-map
   ([remap comment-indent-new-line] . web-mode-comment-indent-new-line)
   ("C-c C-f" . lsp-eslint-apply-all-fixes))
  :defvar web-mode-comment-formats
  :config
  ;;; Change comments from `/*' expressions to `//' format.
  (add-to-list 'web-mode-comment-formats '("javascript" . "//"))
  (add-to-list 'web-mode-comment-formats '("jsx" . "//")))
  (leaf smartparens :config (sp-local-pair 'web-mode "<" ">" :actions nil)))

The complete configuration is available on GitHub.

.emacs.d/init.el at master - ncaq/.emacs.d

I tried to investigate by looking at GitHub for blames and stuff. But GitHub is too slow. I tried to investigate by looking at GitHub, but GitHub was too slow, and I couldn't find any code by searching web-mode-comment-indent-new-line, so I gave up investigating for a while. I have temporarily given up on the investigation.

I will investigate more when it is clear that it is not environment-dependent.