-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemacs.el
219 lines (176 loc) · 6.67 KB
/
emacs.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
(menu-bar-mode -1)
(tool-bar-mode -1)
(show-paren-mode 1)
(xclip-mode 1)
(xterm-mouse-mode 1)
(toggle-scroll-bar -1)
(set-default 'truncate-lines t)
;; Automatically reload files when they change on disk
(setq auto-revert-check-vc-info t)
(setq auto-revert-avoid-polling t)
(global-auto-revert-mode t)
;; Used for snippets, for example auto complete an implementation for an interface
(require 'yasnippet)
(yas-global-mode 1)
;;set gdb debugger to use separate window
(setq gdb-many-windows t gdb-use-separate-io-buffer t)
;;highlight current line number
(setq column-number-mode t)
;;scroll window up/down by one line
(global-set-key (kbd "M-n") (kbd "C-u 1 C-v"))
(global-set-key (kbd "M-p") (kbd "C-u 1 M-v"))
;; dap mode debugging
(require 'dap-lldb)
(dap-auto-configure-mode 1)
(set-default 'dap-lldb-degub-program "lldb-vscode")
;; C/C++
(setq-default c-basic-offset 4)
(add-hook 'before-save-hook (lambda () (when (or (eq 'c-mode major-mode) (eq 'c++-mode major-mode))
(lsp-format-buffer))))
;; LLVM style for C/C++
(defun llvm-lineup-statement (langelem)
(let ((in-assign (c-lineup-assignments langelem)))
(if (not in-assign)
'++
(aset in-assign 0
(+ (aref in-assign 0)
(* 2 c-basic-offset)))
in-assign)))
;; Add a cc-mode style for editing LLVM C and C++ code
(c-add-style "llvm.org"
'("gnu"
(fill-column . 80)
(c++-indent-level . 2)
(c-basic-offset . 2)
(indent-tabs-mode . nil)
(c-offsets-alist . ((arglist-intro . ++)
(innamespace . 0)
(member-init-intro . ++)
(statement-cont . llvm-lineup-statement)))))
(add-to-list 'c-default-style '(other . "llvm.org"))
;; color compilation mode
(when (require 'ansi-color nil t)
(defun my-colorize-compilation-buffer ()
(when (eq major-mode 'compilation-mode)
(ansi-color-apply-on-region compilation-filter-start (point-max))))
(add-hook 'compilation-filter-hook 'my-colorize-compilation-buffer))
;; addon for java lsp
(require 'lsp-java)
(add-hook 'java-mode-hook #'lsp)
;; helm
(helm-mode 1)
(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "C-x C-f") 'helm-find-files)
;; do not use tabs
(setq-default indent-tabs-mode nil)
;; Windmove default for moving between buffers with shift + arrow
(windmove-default-keybindings)
;; Override defaukt to work in terminal
(global-set-key (kbd "C-c <left>") 'windmove-left)
(global-set-key (kbd "C-c <right>") 'windmove-right)
(global-set-key (kbd "C-c <up>") 'windmove-up)
(global-set-key (kbd "C-c <down>") 'windmove-down)
(global-display-line-numbers-mode 1)
(setq neo-show-hidden-files t)
(global-set-key (kbd "C-x g") 'magit-status)
(global-whitespace-mode 1)
(set-face-attribute 'default nil :height 100)
;; example of setting env var named “path”, by appending a new path to existing path
(setenv "FZF_DEFAULT_COMMAND"
"rg --files"
)
(prefer-coding-system 'utf-8)
(set-language-environment 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(set-file-name-coding-system 'utf-8)
(set-clipboard-coding-system 'utf-8)
(set-buffer-file-coding-system 'utf-8)
(setq locale-coding-system 'utf-8)
(setq require-final-newline t)
(add-hook 'after-init-hook (lambda ()
(load-theme 'nord t)
;;(neotree-dir (getenv "PWD"))
(projectile-mode +1)
(global-set-key (kbd "C-x p") 'fzf)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
(global-set-key [f8] 'neotree-toggle)
(neotree-hide)
(require 'yaml-mode)
(add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode))
(require 'protobuf-mode)
;; Add lsp which key mode integration (help command text at bottom)
(which-key-mode)
))
(require 'lsp-mode)
(setq-default lsp-signature-render-documentation nil)
(setq-default lsp-rust-analyzer-cargo-watch-command "clippy")
(setq-default lsp-rust-analyzer-cargo-watch-enable t)
(setq-default lsp-rust-analyzer-cargo-all-targets t)
(setq-default lsp-rust-all-features t)
(setq-default lsp-rust-all-targets t)
(setq-default lsp-pyls-plugins-pylint-enabled t)
(setq-default lsp-pyls-plugins-flake8-enabled t)
(add-hook 'python-mode-hook #'lsp)
(add-hook 'elm-mode-hook #'lsp)
(add-hook 'elm-mode-hook 'elm-format-on-save-mode)
(add-hook 'python-mode-hook 'blacken-mode)
(add-hook 'c-mode-common-hook #'lsp)
;; Add rainbow delimiters for rust language
(add-hook 'rust-mode-hook #'rainbow-delimiters-mode)
;; Add rainbow delimiters for most languages
;;(add-hook 'prog-mode-hook #'rainbow-delimiters-mode)
(require 'rust-mode)
(add-hook 'rust-mode-hook
(lambda ()
(setq indent-tabs-mode nil)
(setq lsp-rust-server 'rust-analyzer)
(cargo-minor-mode)
(lsp)))
(add-hook 'c-mode-hook
(lambda ()
(lsp)))
(add-hook 'before-save-hook (lambda () (when (eq 'rust-mode major-mode)
(lsp-format-buffer))))
(eval-after-load 'flymake
(progn
(require 'flymake-diagnostic-at-point)
(add-hook 'flymake-mode-hook #'flymake-diagnostic-at-point-mode)))
(add-hook 'neo-after-create-hook
(lambda (&rest _) (display-line-numbers-mode -1)))
;; Put auto save files somewhere else which is surprisingly hard to do
(setq backup-directory-alist '((".*" . "~/.skit")))
(setq auto-save-file-name-transforms '((".*" "~/.skit/\\1" t)))
(setq create-lockfiles nil)
;; protobuff
(defconst my-protobuf-style
'((c-basic-offset . 2)
(indent-tabs-mode . nil)))
(add-hook 'protobuf-mode-hook
(lambda () (c-add-style "my-style" my-protobuf-style t)))
;; add hook for which-key-mode
(with-eval-after-load 'lsp-mode
(add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration))
;;Clojure
;; Format on save
(add-hook 'before-save-hook
(lambda ()
(when (or
(eq 'clojure-mode major-mode)
(eq 'clojurescript-mode major-mode))
(lsp-format-buffer))))
;; Add rainbow delimiters for lsp
(add-hook 'lsp-mode-hook #'rainbow-delimiters-mode)
(add-hook 'clojure-mode-hook 'lsp)
(add-hook 'clojurescript-mode-hook 'lsp)
(add-hook 'clojurec-mode-hook 'lsp)
(setq gc-cons-threshold (* 100 1024 1024)
read-process-output-max (* 1024 1024)
treemacs-space-between-root-nodes nil
company-minimum-prefix-length 1
lsp-signature-auto-activate nil
; lsp-enable-indentation nil ; uncomment to use cider indentation instead of lsp
; lsp-enable-completion-at-point nil ; uncomment to use cider completion instead of lsp
)