-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.emacs
212 lines (174 loc) · 7.26 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
(add-to-list 'load-path "~/.emacs.d/elpa")
(require 'package)
(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
("marmalade" . "https://marmalade-repo.org/packages/")
("melpa" . "https://melpa.org/packages/")
("melpa-stable" . "https://stable.melpa.org/packages/")))
(package-initialize)
; symlinks are neat
(setq vc-follow-symlinks t)
;; evil mode
(require 'evil)
(evil-mode 1)
; don't evil in term mode
(delete 'term-mode evil-insert-state-modes)
(add-to-list 'evil-emacs-state-modes 'term-mode)
; do not treat underscores as word boundaries
(modify-syntax-entry ?_ "w")
; auto-indent is cool
(electric-indent-mode t)
; use spaces for tabs always
(setq-default indent-tabs-mode nil)
; I use version control actually
(setq make-backup-files nil)
; save cursor position
(save-place-mode)
; smooth scrolling
(setq scroll-step 1)
; as decreed by the gods of unix
(setq require-final-newline t)
(setq mode-require-final-newline t)
; keep previous M-x shell behaviour of opening in current window
(add-to-list 'display-buffer-alist
`(,(regexp-quote "*shell") display-buffer-same-window))
; everyone loves a winner
(winner-mode)
(defun switch-to-previous-buffer ()
"Switch to previously open buffer.
Repeated invocations toggle between the two most recently open buffers."
(interactive)
(switch-to-buffer (other-buffer (current-buffer) 1)))
(global-set-key (kbd "C-c b") 'switch-to-previous-buffer)
;; solarized theme
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/emacs-color-theme-solarized")
(setq frame-background-mode 'dark)
(load-theme 'solarized t)
(setq solarized-terminal-themed t)
;; spell check for text files
(dolist (hook '(text-mode-hook))
(add-hook hook (lambda () (flyspell-mode 1))))
(dolist (hook '(change-log-mode-hook log-edit-mode-hook html-mode-hook))
(add-hook hook (lambda () (flyspell-mode -1))))
;; latex setup
(add-hook 'text-mode-hook 'turn-on-auto-fill)
(setq latex-run-command "pdflatex")
;; go setup
(defun go-mode-hook ()
; Call Gofmt before saving
(add-hook 'before-save-hook 'gofmt-before-save)
; Display function signatures
(go-eldoc-setup)
; Customize compile command to run go build, test and vet
(if (not (string-match "go" compile-command))
(set (make-local-variable 'compile-command)
; "go build -v && go test -v && go vet"))
"go build -v "))
(local-set-key (kbd "M-g") 'godef-jump)
; Load oracle
(load-file "$GOPATH/src/golang.org/x/tools/cmd/oracle/oracle.el")
(global-set-key (kbd "C-c t") 'go-test-current-file))
(add-hook 'go-mode-hook 'go-mode-hook)
;; python setup
(require 'flycheck)
(flycheck-define-checker
python-mypy ""
:command ("mypy"
"--ignore-missing-imports"
source-original)
:error-patterns
((error line-start (file-name) ":" line ": error:" (message) line-end))
:modes python-mode)
(add-to-list 'flycheck-checkers 'python-mypy t)
(flycheck-add-next-checker 'python-flake8 'python-mypy t)
(defun python-key-bindings ()
(local-set-key "\C-ca" 'pytest-all)
(local-set-key "\C-cm" 'pytest-module)
(local-set-key "\C-c." 'pytest-one)
(local-set-key "\C-cd" 'pytest-directory)
(local-set-key "\C-cpa" 'pytest-pdb-all)
(local-set-key "\C-cpm" 'pytest-pdb-module)
(local-set-key "\C-cp." 'pytest-pdb-one))
(add-hook 'python-mode-hook 'flycheck-mode)
(add-hook 'python-mode-hook 'flyspell-prog-mode)
(add-hook 'python-mode-hook 'anaconda-mode)
(add-hook 'python-mode-hook #'python-key-bindings)
(add-hook
'python-mode-hook
#'(lambda ()
(global-set-key (kbd "C-c C-k")
#'(lambda () (interactive)
; (let ((python-shell-prompt-detect-enabled nil))
(let ((python-shell-prompt-detect-failure-warning nil))
(run-python "pyspark"))))))
(require 'flycheck-cython)
(add-hook 'cython-mode-hook 'flycheck-mode)
(add-hook 'cython-mode-hook 'flycheck-prog-mode)
(add-hook 'python-mode-hook #'python-key-bindings)
(add-hook 'python-mode-hook 'python-black-on-save-mode)
;;; scala setup
(setq ensime-startup-notification nil)
;; load the ensime lisp code...
(add-to-list 'load-path "ENSIME_ROOT/elisp/")
(require 'ensime)
;; This step causes the ensime-mode to be started whenever
;; scala-mode is started for a buffer. You may have to customize this step
;; if you're not using the standard scala mode.
(add-hook 'scala-mode-hook 'ensime-scala-mode-hook)
;; javacript setup
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
(add-hook 'js2-mode-hook (lambda () (setq js2-basic-offset 2)))
(add-hook 'js2-mode-hook (lambda ()
(flycheck-mode t)
(when (executable-find "eslint")
(flycheck-select-checker 'javascript-eslint))))
;; haskell mode configuration
(setq auto-mode-alist
(append auto-mode-alist
'(("\\.hs$" . haskell-mode)
("\\.lhs$" . literate-haskell-mode))))
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
;(add-hook 'haskell-mode-hook 'inf-haskell-mode)
(add-hook 'haskell-mode-hook 'interactive-haskell-mode)
(add-hook 'haskell-mode-hook #'(lambda () (global-set-key (kbd "C-c C-c") 'haskell-process-load-file)))
;; scheme setup
(setq scheme-program-name "racket")
;; markdown setup
(autoload 'markdown-mode "markdown-mode" "Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
(autoload 'gfm-mode "markdown-mode" "Major mode for editing GitHub Flavored Markdown files" t)
(add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode))
(add-hook 'markdown-mode-hook 'flyspell-mode)
(add-hook 'gfm-mode-hook 'flyspell-mode)
;; ruby setup
(add-hook 'ruby-mode-hook #'(lambda () (modify-syntax-entry ?_ "w")))
(add-hook 'ruby-mode-hook 'flyspell-prog-mode)
(add-hook 'ruby-mode-hook 'inf-ruby-minor-mode)
(add-hook 'ruby-mode-hook 'flycheck-mode)
(add-hook 'ruby-mode-hook
#'(lambda ()
; (setq indent-tabs-mode nil)
; (setq tab-width 2)
(setq evil-shift-width 2)))
;; saltstack setup
(add-to-list 'auto-mode-alist '("\\.sls\\'" . yaml-mode))
;; terraform setup
(add-hook 'terraform-mode-hook #'terraform-format-on-save-mode)
;; internetting
(require 'web-mode)
; (add-to-list 'auto-mode-alist '("\\.js\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.css\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages
'(js2-mode python-black ess inf-ruby ruby-end terraform-mode salt-mode anaconda-mode yaml-mode web-mode use-package pytest markdown-mode magit haskell-mode gotest go-guru go-eldoc flycheck-pyflakes flycheck-cython evil ensime dockerfile-mode cython-mode)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)