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