about summary refs log tree commit diff
path: root/configs/shared/emacs/.emacs.d/elpa/evil-collection-20180720.526/evil-collection-alchemist.el
blob: 023cc8acbd7f1babb1caccffec1b81a770e0ba77 (plain) (blame)
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
;;; evil-collection-alchemist.el --- Bindings for `alchemist'. -*- lexical-binding: t -*-

;; Copyright (C) 2017 James Nguyen

;; Author: James Nguyen <james@jojojames.com>
;; Maintainer: James Nguyen <james@jojojames.com>
;; Pierre Neidhardt <ambrevar@gmail.com>
;; URL: https://github.com/emacs-evil/evil-collection
;; Version: 0.0.1
;; Package-Requires: ((emacs "25.1"))
;; Keywords: evil, alchemist, tools

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:
;;; Bindings for `alchemist'.

;;; Code:
(require 'evil-collection)
(require 'alchemist nil t)

(defconst evil-collection-alchemist-maps '(alchemist-compile-mode-map
                                           alchemist-eval-mode-map
                                           alchemist-execute-mode-map
                                           alchemist-message-mode-map
                                           alchemist-help-minor-mode-map
                                           alchemist-macroexpand-mode-map
                                           alchemist-mix-mode-map
                                           alchemist-test-report-mode-map
                                           alchemist-mode-map))


(defun evil-collection-alchemist-setup ()
  "Set up `evil' bindings for `alchemist'."
  (evil-set-initial-state 'alchemist-compile-mode 'normal)
  (evil-set-initial-state 'alchemist-eval-mode 'normal)
  (evil-set-initial-state 'alchemist-execute-mode 'normal)
  (evil-set-initial-state 'alchemist-message-mode 'normal)
  (evil-set-initial-state 'alchemist-help-minor-mode 'normal)
  (evil-set-initial-state 'alchemist-macroexpand-mode 'normal)
  (evil-set-initial-state 'alchemist-refcard-mode 'normal)
  (evil-set-initial-state 'alchemist-mix-mode 'normal)
  (evil-set-initial-state 'alchemist-test-mode 'normal)
  (evil-set-initial-state 'alchemist-test-report-mode 'normal)

  (evil-collection-define-key 'normal 'alchemist-compile-mode-map
    "q" 'quit-window)

  (evil-collection-define-key 'normal 'alchemist-eval-mode-map
    "q" 'quit-window)

  (evil-collection-define-key 'normal 'alchemist-execute-mode-map
    "q" 'quit-window)

  (evil-collection-define-key 'normal 'alchemist-message-mode-map
    "q" 'quit-window)

  (evil-collection-define-key 'normal 'alchemist-help-minor-mode-map
    "q" 'quit-window
    "K" 'alchemist-help-search-at-point
    "m" 'alchemist-help-module
    "s" 'alchemist-help
    "gh" 'alchemist-help-history
    "gd" 'alchemist-goto-definition-at-point
    "g?" 'alchemist-help-minor-mode-key-binding-summary)

  (evil-collection-define-key 'normal 'alchemist-macroexpand-mode-map
    "q" 'quit-window)

  (evil-collection-define-key 'normal 'alchemist-refcard-mode-map
    "gd" 'alchemist-refcard--describe-funtion-at-point
    "g?" 'alchemist-refcard--describe-funtion-at-point
    "q" 'quit-window)

  (evil-collection-define-key 'normal 'alchemist-mix-mode-map
    "q" 'quit-window
    "i" 'alchemist-mix-send-input-to-mix-process
    "gr" 'alchemist-mix-rerun-last-task)

  (evil-collection-define-key 'normal 'alchemist-test-report-mode-map
    "q" 'quit-window
    "t" 'toggle-truncate-lines
    "gr" 'alchemist-mix-rerun-last-test
    "gj" 'alchemist-test-next-result
    "gk" 'alchemist-test-previous-result
    (kbd "C-j") 'alchemist-test-next-result
    (kbd "C-k") 'alchemist-test-previous-result
    "]" 'alchemist-test-next-stacktrace-file
    "[" 'alchemist-test-previous-stacktrace-file
    (kbd "C-c C-k") 'alchemist-report-interrupt-current-process)

  (evil-collection-define-key 'normal 'alchemist-mode-map
    "gz" 'alchemist-iex-run
    "K" 'alchemist-help-search-at-point
    "gd" 'alchemist-goto-definition-at-point
    (kbd "C-t") 'alchemist-goto-jump-back
    "g?" 'alchemist-help
    (kbd "C-j") 'alchemist-goto-jump-to-next-def-symbol
    (kbd "C-k") 'alchemist-goto-jump-to-previous-def-symbol))

(provide 'evil-collection-alchemist)
;;; evil-collection-alchemist.el ends here