我试图通过编辑 scala-mode-indent.el 文件来解决这个问题。它在其他一些情况下会破坏缩进,但至少你不会让所有这些缩进都向前半屏显示。
注释掉这一行:
;; (scala-indentation-from-following)
并修改 scala-indentation-from-preceding:
(defun scala-indentation-from-preceding ()
;; Return suggested indentation based on the preceding part of the
;; current expression. Return nil if indentation cannot be guessed.
(save-excursion
(scala-backward-spaces)
(and
(not (bobp))
(if (eq (char-syntax (char-before)) ?\()
(scala-block-indentation)
(progn
(when (eq (char-before) ?\))
(backward-sexp)
(scala-backward-spaces))
t
;;(scala-looking-at-backward scala-expr-start-re)
))
(if (scala-looking-at-backward scala-expr-start-re)
(+ (current-indentation) scala-mode-indent:step)
(current-indentation)
))))
正如我所说,在那之后它仍然坏掉了。我计划很快写一个更好的支持,也许在一两周内。
编辑:
如果要完全禁用 scala 缩进,请注释掉 scala-mode.el 中的行
;; indent-line-function 'scala-indent-line