-
Notifications
You must be signed in to change notification settings - Fork 3
/
packages.el
131 lines (113 loc) · 3.93 KB
/
packages.el
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
;;; packages.el --- scala-lsp layer packages file for Spacemacs.
;;
;; Copyright (c) 2012-2017 Sylvain Benner & Contributors
;; Copyright (c) 2019 Rodolfo Hansen & Zhe Li <[email protected]>
;;
;; Author: Zhe Li <[email protected]>
;; URL: https://github.com/zheli/layer-scala-lsp
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(defconst scala-lsp-packages
'(
(lsp-scala :require lsp-mode)
counsel-gtags
ggtags
helm-gtags
lsp-ui
noflet
sbt-mode
scala-mode
))
(defun scala-lsp/init-noflet ()
(use-package noflet))
(defun scala-lsp/init-sbt-mode ()
(use-package sbt-mode
:defer t
:config
;; WORKAROUND: https://github.com/ensime/emacs-sbt-mode/issues/31
;; allows using SPACE when in the minibuffer
(substitute-key-definition
'minibuffer-complete-word
'self-insert-command
minibuffer-local-completion-map)
:init (spacemacs/set-leader-keys-for-major-mode 'scala-mode
"b." 'sbt-hydra
"bb" 'sbt-command)))
(defun scala-lsp/init-scala-mode ()
(use-package scala-mode
:defer t
:init
(progn
(dolist (ext '(".cfe" ".cfs" ".si" ".gen" ".lock"))
(add-to-list 'completion-ignored-extensions ext)))
:config
(progn
;; Automatically insert asterisk in a comment when enabled
(defun scala-lsp/newline-and-indent-with-asterisk ()
(interactive)
(newline-and-indent)
(when scala-auto-insert-asterisk-in-comments
(scala-indent:insert-asterisk-on-multiline-comment)))
(evil-define-key 'insert scala-mode-map
(kbd "RET") 'scala-lsp/newline-and-indent-with-asterisk)
;; Automatically replace arrows with unicode ones when enabled
(defconst scala-unicode-arrows-alist
'(("=>" . "⇒")
("->" . "→")
("<-" . "←")))
(defun scala-lsp/replace-arrow-at-point ()
"Replace the arrow before the point (if any) with unicode ones.
An undo boundary is inserted before doing the replacement so that
it can be undone."
(let* ((end (point))
(start (max (- end 2) (point-min)))
(x (buffer-substring start end))
(arrow (assoc x scala-unicode-arrows-alist)))
(when arrow
(undo-boundary)
(backward-delete-char 2)
(insert (cdr arrow)))))
(defun scala-lsp/gt ()
"Insert a `>' to the buffer.
If it's part of a right arrow (`->' or `=>'),replace it with the corresponding
unicode arrow."
(interactive)
(insert ">")
(scala-lsp/replace-arrow-at-point))
(defun scala-lsp/hyphen ()
"Insert a `-' to the buffer.
If it's part of a left arrow (`<-'),replace it with the unicode arrow."
(interactive)
(insert "-")
(scala-lsp/replace-arrow-at-point))
(when scala-use-unicode-arrows
(define-key scala-mode-map
(kbd ">") 'scala-lsp/gt)
(define-key scala-mode-map
(kbd "-") 'scala-lsp/hyphen))
(evil-define-key 'normal scala-mode-map "J" 'spacemacs/scala-join-line)
;; Compatibility with `aggressive-indent'
(setq scala-indent:align-forms t
scala-indent:align-parameters t
scala-indent:default-run-on-strategy
scala-indent:operator-strategy))))
(defun scala-lsp/init-lsp-scala ()
(use-package lsp-scala
:after scala-mode
:demand t
:config
(add-hook 'scala-mode
(lambda ()
(setq-local lsp-prefer-flymake nil)))
:hook (scala-mode . lsp)))
(defun scala-lsp/post-init-lsp-ui()
(add-hook 'lsp-mode-hook 'lsp-ui-mode))
(defun scala-lsp/post-init-ggtags ()
(add-hook 'scala-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))
(defun scala-lsp/post-init-counsel-gtags ()
(spacemacs/counsel-gtags-define-keys-for-mode 'scala-mode))
(defun scala-lsp/post-init-helm-gtags ()
(spacemacs/helm-gtags-define-keys-for-mode 'scala-mode))
;;; packages.el ends here