2017-02-09 21:45:27 +00:00
|
|
|
;;; funcs.el --- Scala Layer functions File for Spacemacs
|
|
|
|
;;
|
2021-03-22 20:11:29 +00:00
|
|
|
;; Copyright (c) 2012-2021 Sylvain Benner & Contributors
|
2017-02-09 21:45:27 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
2019-04-18 09:32:18 +00:00
|
|
|
(autoload 'projectile-project-p "projectile")
|
|
|
|
|
2019-04-26 10:34:11 +00:00
|
|
|
(defun spacemacs//scala-setup-metals ()
|
|
|
|
"Setup LSP metals for Scala."
|
2019-09-22 17:52:28 +00:00
|
|
|
(add-hook 'scala-mode-hook #'lsp))
|
2019-04-26 10:34:11 +00:00
|
|
|
|
2020-04-03 16:00:45 +00:00
|
|
|
(defun spacemacs//scala-setup-dap ()
|
|
|
|
"Setup DAP in metals for Scala."
|
|
|
|
(when (spacemacs//scala-backend-metals-p)
|
|
|
|
(add-hook 'scala-mode-hook #'dap-mode)))
|
|
|
|
|
2021-01-11 18:05:05 +00:00
|
|
|
(defun spacemacs//scala-display-sbt-at-bottom (buffer args)
|
|
|
|
"Display a short buffer in a dedicated window at frame bottom.
|
|
|
|
For use with `sbt:display-buffer-action'."
|
|
|
|
(set-window-dedicated-p
|
|
|
|
(display-buffer-at-bottom buffer (cons '(window-height . 12) args))
|
|
|
|
t))
|
|
|
|
|
2020-04-03 16:00:45 +00:00
|
|
|
(defun spacemacs//scala-setup-treeview ()
|
|
|
|
"Setup lsp-treemacs for Scala."
|
2020-11-16 22:20:10 +00:00
|
|
|
(setq lsp-metals-treeview-show-when-views-received scala-auto-treeview))
|
2020-04-03 16:00:45 +00:00
|
|
|
|
2019-04-26 10:34:11 +00:00
|
|
|
(defun spacemacs//scala-backend-metals-p ()
|
|
|
|
"Return true if the selected backend is metals"
|
|
|
|
(eq scala-backend 'scala-metals))
|
|
|
|
|
2017-02-09 21:45:27 +00:00
|
|
|
(defun spacemacs/scala-join-line ()
|
|
|
|
"Adapt `scala-indent:join-line' to behave more like evil's line join.
|
|
|
|
|
|
|
|
`scala-indent:join-line' acts like the vanilla `join-line',
|
|
|
|
joining the current line with the previous one. The vimmy way is
|
|
|
|
to join the current line with the next.
|
|
|
|
|
|
|
|
Try to move to the subsequent line and then join. Then manually move
|
|
|
|
point to the position of the join."
|
|
|
|
(interactive)
|
|
|
|
(let (join-pos)
|
|
|
|
(save-excursion
|
|
|
|
(goto-char (line-end-position))
|
|
|
|
(unless (eobp)
|
|
|
|
(forward-line)
|
|
|
|
(call-interactively 'scala-indent:join-line)
|
|
|
|
(setq join-pos (point))))
|
|
|
|
|
|
|
|
(when join-pos
|
|
|
|
(goto-char join-pos))))
|