-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.el
203 lines (167 loc) · 7.44 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
;;
;; ______________________
;; / ░█▀▀░█▄█░█▀█░█▀▀░█▀▀ \
;; | ░█▀▀░█░█░█▀█░█░░░▀▀█ |
;; \ ░▀▀▀░▀░▀░▀░▀░▀▀▀░▀▀▀ /
;; ----------------------
;; \ ^__^
;; \ (oo)\_______
;; (__)\ )\/\
;; ||----w |
;; || ||
;;
;; ------ Basic evil mode ------
;; Set up package.el to work with MELPA
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(package-initialize)
(package-refresh-contents)
;; Download Evil
(unless (package-installed-p 'evil)
(package-install 'evil))
;; Enable Evil
(require 'evil)
(evil-mode 1)
;; ----------- Status line package -----------
(unless (package-installed-p 'airline-themes)
(package-install 'airline-themes))
(require 'airline-themes)
(load-theme 'airline-light t)
;; ---------- Neotree ------
(unless (package-installed-p 'neotree)
(package-install 'neotree))
(require 'neotree)
(global-set-key [f8] 'neotree-toggle)
(add-hook 'neotree-mode-hook
(lambda ()
(define-key evil-normal-state-local-map (kbd "TAB") 'neotree-enter)
(define-key evil-normal-state-local-map (kbd "SPC") 'neotree-quick-look)
(define-key evil-normal-state-local-map (kbd "q") 'neotree-hide)
(define-key evil-normal-state-local-map (kbd "RET") 'neotree-enter)
(define-key evil-normal-state-local-map (kbd "g") 'neotree-refresh)
(define-key evil-normal-state-local-map (kbd "n") 'neotree-next-line)
(define-key evil-normal-state-local-map (kbd "p") 'neotree-previous-line)
(define-key evil-normal-state-local-map (kbd "A") 'neotree-stretch-toggle)
(define-key evil-normal-state-local-map (kbd "H") 'neotree-hidden-file-toggle)))
;; --------- Dashboard --------
(unless (package-installed-p 'dashboard)
(package-install 'dashboard))
(require 'dashboard)
(dashboard-setup-startup-hook)
(setq dashboard-startup-banner 2)
;; ------------ flycheck --------
(unless (package-installed-p 'flycheck)
(package-install 'flycheck))
(global-flycheck-mode)
;; ------------ Theme --------
(unless (package-installed-p 'monokai-theme)
(package-install 'monokai-theme))
(load-theme 'monokai t)
;; --------------------- Helm -------------------------
(unless (package-installed-p 'async)
(package-install 'async))
(require 'async)
(unless (package-installed-p 'helm)
(package-install 'helm))
;; helm config -- from https://tuhdo.github.io/helm-intro.html
(require 'helm)
(require 'helm-config)
;; The default "C-x c" is quite close to "C-x C-c", which quits Emacs.
;; Changed to "C-c h". Note: We must set "C-c h" globally, because we
;; cannot change `helm-command-prefix-key' once `helm-config' is loaded.
(global-set-key (kbd "C-c h") 'helm-command-prefix)
(global-unset-key (kbd "C-x c"))
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action) ; rebind tab to run persistent action
(define-key helm-map (kbd "C-i") 'helm-execute-persistent-action) ; make TAB work in terminal
(define-key helm-map (kbd "C-z") 'helm-select-action) ; list actions using C-z
(when (executable-find "curl")
(setq helm-google-suggest-use-curl-p t))
(setq helm-split-window-in-side-p t ; open helm buffer inside current window, not occupy whole other window
helm-move-to-line-cycle-in-source t ; move to end or beginning of source when reaching top or bottom of source.
helm-ff-search-library-in-sexp t ; search for library in `require' and `declare-function' sexp.
helm-scroll-amount 8 ; scroll 8 lines other window using M-<next>/M-<prior>
helm-ff-file-name-history-use-recentf t
helm-echo-input-in-header-line t)
(defun spacemacs//helm-hide-minibuffer-maybe ()
"Hide minibuffer in Helm session if we use the header line as input field."
(when (with-helm-buffer helm-echo-input-in-header-line)
(let ((ov (make-overlay (point-min) (point-max) nil nil t)))
(overlay-put ov 'window (selected-window))
(overlay-put ov 'face
(let ((bg-color (face-background 'default nil)))
`(:background ,bg-color :foreground ,bg-color)))
(setq-local cursor-type nil))))
(add-hook 'helm-minibuffer-set-up-hook
'spacemacs//helm-hide-minibuffer-maybe)
(setq helm-autoresize-max-height 0)
(setq helm-autoresize-min-height 20)
(helm-autoresize-mode 1)
(helm-mode 1)
;; Rebind to helm versions of commands
(global-set-key (kbd "C-x C-f") 'helm-find-files)
(global-set-key (kbd "C-x b") 'helm-mini)
(setq helm-buffers-fuzzy-matching t
helm-recentf-fuzzy-match t)
(global-set-key (kbd "M-x") 'helm-M-x)
(setq helm-M-x-fuzzy-match t) ;; optional fuzzy matching for helm-M-x
;; --------------- lsp-mode ------------------
;; from https://emacs-lsp.github.io/lsp-mode/tutorials/CPP-guide/
(setq package-selected-packages '(lsp-mode yasnippet lsp-treemacs helm-lsp
projectile hydra flycheck company avy which-key helm-xref dap-mode))
(when (cl-find-if-not #'package-installed-p package-selected-packages)
(package-refresh-contents)
(mapc #'package-install package-selected-packages))
;; sample `helm' configuration use https://github.com/emacs-helm/helm/ for details
(helm-mode)
(require 'helm-xref)
(define-key global-map [remap find-file] #'helm-find-files)
(define-key global-map [remap execute-extended-command] #'helm-M-x)
(define-key global-map [remap switch-to-buffer] #'helm-mini)
(which-key-mode)
(add-hook 'c-mode-hook 'lsp)
(add-hook 'cpp-mode-hook 'lsp)
(setq gc-cons-threshold (* 100 1024 1024)
read-process-output-max (* 1024 1024)
treemacs-space-between-root-nodes nil
company-idle-delay 0.0
company-minimum-prefix-length 1
lsp-idle-delay 0.1 ;; clangd is fast
;; be more ide-ish
lsp-headerline-breadcrumb-enable t)
(with-eval-after-load 'lsp-mode
(add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration)
(require 'dap-cpptools)
(yas-global-mode))
;; Turn on company mode for prog and cmake derived modes
(add-hook 'prog-mode-hook 'company-mode)
(add-hook 'cmake-mode-hook 'company-mode)
;; --------- Random keybinds and specifics ----------
;; linum mode spacing
(setq linum-format "%d ")
(when (version<= "26.0.50" emacs-version )
(global-display-line-numbers-mode))
;; Cursor change in evil
(setq evil-normal-state-cursor '(box "light blue")
evil-insert-state-cursor '(bar "medium sea green")
evil-visual-state-cursor '(hollow "orange"))
;; Enable mouse
(xterm-mouse-mode 1)
;; Comment uncomment shortcuts
(global-set-key (kbd "C-a") 'comment-region)
(global-set-key (kbd "C-s") 'uncomment-region)
;; ------- Auto generated stuff -------------
(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.
'(inhibit-startup-screen t)
'(package-selected-packages
'(airline-themes use-package evil-visualstar evil-surround evil-replace-with-register evil-lion evil-goggles evil-expat evil-exchange evil-commentary evil-collection)))
(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.
)