-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.emacs
143 lines (117 loc) · 4.36 KB
/
.emacs
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
132
133
134
135
136
137
138
139
140
141
142
;; turn on packages
(require 'package)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/"))
(setq package-enable-at-startup nil)
(package-initialize)
;; other requires
(require 'evil)
(require 'evil-leader)
;; enable evil-mode on startup
(evil-mode t)
;; enable evil-leader for all evil-mode buffers
(global-evil-leader-mode)
;; enable linenums globally
(global-linum-mode)
;; enable tildes at end of buffer
(global-vim-empty-lines-mode)
;; show matching parents
(show-paren-mode t)
;; change leader key to ,
(evil-leader/set-leader ",")
;; leader key mappings
(evil-leader/set-key
"y" 'pbcopy
"p" 'pbpaste
"w" 'evil-write
"q" 'evil-quit
"e" 'eshell
"v" 'split-window-right
"h" 'split-window-below)
;; macro for breaking lines in normal mode
(fset 'break-line
[?i ?\C-m escape])
;; macro for inserting newline with enter
(fset 'insert-newline
[?o escape])
;; adding back some vim movement that my hands need
(define-key evil-motion-state-map "H" 'evil-beginning-of-line)
(define-key evil-motion-state-map "L" 'evil-end-of-line)
;; make window movement make sense
;; (when (fboundp 'windmove-default-keybindings)
;; (windmove-default-keybindings))
;; (define-key evil-normal-state-map (kbd "C-h") 'evil-window-left)
;; (define-key evil-normal-state-map (kbd "C-j") 'evil-window-down)
;; (define-key evil-normal-state-map (kbd "C-k") 'evil-window-up)
;; (define-key evil-normal-state-map (kbd "C-l") 'evil-window-right)
(global-set-key (kbd "C-h") 'windmove-left)
(global-set-key (kbd "C-l") 'windmove-right)
(global-set-key (kbd "C-k") 'windmove-up)
(global-set-key (kbd "C-j") 'windmove-down)
;; add normal mode line break
(define-key evil-normal-state-map (kbd "K") 'break-line)
(define-key evil-normal-state-map (kbd "RET") 'insert-newline)
;; adding helm space mappings
(define-key evil-normal-state-map (kbd "<SPC>n") 'helm-find-files)
(define-key evil-normal-state-map (kbd "<SPC>b") 'helm-buffers-list)
;; This gives me an easy set of functions to copy and paste from clipboard
(defun pbcopy ()
(interactive)
(call-process-region (point) (mark) "pbcopy")
(setq deactivate-mark t))
(defun pbpaste ()
(interactive)
(call-process-region (point) (if mark-active (mark) (point)) "pbpaste" t t))
(defun pbcut ()
(interactive)
(pbcopy)
(delete-region (region-beginning) (region-end)))
;; set spacemacs as the theme
(load-theme 'base16-default-dark t)
;; remove menu bar
(menu-bar-mode -1)
;; make scrolling smooth
(setq scroll-margin 1
scroll-conservatively 9999
scroll-step 1)
;; Add a space between line number and text
(setq linum-format "%d ")
;; switch yes/no to y/n
(fset 'yes-or-no-p 'y-or-n-p)
;; esc quits
;; http://juanjoalvarez.net/es/detail/2014/sep/19/vim-emacsevil-chaotic-migration-guide/
(defun minibuffer-keyboard-quit ()
"Abort recursive edit.
In Delete Selection mode, if the mark is active, just deactivate it;
then it takes a second \\[keyboard-quit] to abort the minibuffer."
(interactive)
(if (and delete-selection-mode transient-mark-mode mark-active)
(setq deactivate-mark t)
(when (get-buffer "*Completions*") (delete-windows-on "*Completions*"))
(abort-recursive-edit)))
(define-key evil-normal-state-map [escape] 'keyboard-quit)
(define-key evil-visual-state-map [escape] 'keyboard-quit)
(define-key minibuffer-local-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-ns-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-completion-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-must-match-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-isearch-map [escape] 'minibuffer-keyboard-quit)
(global-set-key [escape] 'evil-exit-emacs-state)
;; helm prefs
;; TODO
;; Figure out how to make ESC quit helm buffer
;; (define-key helm-map (kbd "ESC") 'helm-keyboard-quit)
;; Make it fill current window with completetion reqs
(require 'helm)
(require 'helm-config)
(setq helm-split-window-in-side-p t
helm-move-to-line-cycle-in-source t )
(helm-mode t)
;; Hide passwords in eshell
;; (add-hook 'comint-output-filter-functions
;; 'comint-watch-for-password-prompt)
;; Rainbow parens always
(add-hook 'prog-mode-hook #'rainbow-delimiters-mode)
;; drop into an eshell buffer on startup
(eshell)