lang/scala: fix comment continuation #1515
On Doom's modded newline-and-indent.
This commit is contained in:
parent
c3d48e286b
commit
08e125d3d0
3 changed files with 42 additions and 2 deletions
|
@ -117,7 +117,7 @@
|
||||||
(sp-local-pair
|
(sp-local-pair
|
||||||
'(js2-mode typescript-mode rjsx-mode rust-mode c-mode c++-mode objc-mode
|
'(js2-mode typescript-mode rjsx-mode rust-mode c-mode c++-mode objc-mode
|
||||||
csharp-mode java-mode php-mode css-mode scss-mode less-css-mode
|
csharp-mode java-mode php-mode css-mode scss-mode less-css-mode
|
||||||
stylus-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-doc-comment-block "*")))
|
||||||
|
|
35
modules/lang/scala/autoload.el
Normal file
35
modules/lang/scala/autoload.el
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
;;; lang/scala/autoload.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +scala-comment-indent-new-line (&rest _)
|
||||||
|
"Continue the commnt on the current line.
|
||||||
|
|
||||||
|
Meant to be used for `scala-mode's `comment-line-break-function'."
|
||||||
|
(let* ((state (syntax-ppss))
|
||||||
|
(comment-start-pos (nth 8 state)))
|
||||||
|
(save-match-data
|
||||||
|
(cond ((and (integerp (nth 4 state))
|
||||||
|
;; Ensure that we're inside a scaladoc comment
|
||||||
|
(string-match-p "^/\\*\\*?[^\\*]?"
|
||||||
|
(buffer-substring-no-properties
|
||||||
|
comment-start-pos
|
||||||
|
(min (+ comment-start-pos 4)
|
||||||
|
(point-max))))
|
||||||
|
(progn
|
||||||
|
(setq prev-line (buffer-substring-no-properties
|
||||||
|
(line-beginning-position 0)
|
||||||
|
(line-end-position 0)))
|
||||||
|
(or (string-match "^\\s-*\\*" prev-line)
|
||||||
|
(string-match "\\s-*/*" prev-line))))
|
||||||
|
(newline nil t)
|
||||||
|
(indent-according-to-mode)
|
||||||
|
(insert (make-string (max 0 (- (1- (match-end 0))
|
||||||
|
(match-beginning 0)))
|
||||||
|
? )
|
||||||
|
"*")
|
||||||
|
(scala-indent:indent-on-scaladoc-asterisk))
|
||||||
|
((nth 4 state) ; for line comments
|
||||||
|
(call-interactively #'comment-indent-new-line))
|
||||||
|
(t
|
||||||
|
(newline nil t)
|
||||||
|
(indent-according-to-mode))))))
|
|
@ -1,7 +1,12 @@
|
||||||
;;; lang/scala/config.el -*- lexical-binding: t; -*-
|
;;; lang/scala/config.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
(after! scala-mode
|
(after! scala-mode
|
||||||
(setq scala-indent:align-parameters t)
|
(setq scala-indent:align-parameters t
|
||||||
|
;; indent block comments to first asterix, not second
|
||||||
|
scala-indent:use-javadoc-style t)
|
||||||
|
|
||||||
|
(setq-hook! 'scala-mode-hook comment-line-break-function #'+scala-comment-indent-new-line)
|
||||||
|
|
||||||
(after! dtrt-indent
|
(after! dtrt-indent
|
||||||
(add-to-list 'dtrt-indent-hook-mapping-list '(scala-mode c/c++/java scala-indent:step))))
|
(add-to-list 'dtrt-indent-hook-mapping-list '(scala-mode c/c++/java scala-indent:step))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue