-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.emacs
executable file
·553 lines (490 loc) · 18.4 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
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
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
;;; Package --- Summary
;;; Code:
;;; Commentary:
;; __ _ __ _
;; / _| | _____ __ ___ ___ _ __ / _(_) __ _
;; | |_| |/ _ \ \/ / / __/ _ \| '_ \| |_| |/ _` |
;; | _| | __/> < | (_| (_) | | | | _| | (_| |
;; |_| |_|\___/_/\_\ \___\___/|_| |_|_| |_|\__, |
;; |___/
;; Felix Valentini
;; Emcas configuration v.2
;; last update 2023-04-25
(setq custom-file "~/.emacs.custom.el")
(load-file custom-file)
(setenv "PATH" (concat "/Users/flex99/.cabal/bin:" (getenv "PATH")))
;; start package.el eith Emacs
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/"))
;; initialize package.el
(package-initialize)
(setq inhibit-startup-screen t)
;; Disable tool-bar
(tool-bar-mode -1)
;; enable whitespace-mode
;; (require 'whitespace)
;; (global-whitespace-mode 1)
(transient-mark-mode 1) ;; No region when it is not highlighted
(global-set-key (kbd "C-;") 'comment-or-uncomment-region)
;; save annoying backupfiles outside of the working directories
(setq backup-directory-alist '(("." . "~/.emacs.d/backup")))
;; macos uk layout specific
(setq ns-alternate-modifier 'meta)
(setq ns-right-alternate-modifier 'none)
;; (add-to-list 'default-frame-alist '(font . "DejaVu Sans Mono" ))
;; (set-face-attribute 'default t :font "DejaVu Sans Mono" )
;; use spaces instead of tab, to convert tabbed document to spaced one selct the whole doc (C-x h; M-x unatbify)
;; Editor plug ins
(use-package counsel
:ensure t)
(use-package swiper
:ensure t
:config
(progn
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
;; enable this if you want `swiper' to use it
;; (setq search-default-mode #'char-fold-to-regexp)
(global-set-key "\C-s" 'swiper)
(global-set-key (kbd "C-c C-r") 'ivy-resume)
(global-set-key (kbd "<f6>") 'ivy-resume)
(global-set-key (kbd "M-x") 'counsel-M-x)
(global-set-key (kbd "C-x C-f") 'counsel-find-file)
(global-set-key (kbd "<f1> f") 'counsel-describe-function)
(global-set-key (kbd "<f1> v") 'counsel-describe-variable)
(global-set-key (kbd "<f1> l") 'counsel-find-library)
(global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
(global-set-key (kbd "<f2> u") 'counsel-unicode-char)
(global-set-key (kbd "C-c g") 'counsel-git)
(global-set-key (kbd "C-c j") 'counsel-git-grep)
(global-set-key (kbd "C-c k") 'counsel-ag)
(global-set-key (kbd "C-x l") 'counsel-locate)
(global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
(define-key minibuffer-local-map (kbd "C-r") 'counsel-minibuffer-history)))
;; theme
(use-package doom-themes
:ensure t
:config
;; Global settings (defaults)
(setq doom-themes-enable-bold t ; if nil, bold is universally disabled
doom-themes-enable-italic t) ; if nil, italics is universally disabled
(load-theme 'doom-one t)
;; Enable flashing mode-line on errors
(doom-themes-visual-bell-config)
;; or for treemacs users
(setq doom-themes-treemacs-theme "doom-colors") ; use the colorful treemacs theme
(doom-themes-treemacs-config)
;; Corrects (and improves) org-mode's native fontification.
(doom-themes-org-config))
;; M-x all-the-icons-fonts to install them!
(use-package all-the-icons
:ensure t)
;; disable scroll-bar
(scroll-bar-mode -1)
(menu-bar-mode -1)
;; Mod line configuration, used package: spaceline
(use-package spaceline
:ensure t
:config
(require 'spaceline-config)
(spaceline-emacs-theme))
;; nyan-mode for mod line
(use-package nyan-mode
:ensure t
:config
(require 'nyan-mode)
(nyan-mode t))
;; font scaling
(use-package default-text-scale
:ensure t
:config
(global-set-key (kbd "C-M-=") 'default-text-scale-increase)
(global-set-key (kbd "C-M--") 'default-text-scale-decrease))
(define-key ctl-x-map [(control ?0)] 'zoom-in/out)
;; line numeration
(use-package linum-relative
:ensure t
:config
(setq linum-relative-current-symbol "->")
(setq linum-relative-format "%3s ")
(linum-relative-global-mode t))
;; window management
(use-package ace-window
:ensure t
:init
(progn
(global-set-key [remap other-window] 'ace-window)
(custom-set-faces
'(aw-leading-char-face
((t (:inherit ace-jump-face-foreground :height 3.0))))) 121))
(use-package highlight-numbers
:ensure t
:hook (prog-mode-hook . highlight-numbers-mode))
(use-package colorful-mode
:ensure t
:hook (prog-mode text-mode))
(use-package emojify
:ensure t
:hook (after-init-hook #'global-emojify-mode))
(use-package smartparens
:ensure t
:hook (prog-mode . smartparens-mode)
:config
(smartparens-global-mode t)
(show-smartparens-global-mode t)
(require 'smartparens-config))
(use-package rainbow-delimiters
:ensure t
:hook (prog-mode . rainbow-delimiters-mode))
(use-package move-text
:ensure t
:config
(move-text-default-bindings))
;; shows directories
(use-package dir-treeview
:ensure t
:config
(global-set-key [f8] 'dir-treeview))
(use-package breadcrumb
:ensure t
:config
(breadcrumb-mode 1))
(setq-default indent-tabs-mode nil)
;; shows bindings options
(use-package which-key
:ensure t
:config
(which-key-mode))
(use-package multiple-cursors
:ensure t
:config
(require 'multiple-cursors)
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this))
;; Programming plug-ins
;; git interface
(use-package magit
:ensure t)
;; project manager
(use-package projectile
:ensure t
:config
(projectile-mode +1)
(define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
(define-key projectile-mode-map (kbd "C-c f") 'projectile-find-file))
;; syntax checker
(use-package flycheck
:ensure t
:init
(global-flycheck-mode t))
;; python stuff
;; python auto-complete
;; elpy-dep
(use-package company
:ensure t
:config
(add-hook 'after-init-hook 'global-company-mode)
(setq initial-major-mode 'company))
(use-package highlight-indentation
:ensure t
:config
(set-face-background 'highlight-indentation-face "#536878")
(set-face-background 'highlight-indentation-current-column-face "#657E91"))
;; elpy-dep
(use-package pyvenv
:ensure t)
;; ipython interpreter
(defun ipython ()
(interactive)
(term "/usr/bin/ipython"))
;; synatx templates
(use-package yasnippet
:ensure t
:init
(yas-global-mode 1))
(use-package yasnippet-snippets
:ensure t)
(use-package elpy
:ensure t
:init
(elpy-enable))
(setq python-shell-interpreter "/usr/bin/python3")
;; lisp flavoured python
(use-package hy-mode
:ensure t
:mode "\\.hy\\'")
;; javascript stuff
;; rest api tester
(use-package restclient
:ensure t
:mode (("\\.http\\'" . restclient-mode)))
;; customize flycheck temp file prefix
(setq-default flycheck-temp-prefix ".flycheck")
;; disable json-jsonlist checking for json files
(setq-default flycheck-disabled-checkers
(append flycheck-disabled-checkers
'(json-jsonlist)))
;; json utilities
(use-package json-snatcher
:ensure t
:config
(require 'json-snatcher))
(use-package json-mode
:ensure t
:mode "\\.json\\'")
;; yaml utilities
(use-package yaml-mode
:ensure t
:mode "\\.yml\\'"
:config
(add-hook 'yaml-mode-hook 'highlight-indentation-mode))
;; Dockerfile mode
(use-package dockerfile-mode
:ensure t
:config
(require 'dockerfile-mode)
(add-to-list 'auto-mode-alist '("Dockerfile\\'" . dockerfile-mode)))
;; FUNCTIONAL STUFF
;; haskell integration
(use-package hindent
:ensure t)
(use-package haskell-mode
:ensure t
:hook
(haskell-mode . (lambda () (flycheck-mode -1)))
(haskell-mode . hindent-mode)
(haskell-mode . haskell-doc-mode)
(haskell-mode . interactive-haskell-mode)
(haskell-mode . eglot-ensure)
:config
(require 'haskell-mode)
(require 'w3m-haddock)
(setq haskell-process-type 'cabal-repl)
(setq haskell-svg-render-images t)
(setq-default eglot-workspace-configuration
'((haskell
(formattingProvider . "fourmolu"))))
(add-hook 'eglot-managed-mode-hook
(lambda ()
(add-hook 'before-save-hook #'eglot-format-buffer -10 t)))
(add-to-list 'eglot-server-programs
'(haskell-mode . ("haskell-language-server" "--lsp")))
(define-key haskell-mode-map (kbd "C-c h") 'haskell-hoogle)
(define-key haskell-mode-map (kbd "M-[") 'haskell-navigate-imports)
(define-key haskell-mode-map (kbd "M-]") 'haskell-navigate-imports-return)
(define-key haskell-mode-map (kbd "C-c C-d") 'haskell-w3m-open-haddock))
(use-package w3m
:ensure t
:hook (w3m-mode . w3m-haddock-display)
:config
(setq w3m-mode-map (make-sparse-keymap))
(define-key w3m-mode-map (kbd "RET") 'w3m-view-this-url)
(define-key w3m-mode-map (kbd "q") 'bury-buffer)
(define-key w3m-mode-map (kbd "<mouse-1>") 'w3m-maybe-url)
(define-key w3m-mode-map [f5] 'w3m-reload-this-page)
(define-key w3m-mode-map (kbd "M-<left>") 'w3m-view-previous-page)
(define-key w3m-mode-map (kbd "M-<right>") 'w3m-view-next-page)
(define-key w3m-mode-map (kbd "M-.") 'w3m-haddock-find-tag))
(defun w3m-maybe-url ()
(interactive)
(if (or (equal '(w3m-anchor) (get-text-property (point) 'face))
(equal '(w3m-arrived-anchor) (get-text-property (point) 'face)))
(w3m-view-this-url)))
;; (add-to-list 'load-path "~/sources/haskell-ts-mode")
;; (require 'haskell-ts-mode)
;; (add-to-list 'treesit-language-source-alist
;; '(haskell . ("https://github.com/tree-sitter/tree-sitter-haskell" "master" "src")))
;; (with-eval-after-load 'eglot (haskell-ts-setup-eglot))
;; (use-package ormolu
;; :hook (haskell-ts-mode . ormolu-format-on-save-mode)
;; :bind
;; (:map haskell-mode-map
;; ("C-c r" . ormolu-format-buffer)))
;; ghcid
;; file: https://raw.githubusercontent.com/ndmitchell/ghcid/master/plugins/emacs/ghcid.el
(add-to-list 'load-path "~/sources/ghcid/plugins/emacs")
(load "ghcid")
(use-package geiser
:ensure t)
;; modern list API fir emacs-lisp
(use-package dash
:ensure t)
;; string manipulation API for emacs-lisp
(use-package s
:ensure t)
;; lisp utility
(use-package paredit
:ensure t)
;; Text manipulation and utilities
;; org-mode stuff
(use-package org-bullets
:ensure t
:config
(require 'org-bullets)
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
(use-package lsp-mode
:init
;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l")
(setq lsp-keymap-prefix "C-c l")
:hook (
(vue-mode . lsp)
(python-mode . lsp)
(js-mode . lsp)
;; if you want which-key integration
(lsp-mode . lsp-enable-which-key-integration))
:custom
(lsp-vetur-format-default-formatter-css "none")
(lsp-vetur-format-default-formatter-html "none")
(lsp-vetur-format-default-formatter-js "none")
(lsp-vetur-validation-template nil)
:commands lsp)
(use-package vue-mode
:mode "\\.vue\\'"
:hook (vue-mode . prettier-js-mode)
:config
(add-hook 'vue-mode-hook #'lsp)
(add-hook 'vue-mode-hook 'prettier-js-mode)
(setq prettier-js-args '("--parser vue"))
;; https://github.com/8uff3r/vue-ts-mode
(add-to-list 'load-path (concat user-emacs-directory "vue-ts-mode"))
(require 'vue-ts-mode)
(add-hook 'vue-mode-hook 'vue-ts-mode))
;; optionally
(use-package lsp-ui :commands lsp-ui-mode)
;; if you are helm user
(use-package helm-lsp :commands helm-lsp-workspace-symbol)
;; if you are ivy user
(use-package lsp-ivy :commands lsp-ivy-workspace-symbol)
(use-package lsp-treemacs :commands lsp-treemacs-errors-list)
(setq treesit-language-source-alist
'((css "https://github.com/tree-sitter/tree-sitter-css")
(elisp "https://github.com/Wilfred/tree-sitter-elisp")
(html "https://github.com/tree-sitter/tree-sitter-html")
(javascript "https://github.com/tree-sitter/tree-sitter-javascript" "master" "src")
(json "https://github.com/tree-sitter/tree-sitter-json")
(make "https://github.com/alemuller/tree-sitter-make")
(markdown "https://github.com/ikatyang/tree-sitter-markdown")
(python "https://github.com/tree-sitter/tree-sitter-python")
(toml "https://github.com/tree-sitter/tree-sitter-toml")
(tsx "https://github.com/tree-sitter/tree-sitter-typescript" "master" "tsx/src")
(typescript "https://github.com/tree-sitter/tree-sitter-typescript" "master" "typescript/src")
(haskell "https://github.com/tree-sitter/tree-sitter-haskell" "master" "src")
(yaml "https://github.com/ikatyang/tree-sitter-yaml")
(vue "https://github.com/ikatyang/tree-sitter-vue")))
(setq major-mode-remap-alist
'((yaml-mode . yaml-ts-mode)
(js2-mode . js-ts-mode)
(typescript-mode . typescript-ts-mode)
(json-mode . json-ts-mode)
(css-mode . css-ts-mode)
(python-mode . python-ts-mode)
;; (haskell-mode . haskell-ts-mode)
(markdown-mode . markdown-ts-mode)))
(use-package markdown-mode
:ensure t)
;; font: https://github.com/tonsky/FiraCode
(set-face-attribute 'default nil
:family "Fira Code" :weight 'normal :height 120)
(use-package ligature
:config
;; Enable the "www" ligature in every possible major mode
(ligature-set-ligatures 't '("www"))
;; Enable traditional ligature support in eww-mode, if the
;; `variable-pitch' face supports it
(ligature-set-ligatures 'eww-mode '("ff" "fi" "ffi"))
;; Enable all Cascadia and Fira Code ligatures in programming modes
(ligature-set-ligatures 'prog-mode
'(;; == === ==== => =| =>>=>=|=>==>> ==< =/=//=// =~
;; =:= =!=
("=" (rx (+ (or ">" "<" "|" "/" "~" ":" "!" "="))))
;; ;; ;;;
(";" (rx (+ ";")))
;; && &&&
("&" (rx (+ "&")))
;; !! !!! !. !: !!. != !== !~
("!" (rx (+ (or "=" "!" "\." ":" "~"))))
;; ?? ??? ?: ?= ?.
("?" (rx (or ":" "=" "\." (+ "?"))))
;; %% %%%
("%" (rx (+ "%")))
;; |> ||> |||> ||||> |] |} || ||| |-> ||-||
;; |->>-||-<<-| |- |== ||=||
;; |==>>==<<==<=>==//==/=!==:===>
("|" (rx (+ (or ">" "<" "|" "/" ":" "!" "}" "\]"
"-" "=" ))))
;; \\ \\\ \/
("\\" (rx (or "/" (+ "\\"))))
;; ++ +++ ++++ +>
("+" (rx (or ">" (+ "+"))))
;; :: ::: :::: :> :< := :// ::=
(":" (rx (or ">" "<" "=" "//" ":=" (+ ":"))))
;; // /// //// /\ /* /> /===:===!=//===>>==>==/
("/" (rx (+ (or ">" "<" "|" "/" "\\" "\*" ":" "!"
"="))))
;; .. ... .... .= .- .? ..= ..<
("\." (rx (or "=" "-" "\?" "\.=" "\.<" (+ "\."))))
;; -- --- ---- -~ -> ->> -| -|->-->>->--<<-|
("-" (rx (+ (or ">" "<" "|" "~" "-"))))
;; *> */ *) ** *** ****
("*" (rx (or ">" "/" ")" (+ "*"))))
;; www wwww
("w" (rx (+ "w")))
;; <> <!-- <|> <: <~ <~> <~~ <+ <* <$ </ <+> <*>
;; <$> </> <| <|| <||| <|||| <- <-| <-<<-|-> <->>
;; <<-> <= <=> <<==<<==>=|=>==/==//=!==:=>
;; << <<< <<<<
("<" (rx (+ (or "\+" "\*" "\$" "<" ">" ":" "~" "!"
"-" "/" "|" "="))))
;; >: >- >>- >--|-> >>-|-> >= >== >>== >=|=:=>>
;; >> >>> >>>>
(">" (rx (+ (or ">" "<" "|" "/" ":" "=" "-"))))
;; #: #= #! #( #? #[ #{ #_ #_( ## ### #####
("#" (rx (or ":" "=" "!" "(" "\?" "\[" "{" "_(" "_"
(+ "#"))))
;; ~~ ~~~ ~= ~- ~@ ~> ~~>
("~" (rx (or ">" "=" "-" "@" "~>" (+ "~"))))
;; __ ___ ____ _|_ __|____|_
("_" (rx (+ (or "_" "|"))))
;; Fira code: 0xFF 0x12
("0" (rx (and "x" (+ (in "A-F" "a-f" "0-9")))))
;; Fira code:
"Fl" "Tl" "fi" "fj" "fl" "ft"
;; The few not covered by the regexps.
"{|" "[|" "]#" "(*" "}#" "$>" "^="))
;; Enables ligature checks globally in all buffers. You can also do it
;; per mode with `ligature-mode'.
(global-ligature-mode t))
(use-package nix-mode
:mode "\\.nix\\'")
(use-package typescript-mode
:after tree-sitter
:hook ((typescript-mode . eglot-ensure))
:config
;; we choose this instead of tsx-mode so that eglot can automatically figure out language for server
;; see https://github.com/joaotavora/eglot/issues/624 and https://github.com/joaotavora/eglot#handling-quirky-servers
(define-derived-mode typescriptreact-mode typescript-mode
"TypeScript TSX")
;; use our derived mode for tsx files
(add-to-list 'auto-mode-alist '("\\.tsx?\\'" . typescriptreact-mode))
;; by default, typescript-mode is mapped to the treesitter typescript parser
;; use our derived mode to map both .tsx AND .ts -> typescriptreact-mode -> treesitter tsx
(add-to-list 'tree-sitter-major-mode-language-alist '(typescriptreact-mode . tsx)))
(use-package apheleia
:ensure t)
(use-package dart-mode
:ensure t
:hook ((dart-mode . eglot-ensure))
:config
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'((dart-mode) . ("fvm" "dart" "language-server" "--client-id" "emacs.eglot-dart"))))
(add-hook 'eglot-managed-mode-hook
(lambda ()
(add-hook 'before-save-hook #'eglot-format-buffer -10 t))))
(add-hook 'eglot-managed-mode-hook (lambda () (eglot-inlay-hints-mode -1)))
;;; init.el ends here