about summary refs log tree commit diff
path: root/init
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2018-06-22T08·29+0200
committerVincent Ambo <github@tazj.in>2019-02-10T20·43+0100
commit4fe8d78dbb16dbec2b8c173a5142b4b14927fd28 (patch)
tree481bd47ba446167088f846f9eeb383a847dc7d86 /init
parentf0dfc8b06de568e57050510a5b56fcbb725a6733 (diff)
refactor: Begin moving package configuration to use-package
This is the first in a series of commits for refactoring my
configuration to make use of jwiegley's use-package.

In the previous layout of the configuration there were some questions
around what settings go into which file, but in the end it is all just
related to which packages are being configured (besides settings
related to global Emacs behaviour).

This commit introduces use-package forms for all currently used
packages (which are still installed via Nix, not via package.el) but
does not yet clean up the rest of the configuration in a suitable way.

Note that this version introduces a bug in which the configuration of
telephone line is not correctly initialised after package setup.
Diffstat (limited to 'init')
-rw-r--r--init/bindings.el12
-rw-r--r--init/haskell-setup.el5
-rw-r--r--init/lisp-setup.el21
-rw-r--r--init/look-and-feel.el63
-rw-r--r--init/modes.el33
-rw-r--r--init/nixos.el133
-rw-r--r--init/rust-setup.el23
-rw-r--r--init/settings.el17
-rw-r--r--init/term-setup.el16
9 files changed, 97 insertions, 226 deletions
diff --git a/init/bindings.el b/init/bindings.el
index cb793f7253ec..f10869a5325f 100644
--- a/init/bindings.el
+++ b/init/bindings.el
@@ -14,16 +14,9 @@
 ;; Counsel stuff:
 (global-set-key (kbd "C-c r g") 'counsel-rg)
 
-;; Avy mode
-(global-set-key (kbd "M-j") 'avy-goto-char)
-(global-set-key (kbd "M-p") 'avy-pop-mark)
-
 ;; imenu instead of insert-file
 (global-set-key (kbd "C-x i") 'imenu)
 
-(global-set-key (kbd "C-x o") ; Yes, I went there!
-                'ace-window)
-
 ;; Window switching. (C-x o goes to the next window)
 (windmove-default-keybindings) ;; Shift+direction
 
@@ -33,12 +26,7 @@
 ;; Start a new eshell even if one is active.
 (global-set-key (kbd "C-x M") (lambda () (interactive) (eshell t)))
 
-;; Magit!
-(global-set-key (kbd "C-c g") 'magit-status)
 (global-set-key (kbd "C-x p") 'ivy-browse-repositories)
-
-;; Replace standard goto-line with ace-jump-line-mode
-(global-set-key (kbd "M-g g") 'avy-goto-line)
 (global-set-key (kbd "M-g M-g") 'goto-line-with-feedback)
 
 (global-set-key (kbd "C-c w") 'whitespace-cleanup)
diff --git a/init/haskell-setup.el b/init/haskell-setup.el
deleted file mode 100644
index 23de004cde75..000000000000
--- a/init/haskell-setup.el
+++ /dev/null
@@ -1,5 +0,0 @@
-(require 'haskell-mode)
-
-(add-hook 'haskell-mode-hook 'intero-mode)
-
-(provide 'haskell-setup)
diff --git a/init/lisp-setup.el b/init/lisp-setup.el
deleted file mode 100644
index e117817e3f1c..000000000000
--- a/init/lisp-setup.el
+++ /dev/null
@@ -1,21 +0,0 @@
-;; lisp-settings.el - settings for various Lisp dialects
-;; -*- lexical-binding: t; -*-
-
-(require 'adjust-parens)
-(require 'sly)
-
-;; All the lisps:
-
-(add-to-list 'lisp-mode-hook #'company-mode)
-(add-to-list 'lisp-mode-hook #'paredit-mode)
-(add-to-list 'lisp-mode-hook #'adjust-parens-mode)
-
-(define-key lisp-mode-map (kbd "TAB")
-  #'company-indent-or-complete-common)
-
-;; Common Lisp:
-(setq inferior-lisp-program (concat (nix-store-path "sbcl") "/bin/sbcl"))
-
-(add-to-list 'company-backends 'sly-company)
-
-(provide 'lisp-setup)
diff --git a/init/look-and-feel.el b/init/look-and-feel.el
index 555feca43fcf..3d480bd5f43e 100644
--- a/init/look-and-feel.el
+++ b/init/look-and-feel.el
@@ -1,7 +1,5 @@
 ;;; -*- lexical-binding: t; -*-
 
-(require 'telephone-line)
-
 ;; Hide those ugly tool bars:
 (tool-bar-mode 0)
 (scroll-bar-mode 0)
@@ -46,36 +44,37 @@
   (when (bottom-right-window-p)
       (telephone-line-raw mode-line-misc-info t)))
 
-(telephone-line-defsegment telephone-line-last-window-segment ()
-  (telephone-misc-if-last-window))
-
-;; Display the current EXWM workspace index in the mode-line
-(telephone-line-defsegment telephone-line-exwm-workspace-index ()
-  (when (bottom-right-window-p)
-    (format "[%s]" exwm-workspace-current-index)))
-
-;; Define a highlight font for ~ important ~ information in the last
-;; window.
-(defface special-highlight '((t (:foreground "white" :background "#5f627f"))) "")
-(add-to-list 'telephone-line-faces
-             '(highlight . (special-highlight . special-highlight)))
-
-(setq telephone-line-lhs
-      '((nil . (telephone-line-position-segment))
-        (accent . (telephone-line-buffer-segment))))
-
-(setq telephone-line-rhs
-      '((accent . (telephone-line-major-mode-segment))
-        (nil . (telephone-line-last-window-segment
-                telephone-line-exwm-workspace-index))
-        (highlight . (telephone-line-notmuch-counts))))
-
-(setq telephone-line-primary-left-separator 'telephone-line-tan-left
-      telephone-line-primary-right-separator 'telephone-line-tan-right
-      telephone-line-secondary-left-separator 'telephone-line-tan-hollow-left
-      telephone-line-secondary-right-separator 'telephone-line-tan-hollow-right)
-
-(telephone-line-mode 1)
+(defun telephone-line-setup ()
+  (telephone-line-defsegment telephone-line-last-window-segment ()
+    (telephone-misc-if-last-window))
+
+  ;; Display the current EXWM workspace index in the mode-line
+  (telephone-line-defsegment telephone-line-exwm-workspace-index ()
+    (when (bottom-right-window-p)
+      (format "[%s]" exwm-workspace-current-index)))
+
+  ;; Define a highlight font for ~ important ~ information in the last
+  ;; window.
+  (defface special-highlight '((t (:foreground "white" :background "#5f627f"))) "")
+  (add-to-list 'telephone-line-faces
+               '(highlight . (special-highlight . special-highlight)))
+
+  (setq telephone-line-lhs
+        '((nil . (telephone-line-position-segment))
+          (accent . (telephone-line-buffer-segment))))
+
+  (setq telephone-line-rhs
+        '((accent . (telephone-line-major-mode-segment))
+          (nil . (telephone-line-last-window-segment
+                  telephone-line-exwm-workspace-index))
+          (highlight . (telephone-line-notmuch-counts))))
+
+  (setq telephone-line-primary-left-separator 'telephone-line-tan-left
+        telephone-line-primary-right-separator 'telephone-line-tan-right
+        telephone-line-secondary-left-separator 'telephone-line-tan-hollow-left
+        telephone-line-secondary-right-separator 'telephone-line-tan-hollow-right)
+
+  (telephone-line-mode 1))
 
 ;; Auto refresh buffers
 (global-auto-revert-mode 1)
diff --git a/init/modes.el b/init/modes.el
index d9a27c52a411..19ed2a684349 100644
--- a/init/modes.el
+++ b/init/modes.el
@@ -1,14 +1,6 @@
 ;; Initializes modes I use.
 
 (add-hook 'prog-mode-hook 'esk-add-watchwords)
-(add-hook 'prog-mode-hook 'idle-highlight-mode)
-
-;; Configure markdown-mode
-(autoload 'markdown-mode "markdown-mode"
-  "Major mode for editing Markdown files" t)
-(add-to-list 'auto-mode-alist '("\\.txt\\'" . markdown-mode))
-(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
-(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
 
 ;; Use auto-complete as completion at point
 (defun set-auto-complete-as-completion-at-point-function ()
@@ -17,35 +9,18 @@
 (add-hook 'auto-complete-mode-hook
           'set-auto-complete-as-completion-at-point-function)
 
-;; Configure Erlang mode
-
-(defun erlang-mode-init-setup ()
-  (interactive)
-  ;; Don't indent after '>' while I'm writing
-  (local-set-key ">" 'self-insert-command)
-  ;;(local-set-key "RET" 'newline)
-  (rainbow-delimiters-mode 1)
-  )
-
-(add-hook 'erlang-mode-hook 'erlang-mode-init-setup)
-
 ;; Enable rainbow-delimiters for all things programming
 (add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
 
 ;; Enable Paredit & Company in Emacs Lisp mode
-(add-hook 'emacs-lisp-mode-hook 'paredit-mode)
 (add-hook 'emacs-lisp-mode-hook 'company-mode)
 
 ;; Always highlight matching brackets
 (show-paren-mode 1)
 
 ;; Always auto-close parantheses and other pairs
-(electric-pair-mode)
-
-;; Represent undo-history as an actual tree (visualize with C-x u)
-(setq undo-tree-mode-lighter "")
-(require 'undo-tree)
-(global-undo-tree-mode)
+;; (replaced by smartparens)
+;; (electric-pair-mode)
 
 ;; Keep track of recent files
 (recentf-mode)
@@ -57,9 +32,5 @@
 (auto-compression-mode t)
 
 ;; Show available key chord completions
-(which-key-mode t)
-
-;; Show previews of ace-window numbers in the mode line for each window.
-(ace-window-display-mode)
 
 (provide 'modes)
diff --git a/init/nixos.el b/init/nixos.el
index 431ba705c3bc..f3cefea7f391 100644
--- a/init/nixos.el
+++ b/init/nixos.el
@@ -6,11 +6,6 @@
 (require 'f)
 (require 'dash)
 
-(defvar is-nixos
-  (let ((os-f "/etc/os-release"))
-    (s-contains?
-     "NixOS" (if (f-file? os-f) (f-read os-f)))))
-
 (defun pulseaudio-ctl (cmd)
   (shell-command (concat "pulseaudio-ctl " cmd))
   (message "Volume command: %s" cmd))
@@ -38,70 +33,68 @@
               (0 "eDP1")
               ,(-map (lambda (n) (list n "eDP1")) (number-sequence 6 9)))))
 
-(if is-nixos
-    (progn
-      (message "Running on NixOS, configuring ExWM.")
-      (require 'exwm)
-      (require 'exwm-config)
-
-      (fringe-mode 3)
-
-      (setq exwm-workspace-number 10)
-      ;; Make class name the buffer name
-      (add-hook 'exwm-update-class-hook
-                (lambda ()
-                  (exwm-workspace-rename-buffer exwm-class-name)))
-
-      ;; 's-r': Reset
-      (exwm-input-set-key (kbd "s-r") #'exwm-reset)
-      ;; 's-w': Switch workspace
-      (exwm-input-set-key (kbd "s-w") #'exwm-workspace-switch)
-      ;; 's-N': Switch to certain workspace
-      (dotimes (i 10)
-        (exwm-input-set-key (kbd (format "s-%d" i))
-                            `(lambda ()
-                               (interactive)
-                               (exwm-workspace-switch-create ,i))))
-
-      ;; Launch applications with completion (dmenu style!)
-      (exwm-input-set-key (kbd "s-d") #'ivy-run-external-command)
-      (exwm-input-set-key (kbd "s-p") #'ivy-password-store)
-      (exwm-input-set-key (kbd "C-s-p") '(lambda ()
-                                           (interactive)
-                                           (ivy-password-store "~/.aprila-secrets")))
-
-      ;; Toggle between line-mode / char-mode
-      (exwm-input-set-key (kbd "C-c C-t C-t") #'exwm-input-toggle-keyboard)
-
-      ;; Volume keys
-      (exwm-input-set-key (kbd "<XF86AudioMute>") #'volume-mute)
-      (exwm-input-set-key (kbd "<XF86AudioRaiseVolume>") #'volume-up)
-      (exwm-input-set-key (kbd "<XF86AudioLowerVolume>") #'volume-down)
-
-      ;; Brightness keys
-      (exwm-input-set-key (kbd "<XF86MonBrightnessDown>") #'brightness-down)
-      (exwm-input-set-key (kbd "<XF86MonBrightnessUp>") #'brightness-up)
-      (exwm-input-set-key (kbd "<XF86Display>") #'lock-screen)
-
-      ;; Line-editing shortcuts
-      (exwm-input-set-simulation-keys
-       '(([?\C-d] . delete)
-         ([?\C-w] . ?\C-c)))
-
-      ;; Enable EXWM
-      (exwm-enable)
-
-      ;; Show time in the mode line
-      (display-time-mode)
-
-      ;; Configure xrandr when running on laptop
-      (when (equal (shell-command-to-string "hostname") "adho\n")
-        (require 'exwm-randr)
-        (setq exwm-randr-workspace-output-plist (generate-randr-config))
-        (exwm-randr-enable))
-
-      ;; Let buffers move seamlessly between workspaces
-      (setq exwm-workspace-show-all-buffers t)
-      (setq exwm-layout-show-all-buffers t)))
+(use-package exwm
+  :hook ((exwm-update-class . (lambda ()
+                                ;; Make class name the buffer name
+                                (exwm-workspace-rename-buffer exwm-class-name))))
+  :init
+  (progn
+    (require 'exwm-config)
+
+    (fringe-mode 3)
+
+    (setq exwm-workspace-number 10)
+
+    ;; 's-r': Reset
+    (exwm-input-set-key (kbd "s-r") #'exwm-reset)
+    ;; 's-w': Switch workspace
+    (exwm-input-set-key (kbd "s-w") #'exwm-workspace-switch)
+    ;; 's-N': Switch to certain workspace
+    (dotimes (i 10)
+      (exwm-input-set-key (kbd (format "s-%d" i))
+                          `(lambda ()
+                             (interactive)
+                             (exwm-workspace-switch-create ,i))))
+
+    ;; Launch applications with completion (dmenu style!)
+    (exwm-input-set-key (kbd "s-d") #'ivy-run-external-command)
+    (exwm-input-set-key (kbd "s-p") #'ivy-password-store)
+    (exwm-input-set-key (kbd "C-s-p") '(lambda ()
+                                         (interactive)
+                                         (ivy-password-store "~/.aprila-secrets")))
+
+    ;; Toggle between line-mode / char-mode
+    (exwm-input-set-key (kbd "C-c C-t C-t") #'exwm-input-toggle-keyboard)
+
+    ;; Volume keys
+    (exwm-input-set-key (kbd "<XF86AudioMute>") #'volume-mute)
+    (exwm-input-set-key (kbd "<XF86AudioRaiseVolume>") #'volume-up)
+    (exwm-input-set-key (kbd "<XF86AudioLowerVolume>") #'volume-down)
+
+    ;; Brightness keys
+    (exwm-input-set-key (kbd "<XF86MonBrightnessDown>") #'brightness-down)
+    (exwm-input-set-key (kbd "<XF86MonBrightnessUp>") #'brightness-up)
+    (exwm-input-set-key (kbd "<XF86Display>") #'lock-screen)
+
+    ;; Line-editing shortcuts
+    (exwm-input-set-simulation-keys
+     '(([?\C-d] . delete)
+       ([?\C-w] . ?\C-c)))
+
+    ;; Enable EXWM
+    (exwm-enable)
+
+    ;; Show time in the mode line
+    (display-time-mode)
+
+    ;; Configure xrandr when running on laptop
+    (when (equal (shell-command-to-string "hostname") "adho\n")
+      (require 'exwm-randr)
+      (setq exwm-randr-workspace-output-plist (generate-randr-config))
+      (exwm-randr-enable))
+
+    ;; Let buffers move seamlessly between workspaces
+    (setq exwm-workspace-show-all-buffers t)
+    (setq exwm-layout-show-all-buffers t)))
 
 (provide 'nixos)
diff --git a/init/rust-setup.el b/init/rust-setup.el
deleted file mode 100644
index cc61718c1d7e..000000000000
--- a/init/rust-setup.el
+++ /dev/null
@@ -1,23 +0,0 @@
-(require 'company)
-(require 'eglot)
-(require 'rust-mode)
-
-;; LSP configuration:
-(defvar rust-eglot-initialized nil)
-(add-hook 'rust-mode-hook (lambda ()
-                            (unless rust-eglot-initialized
-                              (call-interactively #'eglot)
-                              (setq rust-eglot-initialized t))))
-
-;; Enable cargo-related (C-c C-c C-...) commands.
-(add-hook 'rust-mode-hook #'cargo-minor-mode)
-
-;; Configure autocompletion for rust
-(add-hook 'rust-mode-hook #'company-mode)
-(define-key rust-mode-map (kbd "TAB") #'company-indent-or-complete-common)
-(setq company-tooltip-align-annotations t)
-
-;; Ensure long compiler errors don't flow out of the screen (very annoying!)
-(add-hook 'cargo-process-mode-hook #'visual-line-mode)
-
-(provide 'rust-setup)
diff --git a/init/settings.el b/init/settings.el
index 5d09dfb4d37d..2e4dedc0a535 100644
--- a/init/settings.el
+++ b/init/settings.el
@@ -1,7 +1,6 @@
 (require 'prescient)
 (require 'ivy-prescient)
 (require 'uniquify)
-(require 'password-store)
 (require 'ivy-pass)
 
 ;; Make ivy go!
@@ -63,20 +62,4 @@
 ;; Show time in 24h format
 (setq display-time-24hr-format t)
 
-;; Make ace-window behave in a sane way:
-(setq aw-keys '(?f ?j ?d ?k ?s ?l ?a)) ; Homerow keys in sensible order!
-(setq aw-scope 'frame) ; There are many frames in exwm, I don't care!
-
-;; Configure pinentry for use with GPG
-(setq epa-pinentry-mode 'loopback)
-(pinentry-start)
-
-;; Configure password-store as an auth-source
-;; (this requires emacs 26)
-(require 'auth-source-pass)
-(auth-source-pass-enable)
-
-;; Configure magit-repository-list
-(setq magit-repository-directories '(("/home/vincent/projects" . 2)))
-
 (provide 'settings)
diff --git a/init/term-setup.el b/init/term-setup.el
index e8c74387150c..ea58a53bbf04 100644
--- a/init/term-setup.el
+++ b/init/term-setup.el
@@ -1,6 +1,4 @@
-;; Configuration for multi-term mode:
-
-(require 'multi-term)
+;; Utilities for term-mode
 
 (defun open-or-create-term-buffer (buffer-name)
   "Switch to the buffer with BUFFER-NAME or create a
@@ -31,16 +29,4 @@
         (rename-buffer (format "*terminal<%s>*" (read-string "New terminal name: ")))
       (error "This function is only intended to rename terminal buffers."))))
 
-(global-set-key (kbd "C-x t") #'counsel-switch-to-term)
-
-;; term-mode's attempt to use isearch is not my favourite thing in the
-;; world.
-(delete '("C-r" . isearch-backward) term-bind-key-alist)
-(delete '("C-s" . isearch-forward) term-bind-key-alist)
-
-(add-to-list 'term-bind-key-alist '("C-r" . term-send-reverse-search-history))
-(add-to-list 'term-bind-key-alist '("C-c C-l" . term-line-mode))
-(add-to-list 'term-bind-key-alist '("C-s" . swiper))
-(add-to-list 'term-bind-key-alist '("C-c C-r" . term-rename))
-
 (provide 'term-setup)