PPaste!

Emacs - 2020/01/27

Home - All the pastes - Authored by Thooms

Raw version

  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
;; Package management

(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))
(package-initialize)

(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

(eval-when-compile
  (require 'use-package))


;; Ask "y" or "n" instead of "yes" or "no". Yes, laziness is great.

(fset 'yes-or-no-p 'y-or-n-p)

;; Highlight corresponding parentheses when cursor is on one

(show-paren-mode t)

;; Highlight tabulations

(setq-default highlight-tabs t)

;; Show trailing white spaces

(setq-default show-trailing-whitespace t)

;; Remove useless whitespace before saving a file

(add-hook 'before-save-hook 'whitespace-cleanup)
(add-hook 'before-save-hook (lambda() (delete-trailing-whitespace)))

;; Final newline handling

(setq require-final-newline t)

;; Save do not use backup files (we have git for this)

(setq backup-directory-alist '(("." . "~/.saves")))
(setq make-backup-files nil)
(setq auto-save-default nil)
(setq create-lockfiles nil)

(setq inhibit-splash-screen t
      initial-scratch-message nil)
(scroll-bar-mode -1)
(tool-bar-mode -1)
(menu-bar-mode -1)
(setq column-number-mode t)

;; Replace audible alarm with a visual bell

(setq ring-bell-function
      (lambda ()
	(let ((orig-fg (face-foreground 'mode-line)))
	  (set-face-foreground 'mode-line "#F2804F")
	  (run-with-idle-timer 0.1 nil
			       (lambda (fg) (set-face-foreground 'mode-line fg))
			       orig-fg))))

;; Useful when coding

(global-set-key (kbd "C-c C-c") 'comment-or-uncomment-region)

;; Better modeline

(use-package smart-mode-line
  :ensure t
  :init
  (setq sml/no-confirm-load-theme t)
  (setq sml/theme 'dark)
  (sml/setup))

;; Editor theme

(use-package gruvbox-theme
  :ensure t
  :config
  (defun frame-config (frame)
    "Custom behavior on new frames"
    (with-selected-frame frame
      (when (display-graphic-p)
	(setq frame-title-format '(buffer-file-name "%f" ("%b")))
	(set-face-attribute 'default nil
			    :font "Inconsolata-14"))
      (if (display-graphic-p)
	  (load-theme 'gruvbox-dark-hard t)
	(load-theme 'gruvbox-dark-hard t))
      ))
  (frame-config (selected-frame))
  (add-hook 'after-make-frame-functions 'frame-config))


;; Correctly find environment variables

(use-package exec-path-from-shell
  :ensure t
  :init
  (setq shell-file-name "/usr/local/bin/zsh")
    (setq exec-path-from-shell-variables '("PATH" "MANPATH" "PKG_CONFIG_PATH"))
    (exec-path-from-shell-initialize))

;; Helm -- Search tool

(use-package helm
    :ensure t
    :config
    (setq helm-split-window-default-side 'other)
    (helm-mode 1)
    (helm-autoresize-mode 1)
    (define-key helm-find-files-map
      (kbd "<backtab>") #'helm-select-action)
    (define-key helm-find-files-map
      (kbd "C-i")  #'helm-execute-persistent-action)
    :bind
    (("M-x" . helm-M-x)
     ("M-y" . helm-show-kill-ring)
     ("C-x C-f" . helm-find-files)
     ;("C-c o" . helm-occur)
     ("C-x b" . helm-mini)
     ;("C-x r b" . helm-bookmarks)
     ;("C-h a" . helm-apropos)
     ;("C-h d" . helm-info-at-point)
     ;("C-c L" . helm-locate)
     ;("C-c r" . helm-resume)
     ;("C-c i" . helm-imenu)
     ))

;; Projectile -- Project management

(use-package projectile
  :ensure t
  :config
  (require 'helm)
  (projectile-mode t)
  (setq projectile-completion-system 'helm)
  (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map))


;; Company -- Autocompletion

(use-package company
  :ensure t
  :defer t
  :diminish (company-mode . " ⓐ")
  :init
  (global-company-mode)
  :config
  (setq company-tooltip-align-annotations t
	company-idle-delay 0.2
	company-minimum-prefix-length 1
	company-require-match nil
	company-begin-commands '(self-insert-command)
	company-echo-delay 0
	company-tooltip-limit 20
	))

;; Show help in tooltip

(use-package company-quickhelp
    :ensure t
    :defer t
    :init (with-eval-after-load 'company
	    (company-quickhelp-mode)))

;; LSP

(use-package lsp-mode
  :ensure t
  :commands (lsp lsp-deferred)
  :hook (go-mode . lsp-deferred))

(use-package lsp-ui
  :ensure t
  :commands lsp-ui-mode
  :init
  )

(use-package company-lsp
  :ensure t
  :commands company-lsp)

(setq lsp-ui-doc-enable nil
      lsp-ui-peek-enable t
      lsp-ui-sideline-enable t
      lsp-ui-imenu-enable t
      lsp-ui-flycheck-enable t)



;; Go-specific modding

(use-package go-mode
  :defer t
  :ensure t
  :mode ("\\.go\\'" . go-mode)
  :bind (("M-." . godef-jump)))

(defun lsp-go-install-save-hooks ()
  (add-hook 'before-save-hook #'lsp-format-buffer t t)
  (add-hook 'before-save-hook #'lsp-organize-imports t t))
(add-hook 'go-mode-hook #'lsp-go-install-save-hooks)


;; Automatic 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.
 '(package-selected-packages
   (quote
    (company-lsp lsp-ui lsp-mode go-mode gruvbox-theme company-quickhelp company exec-path-from-shell nyx-theme smart-mode-line use-package))))
(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.
 )