-
Notifications
You must be signed in to change notification settings - Fork 0
/
erlang-lsp.el
65 lines (52 loc) · 1.95 KB
/
erlang-lsp.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
;; -*- lisp -*-
;; Define a utility function which either installs a package (if it is
;; missing) or requires it (if it already installed).
(defun package-require (pkg &optional require-name)
"Install a package only if it's not already installed."
(when (not (package-installed-p pkg))
(package-install pkg))
(if require-name
(require require-name)
(require pkg)))
;; Install the official Erlang mode
(package-require 'erlang)
;; Include the Language Server Protocol Clients
(package-require 'lsp-mode)
;; Customize prefix for key-bindings
(setq lsp-keymap-prefix "C-l")
;; Enable LSP for Erlang files
(add-hook 'erlang-mode-hook #'lsp)
;; Require and enable the Yasnippet templating system
(package-require 'yasnippet)
(yas-global-mode t)
;; Enable logging for lsp-mode
(setq lsp-log-io t)
;; Show line and column numbers
(add-hook 'erlang-mode-hook 'linum-mode)
(add-hook 'erlang-mode-hook 'column-number-mode)
;; Enable and configure the LSP UI Package
(package-require 'lsp-ui)
(setq lsp-ui-sideline-enable t)
(setq lsp-ui-doc-enable t)
(setq lsp-ui-doc-position 'bottom)
;; Enable LSP Origami Mode (for folding ranges)
(package-require 'lsp-origami)
(add-hook 'origami-mode-hook #'lsp-origami-mode)
(add-hook 'erlang-mode-hook #'origami-mode)
;; Provide commands to list workspace symbols:
;; - helm-lsp-workspace-symbol
;; - helm-lsp-global-workspace-symbol
(package-install 'helm-lsp)
;; Which-key integration
(package-require 'which-key)
(add-hook 'erlang-mode-hook 'which-key-mode)
(with-eval-after-load 'lsp-mode
(add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration))
;; Always show diagnostics at the bottom, using 1/3 of the available space
(add-to-list 'display-buffer-alist
`(,(rx bos "*Flycheck errors*" eos)
(display-buffer-reuse-window
display-buffer-in-side-window)
(side . bottom)
(reusable-frames . visible)
(window-height . 0.33)))