blob: ff66b689661d3931d98f63fb769e15194993810f (
plain) (
blame)
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
|
;; dotfiles -- emacs.johannst.el
;; author: johannst
(provide 'johannst)
;; config
(custom-set-variables
'(font-use-system-font t)
'(indent-tabs-mode nil)
'(inhibit-startup-screen t)
'(tool-bar-mode nil)
'(whitespace-style '(face trailing space-before-tab newline indentation empty space-after-tab tab-mark))
'(global-whitespace-mode t)
'(backup-directory-alist `(("." . "~/.emacs.saves")))
'(display-line-numbers 'relative)
)
;; global kbd maps
(global-set-key (kbd "C-x C-b") 'ibuffer)
(define-key isearch-mode-map (kbd "M-o") 'isearch-occur)
;; only y/n prompt (no RET needed)
(defalias 'yes-or-no-p 'y-or-n-p)
;; fix 'bad request' on package-refresh-contents (should be fixed with emcas 26.3)
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
;; ELPA & MELPA
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/") t)
(setq package-enable-at-startup nil)
(package-initialize)
;; bootstrap use-package
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-when-compile
(require 'use-package))
;; theme
(use-package spacemacs-theme
:ensure t
:defer t
:init
(load-theme 'spacemacs-dark t)
)
;; evil
(use-package evil
:ensure t
:config
(evil-mode t)
;; leader key
(defvar leader-map (make-sparse-keymap)
"Keymap for <leader> key.")
(define-key evil-normal-state-map (kbd "SPC") leader-map)
;; scrolling
(define-key evil-normal-state-map (kbd "C-k") 'evil-scroll-up)
(define-key evil-normal-state-map (kbd "C-j") 'evil-scroll-down)
)
;; undo-tree (optional dependency for evil to get vim like undo/redo)
(use-package undo-tree
:ensure t
:config
(global-undo-tree-mode t)
)
;; org
(use-package org
:bind
(("\C-cc" . org-capture)
:map org-mode-map
("M-j" . org-metadown)
("M-h" . org-metaleft)
("M-l" . org-metaright)
("M-k" . org-metaup)
)
:config
(setq org-directory "~/org")
(setq org-default-notes-file (concat org-directory "/capture.org"))
(setq org-log-done t)
(setq org-confirm-babel-evaluate nil)
(setq org-todo-keywords '((sequence "TODO" "WAIT" "DONE")))
(setq org-hide-leading-stars t)
)
;; helm
;(use-package helm
; :ensure t
; :config
; (define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action)
; (define-key helm-map (kbd "C-z") 'helm-select-action)
; (define-key leader-map "pf" 'helm-projectile-find-file)
; (helm-mode t)
; )
;; helm
;(use-package helm-projectile
; :ensure t
; )
;; ivy-xref
(use-package ivy-xref
:ensure t
)
;; magit
(use-package magit
:ensure t
)
;; lsp
(use-package lsp-mode
:ensure t
:config
(setq lsp-rust-server 'rust-analyzer
lsp-rust-analyzer-server-display-inlay-hints t
lsp-rust-analyzer-display-chaining-hints t
lsp-rust-analyzer-display-parameter-hints t
)
:hook (
(c-mode . lsp)
(c++-mode . lsp)
)
)
;; lsp ui
(use-package lsp-ui
:ensure t
:config (setq
lsp-ui-doc-enable nil
lsp-ui-sideline-enable t
)
)
;; company
(use-package company
:ensure t
:config
; (global-company-mode t)
(setq company-idle-delay 0
company-minimum-prefix-length 1
company-show-numbers t
company-dabbrev-downcase nil
company-tooltip-align-annotations t
)
:hook (
(rust-mode . company-mode)
(c-mode . company-mode)
(c++-mode . (lambda ()
(company-mode)
(add-to-list 'company-dabbrev-code-modes 'c++-mode)))
)
:bind (
:map company-mode-map
("<tab>" . company-indent-or-complete-common)
:map company-active-map
("C-p" . 'company-select-previous-or-abort)
("C-n" . 'company-select-next-or-abort)
("<backtab>" . 'company-select-previous-or-abort)
("<tab>" . 'company-select-next-or-abort)
)
)
;; company-c-headers
(use-package company-c-headers
:ensure t
:requires (company)
:config
(add-to-list 'company-backends 'company-c-headers)
;; simple heuristic to find latest c++ headers installed on system
(add-to-list 'company-c-headers-path-system (concat "/usr/include/c++/" (car (last (directory-files "/usr/include/c++" nil "^[1-9]")))))
)
;; rust-mode
(use-package rust-mode
:ensure t
:mode ("\\.rs\\'" . rust-mode)
:hook
(rust-mode . lsp)
)
;; clang-format
(use-package clang-format
:ensure t
)
|