Improve smartparens support for (* *) comment blocks

In tuareg-mode and fsharp-mode
This commit is contained in:
Henrik Lissner 2019-07-09 00:27:23 +02:00
parent 92dd66f736
commit d748fe0cd2
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -98,18 +98,19 @@
;; characters), so just do it ourselves.
(define-key! c++-mode-map "<" nil ">" nil)
;; ...and leave it to smartparens
(sp-with-modes '(c++-mode objc-mode)
(sp-local-pair "<" ">"
(sp-local-pair '(c++-mode objc-mode)
"<" ">"
:when '(+cc-sp-point-is-template-p +cc-sp-point-after-include-p)
:post-handlers '(("| " "SPC"))))
:post-handlers '(("| " "SPC")))
(sp-with-modes '(c-mode c++-mode objc-mode java-mode)
(sp-local-pair "/*!" "*/" :post-handlers '(("||\n[i]" "RET") ("[d-1]< | " "SPC")))))
(sp-local-pair '(c-mode c++-mode objc-mode java-mode)
"/*!" "*/"
:post-handlers '(("||\n[i]" "RET") ("[d-1]< | " "SPC"))))
;; Expand C-style doc comment blocks. Must be done manually because some of
;; these languages use specialized (and deferred) parsers, whose state we
;; can't access while smartparens is doing its thing.
(defun +default-expand-doc-comment-block (&rest _ignored)
(defun +default-expand-asterix-doc-comment-block (&rest _ignored)
(let ((indent (current-indentation)))
(newline-and-indent)
(save-excursion
@ -122,7 +123,17 @@
stylus-mode scala-mode)
"/*" "*/"
:actions '(insert)
:post-handlers '(("| " "SPC") ("|\n*/[i][d-2]" "RET") (+default-expand-doc-comment-block "*")))
:post-handlers '(("| " "SPC")
("|\n*/[i][d-2]" "RET")
(+default-expand-asterix-doc-comment-block "*")))
(after! smartparens-ml
(sp-with-modes '(tuareg-mode fsharp-mode)
(sp-local-pair "(*" "*)" :actions nil)
(sp-local-pair "(*" "*"
:actions '(insert)
:post-handlers '(("| " "SPC") ("|\n[i]*)[d-2]" "RET")))))
;; Highjacks backspace to:
;; a) balance spaces inside brackets/parentheses ( | ) -> (|)