aboutsummaryrefslogtreecommitdiff
path: root/share/home/emacs/emacs.el
blob: 8eb5a894fe384f692eb3ad1110be235f9c29fc9e (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
;; -*- lexical-binding: t -*-
;;; emacs-config --- My emacs config
;;;
;;; Commentary:
;;; Various resources were used to hack together this config:
;;; - https://sanemacs.com/
;;; - https://rossabaker.com/configs/emacs/
;;;
;;; Code:

;;; Early stuff
(use-package benchmark-init
  :ensure t
  :demand t
  :hook (after-init . benchmark-init/deactivate)
  :config
  (benchmark-init/activate))

;;; GC
(use-package gcmh
  :ensure t
  :diminish
  :init (setq gc-cons-threshold (* 80 1024 1024))
  :hook (emacs-startup . gcmh-mode))

;; Trusted connections?
(use-package gnutls
  :defer t
  :custom
  (gnutls-verify-error t))

(use-package no-littering
  :ensure t
  :init
  (setq no-littering-etc-directory "~/.cache/emacs/etc/"
        no-littering-var-directory "~/.cache/emacs/var/")
  (when (fboundp 'startup-redirect-eln-cache)
    (startup-redirect-eln-cache
     (convert-standard-filename
      (expand-file-name  "eln-cache/" no-littering-var-directory)))))

;;; use-package keywords
(use-package bind-key
  :demand t
  :bind
  (:prefix-map rab/files-map
   :prefix "C-c f")
  :bind
  (:prefix-map rab/toggles-map
   :prefix "C-c t"))

(use-package diminish :ensure t)

;;; Disable menu-bar, tool-bar, and scroll-bar.
(if (fboundp 'menu-bar-mode)
    (menu-bar-mode -1))
(if (fboundp 'tool-bar-mode)
    (tool-bar-mode -1))
(if (fboundp 'scroll-bar-mode)
    (scroll-bar-mode -1))

;;; Setup package.el
(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(unless package--initialized (package-initialize))

;;; Setup use-package
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))
(eval-when-compile
  (require 'use-package))
(setq use-package-always-ensure t)

;;; Useful Defaults
(setq-default cursor-type 'bar)           ; Line-style cursor similar to other text editors
(setq inhibit-startup-screen t)           ; Disable startup screen
(setq initial-scratch-message "")         ; Make *scratch* buffer blank
(setq-default frame-title-format '("%b")) ; Make window title the buffer name
(setq ring-bell-function 'ignore)         ; Disable bell sound
(fset 'yes-or-no-p 'y-or-n-p)             ; y-or-n-p makes answering questions faster
(show-paren-mode 1)                       ; Show closing parens by default
(global-auto-revert-mode t)               ; Auto-update buffer if file has changed on disk
(setopt create-lockfiles nil)

(use-package display-line-numbers
  :custom
  (display-line-numbers-widen t)
  :hook
  ((prog-mode conf-mode) . display-line-numbers-mode))

(use-package hl-line
  :hook (on-first-buffer . global-hl-line-mode))

;;; Load wheatgrass as the default theme if one is not loaded already
(if (not custom-enabled-themes)
    (load-theme 'wheatgrass t))

;; Autopairs
(electric-pair-mode 1)

;; Set up vi keybinds
(use-package evil
  :config
  (evil-mode 1))

(use-package envrc
  :ensure t
  :hook (on-first-file . envrc-global-mode))

(use-package nix-mode
  :mode "\\.nix\\'")

;; Set up proof general for working with coq
(use-package proof-general
  :mode ("\\.v\\'" . coq-mode))

(use-package flycheck
  :init (global-flycheck-mode))

(use-package company
  :init (global-company-mode))

(use-package helm
  :init
  (helm-mode 1)
  :config
  (setq helm-completion-style 'emacs))

(use-package fussy
  :config
  (push 'fussy completion-styles)
  (setq
   ;; For example, project-find-file uses 'project-files which uses
   ;; substring completion by default. Set to nil to make sure it's using
   ;; flx.
   completion-category-defaults nil
   completion-category-overrides nil))

(use-package projectile
  :bind-keymap ("C-c p" . projectile-command-map)
  :config
  (projectile-mode +1))

;;; emacs.el ends here