aboutsummaryrefslogtreecommitdiff
path: root/emacs/emacs.el
blob: 83763313997d7ef67e9b1ecce3fdd42660d6068a (plain)
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
;; symlink this file to ~/.emacs

;; Nicer defaults

(setq compilation-scroll-output t)
(setq column-number-mode t)
(setq-default show-trailing-whitespace t)
(setq org-startup-folded t)
(xterm-mouse-mode 1)

;; From https://www.emacswiki.org/emacs/SmoothScrolling#h5o-8
(setq scroll-step 1)
(setq scroll-conservatively 10000)
(setq auto-window-vscroll nil)

;; Do not spill temporary files everywhere
;; https://stackoverflow.com/a/18330742
(defvar --backup-directory (concat user-emacs-directory "backups"))
(if (not (file-exists-p --backup-directory))
        (make-directory --backup-directory t))
(setq backup-directory-alist `(("." . ,--backup-directory)))

;; Colorblind friendly theme.
(require-theme 'modus-themes)
(load-theme 'modus-vivendi :no-confirm)

;; From https://github.com/emacs-lsp/lsp-ui/issues/607 , silence some mouse hovering noise
(let ((areas '("mode-line" "left-margin" "left-fringe" "right-fringe" "header-line" "vertical-scroll-bar"))
          loc)
      (while areas
        (setq loc (pop areas))
        (global-set-key
         (kbd (concat "<" loc "> <mouse-movement>")) #'ignore)))

;; I use Emacs in the terminal, where x-pos|hide-tip is not defined. This masks errors :(
(defun x-pos-tip () nil)
(defun x-hide-tip () nil)

(require 'use-package-ensure)
(setq use-package-always-ensure t)

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)

;; Install xclip so cutting/copying in Emacs on a terminal affects the graphical clipboard
(use-package xclip
  :ensure t
  :config
  (xclip-mode 1))

;; editorconfig simplifies adhering to code standards
(use-package editorconfig
  :ensure t
  :config
  (editorconfig-mode 1))

;; Fancy undo
(use-package undo-tree
  :ensure t
  :config
  (global-undo-tree-mode)
  (setq undo-tree-visualizer-diff t)
  (setq undo-tree-visualizer-timestamp t)
  (setq undo-tree-auto-save-history t)
  ;; https://www.reddit.com/r/emacs/comments/tejte0/undotree_bug_undotree_files_scattering_everywhere/?rdt=39892
  (setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo"))))

;; nicer completion UI
(use-package helm
  :ensure t
  :config
  (global-set-key (kbd "M-x") #'helm-M-x)
  (global-set-key (kbd "C-x C-f") #'helm-find-files)
  (global-set-key (kbd "C-x C-b") #'helm-mini)
  (setq helm-ff-skip-boring-files t))

;; learn keyboard shortcuts
(use-package which-key
  :ensure t
  :config
  (which-key-mode))

;; LSP base for Rust and Java
(use-package lsp-mode
  :ensure t
  :init
  ;; Windows Terminal has rendering issues with lenses?
  (setq lsp-lens-enable nil)
  :custom (lsp-rust-features "all"))

(use-package company
  :ensure t
  :config
  (add-hook 'after-init-hook 'global-company-mode))

(use-package lsp-ui
  :ensure t)
(use-package yasnippet
  :ensure t)

(yas-global-mode 1)

;; Rust support
(use-package rust-mode
  :ensure t
  :config
  (add-hook 'rust-mode-hook #'lsp)
  (add-hook 'rust-mode-hook
            (lambda () (setq indent-tabs-mode nil)))
  (setq rust-format-on-save t))

;; Python support
; https://github.com/jorgenschaefer/elpy/issues/1890#issuecomment-792361668
; Need to downgrade jedi to get it to work :(
(use-package elpy
  :ensure t
  :init
  (elpy-enable))

;;; Java Support
(use-package lsp-java
  :ensure t
  :config
  (add-hook 'java-mode-hook 'lsp)
  (add-hook 'java-mode-hook (lambda ()
                              (setq c-basic-offset 2
                                    indent-tabs-mode f))))

;; YAML support
(use-package yaml-mode
  :ensure t)

;; lsp-mode seems unusably slow, so don't install the Ansible language server
;; if you want to get it working, try https://www.reddit.com/r/emacs/comments/ybbkks/how_to_properly_set_up_lsp_ansible_language/itfxoaa/
(use-package ansible
  :ensure t
  :config
  (add-hook 'yaml-mode-hook 'ansible))

;; Puppet support; mostly for syntax highlighting

(use-package puppet-mode
  :ensure t)

(use-package zmq :ensure t)
(use-package jupyter :ensure t)

(use-package elfeed :ensure t)
(use-package elfeed-protocol
  :ensure t
  :config
  (setq elfeed-use-curl t)
  (elfeed-set-timeout 36000)
  (setq elfeed-protocol-enabled-protocols '(fever))
  (elfeed-protocol-enable)
  (setq elfeed-protocol-feeds '(("fever+https://alex@miniflux.pdp7.net"
				 :api-url "https://miniflux.pdp7.net/fever/"
				 :password-file "~/.miniflux.fever.pw")))
  (setq-default elfeed-search-filter "+unread ")
  (setq-default elfeed-sort-order 'ascending))