mirror of
https://gitlab.com/dwt1/dotfiles.git
synced 2026-04-23 11:30:23 +10:00
Moving to Doom Emacs!
This commit is contained in:
50
.emacs.d/modules/lang/scala/autoload.el
Normal file
50
.emacs.d/modules/lang/scala/autoload.el
Normal file
@@ -0,0 +1,50 @@
|
||||
;;; lang/scala/autoload.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autoload
|
||||
(defun +scala-comment-indent-new-line (&optional _)
|
||||
"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))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +scala/open-repl ()
|
||||
"Open a scala repl. Uses `run-scala' if in a sbt project."
|
||||
(interactive)
|
||||
(if (and (require 'sbt-mode nil t)
|
||||
(sbt:find-root))
|
||||
(run-scala)
|
||||
(let ((buffer-name "*scala-repl")
|
||||
buffer)
|
||||
(unless (comint-check-proc buffer-name)
|
||||
(setq buffer (make-comint-in-buffer
|
||||
"scala-repl" buffer-name "scala")))
|
||||
(display-buffer buffer)
|
||||
buffer)))
|
||||
24
.emacs.d/modules/lang/scala/config.el
Normal file
24
.emacs.d/modules/lang/scala/config.el
Normal file
@@ -0,0 +1,24 @@
|
||||
;;; lang/scala/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(after! projectile
|
||||
(add-to-list 'projectile-project-root-files "build.sbt"))
|
||||
|
||||
|
||||
;;
|
||||
;;; Packages
|
||||
|
||||
(after! scala-mode
|
||||
(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)
|
||||
|
||||
(when (featurep! +lsp)
|
||||
(add-hook 'scala-mode-local-vars-hook #'lsp!)))
|
||||
|
||||
|
||||
(use-package! sbt-mode
|
||||
:after scala-mode
|
||||
:config (set-repl-handler! 'scala-mode #'+scala/open-repl))
|
||||
9
.emacs.d/modules/lang/scala/doctor.el
Normal file
9
.emacs.d/modules/lang/scala/doctor.el
Normal file
@@ -0,0 +1,9 @@
|
||||
;;; lang/scala/doctor.el -*- lexical-binding: t; -*-
|
||||
|
||||
(assert! (or (not (featurep! +lsp))
|
||||
(featurep! :tools lsp))
|
||||
"This module requires (:tools lsp)")
|
||||
|
||||
(if (and (featurep! +lsp)
|
||||
(not (executable-find "metals-emacs")))
|
||||
(warn! "metals-emacs isn't installed"))
|
||||
5
.emacs.d/modules/lang/scala/packages.el
Normal file
5
.emacs.d/modules/lang/scala/packages.el
Normal file
@@ -0,0 +1,5 @@
|
||||
;; -*- no-byte-compile: t; -*-
|
||||
;;; lang/scala/packages.el
|
||||
|
||||
(package! sbt-mode)
|
||||
(package! scala-mode)
|
||||
Reference in New Issue
Block a user