Fix C-style doc comment pair expansion
Some major modes rely on external parsers for correct indentation, like js2-mode or enh-ruby-mode. They don't properly indent the closing comment pair (*/), so we do it manually.
This commit is contained in:
parent
d3fd9f3754
commit
ceb06e1948
1 changed files with 10 additions and 2 deletions
|
@ -64,12 +64,20 @@
|
|||
(sp-local-pair (append sp--html-modes '(markdown-mode gfm-mode))
|
||||
"<!--" "-->" :actions '(insert) :post-handlers '(("| " "SPC")))
|
||||
|
||||
;; Expand C-style doc comment blocks
|
||||
(defun +default-expand-doc-comment-block (&rest _ignored)
|
||||
(let ((indent (current-indentation)))
|
||||
(newline-and-indent)
|
||||
(save-excursion
|
||||
(newline)
|
||||
(insert (make-string indent 32) " */")
|
||||
(delete-char 2))))
|
||||
(sp-local-pair
|
||||
'(js2-mode typescript-mode rjsx-mode rust-mode c-mode c++-mode objc-mode
|
||||
java-mode php-mode css-mode scss-mode less-css-mode stylus-mode)
|
||||
java-mode php-mode css-mode scss-mode less-css-mode stylus-mode)
|
||||
"/*" "*/"
|
||||
:actions '(insert)
|
||||
:post-handlers '(("| " "SPC") ("|\n*/[i][d-2]" "RET") ("\n* ||\n*/[i][d-2]" "*")))
|
||||
:post-handlers '(("| " "SPC") ("|\n*/[i][d-2]" "RET") (+default-expand-doc-comment-block "*")))
|
||||
|
||||
;; Highjacks backspace to:
|
||||
;; a) balance spaces inside brackets/parentheses ( | ) -> (|)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue