MacでScalaの開発環境をEmacsで構築する方法についてまとめています。
sbt install
sbtをインストールします。
REPLを起動します。
https://scalameta.org/metals/docs/editors/emacs.html
1
2
3
4
5
6
7
8
9
| $ curl -L -o coursier https://git.io/coursier
$ chmod +x coursier\n./coursier bootstrap \
--java-opt -Xss4m \
--java-opt -Xms100m \
--java-opt -Dmetals.client=emacs \
org.scalameta:metals_2.12:0.8.0 \
-r bintray:scalacenter/releases \
-r sonatype:release \
-o /usr/local/bin/metals-emacs -f
|
emacs
Caskファイルを編集
1
2
3
4
5
6
7
8
| (depends-on "scala-mode")
(depends-on "sbt-mode")
(depends-on "lsp-mode")
(depends-on "lsp-treemacs")
(depends-on "lsp-ui")
(depends-on "company-lsp")
(depends-on "helm-lsp")
(depends-on "company-box")
|
EmacsのPackageをインストール
.init.elを編集します。
scala-modeの起動とともにlspが起動します。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
| (use-package scala-mode
:mode "^\w+\\.s\\(cala\\|bt\\)$")
(use-package lsp-mode
:ensure t
:commands lsp
:custom
(lsp-auto-guess-root nil)
:bind (:map lsp-mode-map ("C-c C-f" . lsp-format-buffer))
:hook
((python-mode) . lsp)
(scala-mode . lsp))
(use-package flycheck
:init (global-flycheck-mode))
(use-package lsp-ui
:after lsp-mode
:diminish
:commands lsp-ui-mode
:custom-face
(lsp-ui-doc-background ((t (:background nil))))
(lsp-ui-doc-header ((t (:inherit (font-lock-string-face italic)))))
:bind (:map lsp-ui-mode-map
([remap xref-find-definitions] . lsp-ui-peek-find-definitions)
([remap xref-find-references] . lsp-ui-peek-find-references)
("C-c u" . lsp-ui-imenu))
:custom
(lsp-ui-doc-enable t)
(lsp-ui-doc-header t)
(lsp-ui-doc-include-signature t)
(lsp-ui-doc-position 'top)
(lsp-ui-doc-border (face-foreground 'default))
(lsp-ui-sideline-enable nil)
(lsp-ui-sideline-ignore-duplicate t)
(lsp-ui-sideline-show-code-actions nil)
:config
(setq lsp-ui-doc-use-webkit t)
(defadvice lsp-ui-imenu (after hide-lsp-ui-imenu-mode-line activate)
(setq mode-line-format nil)))
(use-package company-lsp :commands company-lsp)
(use-package helm-lsp :commands helm-lsp-workspace-symbol)
(use-package lsp-treemacs :commands lsp-treemacs-errors-list)
(setq treemacs-space-between-root-nodes nil)
(lsp-treemacs-sync-mode 1)
|