-
Notifications
You must be signed in to change notification settings - Fork 0
/
ontop-erlang.el
103 lines (85 loc) · 3.46 KB
/
ontop-erlang.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
;;; ontop-erlang.el --- Erlang configuration -*- lexical-binding: t; -*-
;; This file is part of Emacs ONTOP
;; https://github.com/monkeyjunglejuice/emacs.ontop
;;; Commentary:
;; You can also use this file/configuration independently from Emacs ONTOP
;; Load it from anywhere via `(load-file "/path/to/ontop-erlang.el")'.
;;; Code:
;; ____________________________________________________________________________
;;; USE-PACKAGE
;; <https://github.com/jwiegley/use-package>
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package nil))
(eval-when-compile
(require 'use-package))
;; ____________________________________________________________________________
;;; ERLANG MODE
;; <https://github.com/erlang/otp/tree/master/lib/tools/emacs>
;; <https://www.erlang.org/doc/apps/tools/erlang_mode_chapter.html>
(use-package erlang
:ensure t)
;; In order to use Tree Sitter, install the tree-sitter binary with your
;; OS package manager. Then install the language grammar via
;; 'M-x treesit-install-language-grammar'
(use-package treesit
:ensure nil
:config
(add-to-list 'treesit-language-source-alist
'(erlang "https://github.com/WhatsApp/tree-sitter-erlang")))
;; ____________________________________________________________________________
;;; LANGUAGE SERVER
;; <https://github.com/joaotavora/eglot/blob/master/MANUAL.md>
;; Common keybindings are configured in `./ontop-core.el'
;; . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
;;; ERLANG_LS
;; <https://github.com/erlang-ls/erlang_ls>
(use-package eglot
:ensure t
:custom
;; A longer timeout seems required for the first run in a new project
(eglot-connect-timeout 30) ; default: 30
:config
;; Make sure to adapt the path and use the .bat script for Windows
(add-to-list 'eglot-server-programs
'((erlang-mode) . ("erlang_ls")))
:hook
;; Start language server automatically
(erlang-mode . eglot-ensure)
;; Tell the language server to format the buffer before saving
(erlang-mode . (lambda ()
(add-hook 'before-save-hook
#'eglot-format-buffer nil 'local))))
;; ____________________________________________________________________________
;;; PARENTHESIS DISPLAY
;; Rainbow-delimiters color-coding of nested parens is already enabled
;; for all prog-modes in `ontop-core.el'
(use-package rainbow-delimiters
:ensure t
:hook
(erlang-shell-mode . rainbow-delimiters-mode))
;; Make parens styleable, e.g. more or less prominent
;; <https://github.com/tarsius/paren-face>
;; (use-package paren-face
;; :ensure t
;; :hook
;; ((erlang-mode erlang-shell-mode) . paren-face-mode))
;; ____________________________________________________________________________
;;; ORG-MODE BABEL
;; <https://org-babel.readthedocs.io/en/latest/eval/>
;; Notebook-like literate programming in Emacs
;; Evaluate Erlang code in Org source code blocks via "C-c C-c"
;; Only available from Github, therefore not installed
;; <https://github.com/xfwduke/ob-erlang>
;; (use-package ob-erlang
;; :ensure t)
;; (use-package org
;; :ensure nil
;; :hook
;; (org-mode . (lambda ()
;; (org-babel-do-load-languages
;; 'org-babel-load-languages
;; (add-to-list 'org-babel-load-languages '(erlang . t))))))
;; _____________________________________________________________________________
(provide 'ontop-erlang)
;;; ontop-erlang.el ends here