-
Notifications
You must be signed in to change notification settings - Fork 0
/
elixir-conf.el
107 lines (89 loc) · 3.18 KB
/
elixir-conf.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
; git clone https://github.com/rrrene/bunt
; cd bunt
; mix archive.build
; mix archive.install
; git clone https://github.com/rrrene/credo
; cd credo
; mix archive.build
; mix archive.install
(font-lock-add-keywords
'elixir-mode
'(("->\\|::\\|,\\||>\\||" . font-lock-keyword-face)
("@\\(\\sw\\|_\\)+" . font-lock-keyword-face)))
(defun iex () (interactive) (alchemist-iex-run))
(defun iex-mix () (interactive) (alchemist-iex-project-run))
(defun elixir:key (map func)
(define-key elixir-mode-map (kbd map) func)
(define-key alchemist-mode-map (kbd map) func))
(defun elixir:config-smartparens ()
(require 'smartparens-elixir))
(defun elixir:config-flycheck ()
(flycheck-mix-setup)
(flycheck-credo-setup)
(flycheck-dialyxir-setup)
)
(defun elixir:compile ()
(interactive)
(let* ((root (file-name-directory (get-closest-pathname "mix.exs")))
(mix-cmd "mix do compile")
(cmd (format "cd %s && %s" root mix-cmd)))
(compile cmd)))
(defun elixir:run-in-repl (command)
(alchemist-iex--send-command (alchemist-iex-process) command))
(defun elixir:reload ()
(interactive)
(elixir:run-in-repl "IEx.Helpers.recompile"))
(defun elixir:iex:key (map func)
(define-key alchemist-iex-mode-map (kbd map) func))
(defun elixir:go-to-iex-buffer ()
(interactive)
(switch-to-buffer-other-frame "*Alchemist-IEx*"))
(defun elixir:switch-to-previous-buffer ()
(interactive)
(switch-to-buffer-other-frame (other-buffer (current-buffer) 1)))
(defun elixir:set-key-bindings ()
(elixir:key "C-c TAB" 'company-complete)
(elixir:key "C-c d" 'alchemist-help-search-at-point)
(elixir:key "C-c SPC" 'helm-company)
(elixir:key "C-c C-c" 'elixir:compile)
(elixir:key "C-c C-r" 'elixir:reload)
(elixir:key "C-x C-e" 'alchemist-iex-send-last-sexp)
(elixir:key "C-c C-z" 'elixir:go-to-iex-buffer)
(elixir:key "C-c C-t t" 'alchemist-mix-test-at-point)
(elixir:key "C-c C-t f" 'alchemist-mix-test-this-buffer)
(elixir:key "C-c C-t a" 'alchemist-mix-test)
(elixir:key "C-c C-t s" 'alchemist-test-toggle-test-report-display)
(elixir:key "C-c M-r" 'iex-mix)
(elixir:key "C-c C-k" 'alchemist-iex-compile-this-buffer)
(elixir:iex:key "C-c C-o" 'alchemist-iex-clear-buffer)
(elixir:iex:key "C-c C-z" 'elixir:switch-to-previous-buffer))
(defun elixir:one-time-config ()
(remove-hook 'elixir-mode-hook 'elixir:one-time-config)
(elixir:set-key-bindings)
(elixir:config-smartparens)
(elixir:config-flycheck)
(fix-alchemist-bugs))
(defun elixir:hook ()
(alchemist-mode 1)
(auto-complete-mode 0)
(company-mode 1)
(smartparens-mode 1)
;(flycheck-mode 1)
;(turn-on-smartparens-strict-mode)
;(rainbow-delimiters-mode 1)
;(flycheck-mode 0) ;; not geting it work for the moment
(yas-minor-mode 1))
(defun elixir:iex:hook ()
(company-mode 1)
(smartparens-mode 1)
;;(rainbow-delimiters-mode 1)
;;(rainbow-identifiers-mode 1)
)
(add-hook 'elixir-mode-hook 'elixir:one-time-config)
(add-hook 'elixir-mode-hook 'elixir:hook)
(add-hook 'alchemist-iex-mode-hook 'elixir:iex:hook)
(defun fix-alchemist-bugs ()
(defun alchemist-utils-empty-string-p (string)
"Return non-nil if STRING is null, blank or whitespace only."
(or (null string)
(string= string ""))))