-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.el
470 lines (384 loc) · 14 KB
/
init.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
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
;;; package --- Summary
;;; Commentary:
;;; Code:
(setq straight-use-package-by-defaul t)
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(defvar my:backup-directory
(expand-file-name (concat user-emacs-directory "backups/"))
"Directory storing all backups and auto-save files.
Must end with a trailing slash.")
(setq inhibit-startup-message t)
(desktop-save-mode 1)
(global-linum-mode 1)
(global-auto-revert-mode t)
(setq-default indent-tabs-mode nil)
(server-start) ;;or using "emacs --daemon option"
(add-to-list 'default-frame-alist
'(font . "DejaVu Sans Mono-12"))
(load "~/.emacs.d/alezf")
(load "~/.emacs.d/desktop-menu")
(load "~/.emacs.d/bufsearch")
(load "~/.emacs.d/mail")
(load "~/.emacs.d/docker-tramp-compat")
(use-package ag
:straight t
:if (not noninteractive))
(use-package auto-complete
:if (not noninteractive)
:straight t
:diminish auto-complete-mode
:config (progn
(require 'auto-complete-config)
(ac-config-default)
(setq-default ac-sources '(ac-source-yasnippet
ac-source-filename
ac-source-abbrev
ac-source-dictionary
ac-source-words-in-same-mode-buffers))
(global-auto-complete-mode 1)))
(use-package cyberpunk-theme
:straight t)
(use-package files
:config
(progn
(setq auto-save-file-name-transforms `((".*" ,my:backup-directory t))
auto-save-list-file-prefix my:backup-directory
backup-directory-alist `(("." . ,my:backup-directory))
auto-save-default t
auto-save-interval 200
auto-save-timeout 20
backup-by-copying t
delete-by-moving-to-trash t
delete-old-versions t
kept-new-versions 20
kept-old-versions 0
make-backup-files t
version-control t)
(defun force-backup-of-buffer ()
"Reset `buffer-backed-up' to nil."
(setq buffer-backed-up nil))
;; Always create backups on save:
(add-hook 'before-save-hook #'delete-trailing-whitespace)
(add-hook 'before-save-hook #'force-backup-of-buffer)))
(use-package flycheck
:straight t
:config
(progn
;; Add virtualenv support for checkers
(defadvice flycheck-checker-executable
(around python-flycheck-check-executable (checker)
activate compile)
"`flycheck-checker-executable' with virtualenv support."
(if (eq major-mode 'python-mode)
(let* ((process-environment (python-shell-calculate-process-environment))
(exec-path (python-shell-calculate-exec-path)))
ad-do-it)
ad-do-it))
(defadvice flycheck-start-checker
(around python-flycheck-start-checker (checker callback)
activate compile)
"`flycheck-start-checker' with virtualenv support."
(if (eq major-mode 'python-mode)
(let* ((process-environment (python-shell-calculate-process-environment))
(exec-path (python-shell-calculate-exec-path)))
ad-do-it)
ad-do-it))
(setq-default flycheck-disabled-checkers
(append flycheck-disabled-checkers
'(javascript-jshint)))
(setq flycheck-mode-line-lighter " ")))
;; this is for the autocomplete for commands
(use-package ido
:if (not noninteractive)
:straight t
:config
(progn
(use-package ido-vertical-mode
:straight t)
(use-package flx
:straight t)
(use-package flx-ido
:straight t)
(setq ido-enable-flex-matching t
ido-use-faces nil
flx-ido-use-faces t)
(ido-mode 1)
(ido-everywhere 1)
(ido-vertical-mode 1)
(flx-ido-mode 1)))
(use-package web-mode
:straight t
:config
(progn
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
(setq web-mode-engines-alist
'(("blade" . "\\.blade\\.")
("django" . "\\.html")))
(defun my-web-mode-hook ()
"Hooks for Web mode."
(setq web-mode-markup-indent-offset 4)
(setq web-mode-css-indent-offset 2)
(setq web-mode-code-indent-offset 2)
(setq web-mode-comment-style 2)
(setq web-mode-enable-current-element-highlight t)
(set-face-background 'web-mode-current-element-highlight-face "#0000FF")
(local-set-key (kbd "C-c C-v") 'browse-url-of-buffer))
(add-hook 'web-mode-hook 'my-web-mode-hook)))
;; Setting 2 spaces on javascript-mode
(setq js-indent-level 4)
(use-package projectile
:straight t
:if (not noninteractive)
:diminish projectile-mode
:config (projectile-global-mode 1))
(use-package python
:config
(progn
(use-package jedi
:straight t)
(setq jedi:complete-on-dot t)
(remove-hook 'python-mode-hook 'wisent-python-default-setup)
(add-hook 'python-mode-hook 'jedi:setup)
(add-hook 'python-mode-hook 'flycheck-mode)
(add-hook 'python-mode-hook 'hs-minor-mode)
(setq python-shell-interpreter "ipython"
python-shell-interpreter-args "--simple-prompt -i" )))
(use-package magit
:straight t
:if (not noninteractive)
:bind (("C-x g" . magit-status)
("C-x p" . magit-push))
:config
(progn
(defun magit-diff-toggle-whitespace ()
(interactive)
(if (member "-w" magit-diff-options)
(magit-diff-dont-ignore-whitespace)
(magit-diff-ignore-whitespace)))
(defun magit-diff-ignore-whitespace ()
(interactive)
(add-to-list 'magit-diff-options "-w")
(magit-refresh))
(defun magit-diff-dont-ignore-whitespace ()
(interactive)
(setq magit-diff-options (remove "-w" magit-diff-options))
(magit-refresh))
(defun magit-merge-no-ff (rev)
(interactive (list (magit-read-other-branch-or-commit "Merge")))
(magit-merge-assert)
(magit-run-git "merge" "--no-ff" rev))
(bind-key "W" 'magit-diff-toggle-whitespace magit-status-mode-map))
)
;; colour for your parens...
(use-package rainbow-mode
:straight t
:if (not noninteractive)
:config (progn
(mapc (lambda (mode)
(add-to-list 'rainbow-r-colors-major-mode-list mode))
'(css-mode emacs-lisp-mode lisp-interaction-mode))
(add-hook 'prog-mode-hook #'rainbow-turn-on)))
(use-package rainbow-delimiters
:straight t
:if (not noninteractive)
:config (add-hook 'prog-mode-hook 'rainbow-delimiters-mode))
(use-package scroll-bar
:config (scroll-bar-mode -1))
(use-package smartparens
:straight t
:if (not noninteractive)
:diminish (smartparens-mode . " π"))
(use-package smex
:straight t
:if (not noninteractive)
:bind (("M-x" . smex)
("M-X" . smex-major-mode-commands)
("C-c M-x" . execute-extended-command))
:config (smex-initialize))
(use-package tool-bar
:config (tool-bar-mode -1))
(use-package uniquify
:if (not noninteractive)
:config (setq uniquify-buffer-name-style 'forward))
(use-package whitespace
:straight t
:if (not noninteractive)
:diminish (global-whitespace-mode . " ω")
:config (progn
(setq whitespace-style '(trailing tabs indentation::space face))
(setq whitespace-global-modes
'(c-mode c++-mode emacs-lisp-mode python-mode lisp-mode go-mode))
(global-whitespace-mode 1)))
(setq custom-file "~/.emacs.d/custom.el")
(load custom-file 'noerror)
(put 'dired-find-alternate-file 'disabled nil)
(global-flycheck-mode)
;; Python virtualenv support configuration
(use-package virtualenvwrapper
:straight t
:config (progn (venv-initialize-interactive-shells) ;; if you want interactive shell support
(venv-initialize-eshell) ;; if you want eshell support
(setq venv-location "~/.virtualenvs/")))
;; Configuring emmet-mode for (x)html & css files
(use-package emmet-mode
:straight t)
(add-hook 'sgml-mode-hook 'emmet-mode) ;; Auto-start on any markup modes
(add-hook 'html-mode-hook 'emmet-mode)
(add-hook 'css-mode-hook 'emmet-mode)
(add-hook 'web-mode-hook 'emmet-mode)
(use-package bash-completion
:straight t
:config (bash-completion-setup))
(use-package restclient
:straight t)
(use-package yaml-mode
:straight t)
(use-package ansible
:straight t
:config
;; activamos yaml-mode cuando se activa ansible-mode
(add-hook 'yaml-mode-hook '(lambda () (ansible 1))))
(use-package yasnippet
:straight t
:config
(progn
(add-to-list 'load-path
"~/.emacs.d/plugins/yasnippet")
(yas-global-mode 1)))
(use-package yasnippet-snippets
:straight t)
(use-package common-lisp-snippets
:straight t)
(use-package docker
:bind ("C-c d" . docker))
(use-package dockerfile-mode
:straight t)
(defun run-slime-config ()
"Run config based on Slime."
;; wrapper around slime-docker, for its correct use first:
;; 1) $ mkdir ~/projects (if not exists folder)
;; 2) $ docker network create devnetwork
(fset 'my-docker
(lambda (&optional arg) (interactive)
(slime-docker-start :rm t
:mounts '((("~/projects" . "/home/lisp/quicklisp/local-projects/")))
:network "devenv_dev_net"
:env '(("LISP_DEVEL_UID" . "1000")))))
(defun slime-qlot-exec (directory)
"DIRECTORY is the directory that contain your qlot project."
(interactive (list (read-directory-name "Project directory: ")))
(slime-start :program "/home/alejandrozf/.roswell/bin/qlot"
:program-args '("exec" "ros" "-S" "." "run")
:directory directory
:name 'qlot
:env (list (concat "PATH=" (mapconcat 'identity exec-path ":")))))
(use-package slime-docker
:straight t)
(slime-setup '(slime-fancy slime-tramp slime-asdf)))
(defun run-sly-config ()
"Run config based on Sly."
(use-package sly
:straight (sly :type git :host github :repo "joaotavora/sly"
:fork (:host github
:repo "alejandrozf/sly"
:branch "azf-fix-abcl-backend"))
:bind (("C-c C-s b" . sly-stickers-clear-buffer-stickers)
("C-c C-s f" . sly-stickers-forget)))
:config (setq sly-complete-symbol-function 'sly-simple-completions)) ;sly-flex-completions
(defun sly-qlot-exec (directory)
(interactive (list (read-directory-name "Project directory: ")))
(sly-start :program "/home/alejandrozf/.roswell/bin/qlot"
:program-args '("exec" "ros" "-S" "." "run")
:directory directory
:name 'qlot
:env (list (concat "PATH=" (mapconcat 'identity exec-path ":")))))
;; by default run with Sly configuration but if you run emacs with:
;; AZF_EMACS_SLIME=True emacs
;; will use with Slime configuration instead
(if (getenv "AZF_EMACS_SLIME")
(run-slime-config)
(run-sly-config))
;; ABCL notes for debugging:
;; ant abcl.debug.jpda
;; jdb -connect com.sun.jdi.SocketAttach:port=6789
(load "~/.emacs.d/asdf")
(setq inferior-lisp-program "sbcl")
;; Examples for Sly implementations (you should add it to local.el)
;; (setq sly-lisp-implementations
;; '((abcl ("/home/alejandrozf/Desktop/abcl/abcl"))
;; (sbcl ("sbcl"))
;; (sbcl-roswell ("ros" "run"))
;; (sbcl-2048-roswell ("ros" "run" "dynamic-space-size=2048"))
;; (abcl-jar ("java" "-jar" "/home/alejandrozf/Desktop/abcl/dist/abcl.jar"))))
;; (setq slime-contribs '(slime-fancy slime-tramp))
(show-paren-mode t) ;; enable show paren mode
(setq show-paren-style 'expression) ;; highlight whole expression
;; define function to restart the server
(defun signal-restart-server ()
(interactive)
(message "Caught event %S" last-input-event)
(server-mode)
)
;; add the binding to the special-event-map
(define-key special-event-map [sigusr1] 'signal-restart-server)
;; cua-mode initialization
(cua-mode t)
;; delete beep, and change by visible indicator
(setq visible-bell 1)
;; ver la hora por defecto
(display-time-mode 1)
(condition-case nil
(load "~/.emacs.d/local")
(error "No ha definido un archivo con código local"))
;; Org-mode clock tasks
(setq org-clock-persist 'history)
(org-clock-persistence-insinuate)
(setq dired-dwim-target t)
(org-babel-do-load-languages
'org-babel-load-languages
'((calc . t)
(python . t)
(lisp . t)
(shell . t)
))
(use-package dumb-jump
;; instalar ag
;; https://github.com/ggreer/the_silver_searcher
:straight t
:bind (("M-g o" . dumb-jump-go-other-window)
("M-g j" . dumb-jump-go)
("M-g i" . dumb-jump-go-prompt)
("M-g x" . dumb-jump-go-prefer-external)
("M-g z" . dumb-jump-go-prefer-external-other-window))
:config (setq dumb-jump-selector 'ido) ;; (setq dumb-jump-selector 'helm)
)
(add-hook 'after-init-hook
() (load-theme 'cyberpunk t))
(add-hook 'after-org-mode
() (setq org-indent-mode t))
(setq dired-listing-switches "-alh")
;; (add-hook 'after-init-hook 'global-company-mode)
(use-package org-attach-screenshot
:straight t)
(add-hook 'sly-inspector-mode-hook #'toggle-truncate-lines)
(provide 'init)
;;; init.el ends here