aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatharina Fey <kookie@spacekookie.de>2020-12-31 14:24:28 +0100
committerKatharina Fey <kookie@spacekookie.de>2020-12-31 14:24:28 +0100
commit0a69904ae08e2e7fd41c03a2eada4b5060097377 (patch)
tree80f103b95b2400718976d61026cd0c59c534c172
parent9705294eecc91638699baa9363b7c3b879903f46 (diff)
libkookie: emacs: finish port of old configuration to new overlay
-rw-r--r--infra/libkookie/overlays/kookie/emacs/base/default.el16
-rw-r--r--infra/libkookie/overlays/kookie/emacs/base/default.nix2
-rw-r--r--infra/libkookie/overlays/kookie/emacs/default.nix70
-rw-r--r--infra/libkookie/overlays/kookie/emacs/init.el253
-rw-r--r--infra/libkookie/overlays/kookie/emacs/multi-cursor/default.el17
-rw-r--r--infra/libkookie/overlays/kookie/emacs/multi-cursor/default.nix4
-rw-r--r--infra/libkookie/overlays/kookie/emacs/notmuch/default.el47
-rw-r--r--infra/libkookie/overlays/kookie/emacs/notmuch/default.nix4
-rw-r--r--infra/libkookie/overlays/kookie/emacs/org/default.el31
-rw-r--r--infra/libkookie/overlays/kookie/emacs/org/default.nix4
-rw-r--r--infra/libkookie/overlays/kookie/emacs/rust/default.el4
-rw-r--r--infra/libkookie/overlays/kookie/emacs/rust/default.nix3
12 files changed, 162 insertions, 293 deletions
diff --git a/infra/libkookie/overlays/kookie/emacs/base/default.el b/infra/libkookie/overlays/kookie/emacs/base/default.el
index 3efaf47088be..906eca673043 100644
--- a/infra/libkookie/overlays/kookie/emacs/base/default.el
+++ b/infra/libkookie/overlays/kookie/emacs/base/default.el
@@ -32,6 +32,12 @@
;;; Delete selections
(delete-selection-mode t)
+;;; Change the swap/ autosave directory
+(let ((backup-dir (concat user-emacs-directory "backups")))
+ (make-directory backup-dir t)
+ (setq backup-directory-alist (list (cons "." backup-dir)))
+ (setq message-auto-save-directory backup-dir))
+
;;; Display and create symbol pairs
(show-paren-mode t)
(electric-pair-mode t)
@@ -59,6 +65,16 @@
(setq emacs-anchor default-directory)
(defun mitosis () (interactive) (make-frame))
+;;; Distraction free mode and minimap
+(require 'sublimity)
+(require 'sublimity-attractive)
+
+;;; OpenSCAD mode
+(add-to-list 'auto-mode-alist '("\\.scad$" . scad-mode))
+
+;;; Capn Proto mode
+(add-to-list 'auto-mode-alist '("\\.capnp$" . protobuf-mode))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Function definitions
diff --git a/infra/libkookie/overlays/kookie/emacs/base/default.nix b/infra/libkookie/overlays/kookie/emacs/base/default.nix
index 570cc2c62a3f..1c80398408d0 100644
--- a/infra/libkookie/overlays/kookie/emacs/base/default.nix
+++ b/infra/libkookie/overlays/kookie/emacs/base/default.nix
@@ -1,3 +1,3 @@
{ buildModule, pkgs, epkgs }:
with epkgs;
-(buildModule "base" ./. [ smex ])
+(buildModule "base" ./. [ smex sublimity scad-mode protobuf-mode ])
diff --git a/infra/libkookie/overlays/kookie/emacs/default.nix b/infra/libkookie/overlays/kookie/emacs/default.nix
index be3a634fe47a..d89863eaa270 100644
--- a/infra/libkookie/overlays/kookie/emacs/default.nix
+++ b/infra/libkookie/overlays/kookie/emacs/default.nix
@@ -4,47 +4,39 @@ with (import ./builder.nix args);
pkgs.emacsWithPackages (epkgs:
let
include = path: (import path { inherit buildModule pkgs epkgs; });
- modules = [ ./base ./move-lines ./theme ./rust ];
+ modules = [
+ ./base
+ ./move-lines
+ ./multi-cursor
+ ./notmuch
+ ./org
+ ./rust
+ ./theme
+ ];
kookie-config = bootstrap (map (p: include p) modules);
- in [
- kookie-config
- ])
+ in
+ with epkgs; [
+ kookie-config
+ ##################################################################
+ # A set of simple module that don't require special configuration
+ #
+ #
+ # Simple language modes
+ fish-mode
+ markdown-mode
+ nim-mode
+ nix-mode
+ python-mode
+ # Utility moduse
+ direnv
+ fzf
+ magit
+ treemacs
+ undo-tree
+ visual-fill-column
+ which-key
+ ])
-
- # Language support
- # fish-mode
- # lsp-mode
- # markdown-mode
- # nim-mode
- # nix-mode
- # protobuf-mode
- # python-mode
- # rust-mode
-
- # color-identifiers-mode
- # color-theme-sanityinc-tomorrow
- # company
- # company-lsp
- # direnv
- # fzf
- # ido-vertical-mode
- # ledger-mode
- # lsp-ui
- # magit
- # monokai-theme
- # multiple-cursors
- # notmuch
- # org
- # protobuf-mode
- # scad-mode
- # smex
- # sublimity
- # treemacs
- # undo-tree
- # visual-fill-column
- # which-key
- # yasnippet
- # ]))
diff --git a/infra/libkookie/overlays/kookie/emacs/init.el b/infra/libkookie/overlays/kookie/emacs/init.el
deleted file mode 100644
index 5db8d806958b..000000000000
--- a/infra/libkookie/overlays/kookie/emacs/init.el
+++ /dev/null
@@ -1,253 +0,0 @@
-;; Kookie's emacs config
-
-;; Enable automatic shell.nix loading
-;; (require 'direnv)
-;; (direnv-mode)
-
-(require 'magit)
-
-(require 'multiple-cursors)
-
-(require 'org)
-(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
-
-(defun org-open-at-point-in-current-window ()
- (interactive)
- (let ((org-link-frame-setup (quote
- ((vm . vm-visit-folder)
- (vm-imap . vm-visit-imap-folder)
- (gnus . gnus)
- (file . find-file)
- (wl . wl)))
- ))
- (org-open-at-point)))
-
-
-(autoload 'notmuch "notmuch" "notmuch mail" t)
-(setq notmuch-search-oldest-first nil)
-(setq mml-secure-openpgp-encrypt-to-self t)
-(setq mml-secure-smime-encrypt-to-self t)
-
-(add-hook 'message-setup-hook 'mml-secure-message-sign-pgpmime)
-(add-hook 'notmuch-hello-refresh-hook
- (lambda ()
- (if (and (eq (point) (point-min))
- (search-forward "Saved searches:" nil t))
- (progn
- (forward-line)
- (widget-forward 1))
- (if (eq (widget-type (widget-at)) 'editable-field)
- (beginning-of-line)))))
-
-(define-transient-command notmuch-apply-email ()
- "Apply patches received by email."
- ["Arguments"
- ("-s" "Sign off on patches" ("-s" "--signoff"))
- ("-r" "Set this reject thingy" ("-r" "--reject"))
- ("-o" "Skip cover letter automatically" ("-o" "--skip-coverletter"))]
- ["Method"
- ("p" "patchset" notmuch--apply-email)])
-
-(defun notmuch--apply-email ()
- "Apply a patch directly from a notmuch frame."
- (interactive)
- (let ((repository (read-directory-name "Select repository")))
- (cd repository)
- (notmuch-show-pipe-message t "git am -3 -")))
-
-;; change the swap/autosave directory
-(let ((backup-dir (concat user-emacs-directory "backups")))
- (make-directory backup-dir t)
- (setq backup-directory-alist (list (cons "." backup-dir)))
- (setq message-auto-save-directory backup-dir))
-
-;; Explicitly enable lsp-mode for certain languages
-
-(add-hook 'c-mode-hook #'lsp)
-(add-hook 'c++-mode-hook #'lsp)
-
-;; OpenSCAD mode
-(add-to-list 'auto-mode-alist '("\\.scad$" . scad-mode))
-
-;; Capn Proto mode
-(add-to-list 'auto-mode-alist '("\\.capnp$" . protobuf-mode))
-
-(require 'color-theme-sanityinc-tomorrow)
-(load-theme 'sanityinc-tomorrow-eighties)
-
-;; Distraction free mode and minimap
-(require 'sublimity)
-(require 'sublimity-attractive)
-
-;; This is require for lsp-mode
-(require 'yasnippet)
-
-(defun lorri (&optional buffer-name)
- (interactive)
- (setq buffer-name (or buffer-name (generate-new-buffer "*lorri*")))
- (start-process "lorri" buffer-name "lorri" "watch")
- (display-buffer buffer-name))
-
-;; Better completion handling with lsp-mode
-(require 'company-lsp)
-(push 'company-lsp company-backends)
-(setq lsp-ui-doc-position 'top)
-(setq lsp-ui-doc-max-width 45)
-(setq lsp-ui-doc-max-height 10)
-
-(add-hook 'after-init-hook 'global-company-mode)
-
-;; Turns out I'm a huge dork
-(setq emacs-anchor default-directory)
-(defun mitosis () (interactive) (make-frame))
-
-;; Setup RSS feeds
-(setq elfeed-feeds
- '(("https://alyssa.is/feed.xml" girlfriend blog)
- ("https://spacekookie.de/rss.xml" self blog)
- ("https://xkcd.com/rss.xml" webcomic)
- ("https://deterministic.space/feed.xml" rust blog)
- ))
-
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;;;;;;; ;;;;;;;;;;;;
-;;;;;;;;; KOOKIE-MODE DEFINITIONS BELOW ;;;;;;;;;;;;
-;;;;;;;;; ;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(defun new-empty-buffer ()
- "Opens a new empty buffer."
- (interactive)
- (let ((buf (generate-new-buffer "untitled")))
- (switch-to-buffer buf)
- (funcall (and initial-major-mode))
- (setq buffer-offer-save t)))
-
-(defun user-buffer-q ()
- "Check if a buffer is a user buffer"
- (interactive)
- (if (string-equal "*" (substring (buffer-name) 0 1))
- nil
- (if (string-equal major-mode "dired-mode")
- nil
- t
- )))
-
-(defun next-user-buffer ()
- "Switch to the next user buffer."
- (interactive)
- (next-buffer)
- (let ((i 0))
- (while (< i 20)
- (if (not (user-buffer-q))
- (progn (next-buffer)
- (setq i (1+ i)))
- (progn (setq i 100))))))
-
-(defun previous-user-buffer ()
- "Switch to the previous user buffer."
- (interactive)
- (previous-buffer)
- (let ((i 0))
- (while (< i 20)
- (if (not (user-buffer-q))
- (progn (previous-buffer)
- (setq i (1+ i)))
- (progn (setq i 100))))))
-
-
-(defun move--section (offset)
- "Move a line or reg up or down by on offset."
-
- ;; We'll have to track 4 text points in this function
- ;; Future me: the * is important....
- (let* (txt-start
- txt-end
- (reg-start (point))
- (reg-end reg-start)
-
- ;; De we delete a trailing \n
- del-nl-trail)
-
- ;; Find the text borders
- (when (region-active-p)
- (if (> (point) (mark))
- (setq reg-start (mark))
- (exchange-point-and-mark)
- (setq reg-end (point))))
- (end-of-line)
-
- ;; If point > point-max there is no trailing \n
- (if (< (point) (point-max))
- (forward-char 1)
- (setq del-nl-trail t)
- (insert-char ?\n))
- (setq txt-end (point)
- reg-end (- reg-end txt-end))
-
- ;; text/region start points
- (goto-char reg-start)
- (beginning-of-line)
- (setq txt-start (point)
- reg-start (- reg-start txt-end))
-
- ;; I'm tired and numbers are hard
- (message "ts: %d, te: %d, rs: %d, re: %d"
- txt-start
- txt-end
- reg-start
- reg-end)
-
- ;; Fake the txt move
- (let ((text (delete-and-extract-region txt-start txt-end)))
- (forward-line offset)
- (when (not (= (current-column) 0))
- (insert-char ?\n)
- (setq del-nl-trail t))
- (insert text))
-
- ;; Restore point position
- (forward-char reg-start)
-
- ;; Clean that annoying \n at the end
- (when del-nl-trail
- (save-excursion
- (goto-char (point-max))
- (delete-char -1)))
-
- ;; If we operated on a region we need to fix the selection
- (when (region-active-p)
- (setq deactivate-mark nil)
- (set-mark (+ (point) (- (- reg-start reg-end)))))))
-
-(defun move-section-up (offset)
- "Move a line or reg upwards"
- (interactive "p")
- (if (eq offset nil)
- setq offset 1)
- (move--section (- offset)))
-
-(defun move-section-down (offset)
- "Move a line or region dawnwards"
- (interactive "p")
- (if (eq offset nil)
- setq offset 1)
- (move--section offset))
-
-(global-set-key (kbd "C-M-<up>") 'move-section-up)
-(global-set-key (kbd "C-M-<down>") 'move-section-down)
-
-;;; Multiple cursors bindings
-(global-set-key (kbd "C-H-c C-H-c") 'mc/edit-lines)
-(global-set-key (kbd "C->") 'mc/mark-next-like-this)
-(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
-(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
-
-
-
-;;; Org mode bindings replicated here to make it easier for me
-(define-key org-mode-map "\C-c\C-o" 'org-open-at-point-in-current-window)
-(define-key org-mode-map "\C-S-<up>" nil)
-(define-key org-mode-map "\C-S-<down>" nil)
diff --git a/infra/libkookie/overlays/kookie/emacs/multi-cursor/default.el b/infra/libkookie/overlays/kookie/emacs/multi-cursor/default.el
new file mode 100644
index 000000000000..15d737d2e8a0
--- /dev/null
+++ b/infra/libkookie/overlays/kookie/emacs/multi-cursor/default.el
@@ -0,0 +1,17 @@
+;; multi-cursor.el
+;; Configure multiple-cursors mode with custom keybings
+;;
+;; This module depends on multiple-cursors mode.
+;;
+;;
+;; This file is part of LIBKOOKIE, a collection of nix expressions.
+;; LIBKOOKIE is licensed under the GPL-3.0 (or later) -- see LICENSE
+
+(provide 'multi-cursor)
+(require 'multiple-cursors)
+
+;;; Multiple cursors bindings
+(global-set-key (kbd "C-H-c C-H-c") 'mc/edit-lines)
+(global-set-key (kbd "C->") 'mc/mark-next-like-this)
+(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
+(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
diff --git a/infra/libkookie/overlays/kookie/emacs/multi-cursor/default.nix b/infra/libkookie/overlays/kookie/emacs/multi-cursor/default.nix
new file mode 100644
index 000000000000..2879b671ff78
--- /dev/null
+++ b/infra/libkookie/overlays/kookie/emacs/multi-cursor/default.nix
@@ -0,0 +1,4 @@
+{ buildModule, epkgs, pkgs }:
+
+with epkgs; with pkgs;
+(buildModule "multi-cursor" ./. [ multiple-cursors ])
diff --git a/infra/libkookie/overlays/kookie/emacs/notmuch/default.el b/infra/libkookie/overlays/kookie/emacs/notmuch/default.el
new file mode 100644
index 000000000000..ba6b8ac12a2d
--- /dev/null
+++ b/infra/libkookie/overlays/kookie/emacs/notmuch/default.el
@@ -0,0 +1,47 @@
+;; magit.el
+;; Configure magit utilities to apply mail patches
+;;
+;; This module depends on notmuch mail handling.
+;;
+;;
+;; This file is part of LIBKOOKIE, a collection of nix expressions.
+;; LIBKOOKIE is licensed under the GPL-3.0 (or later) -- see LICENSE
+
+(provide 'kookie-notmuch)
+
+(require 'magit)
+
+;;; Configure notmuch
+(autoload 'notmuch "notmuch" "notmuch mail" t)
+(setq notmuch-search-oldest-first nil)
+(setq mml-secure-openpgp-encrypt-to-self t)
+(setq mml-secure-smime-encrypt-to-self t)
+
+(add-hook 'message-setup-hook 'mml-secure-message-sign-pgpmime)
+(add-hook 'notmuch-hello-refresh-hook
+ (lambda ()
+ (if (and (eq (point) (point-min))
+ (search-forward "Saved searches:" nil t))
+ (progn
+ (forward-line)
+ (widget-forward 1))
+ (if (eq (widget-type (widget-at)) 'editable-field)
+ (beginning-of-line)))))
+
+(define-transient-command notmuch-apply-email ()
+ "Apply patches received by email."
+ ["Arguments"
+ ("-s" "Sign off on patches" ("-s" "--signoff"))
+ ("-r" "Set this reject thingy" ("-r" "--reject"))
+ ("-o" "Skip cover letter automatically" ("-o" "--skip-coverletter"))]
+ ["Method"
+ ("p" "patchset" notmuch--apply-email)])
+
+(defun notmuch--apply-email ()
+ "Apply a patch directly from a notmuch frame."
+ (interactive)
+ (let ((repository (read-directory-name "Select repository")))
+ (cd repository)
+ (notmuch-show-pipe-message t "git am -3 -")))
+
+
diff --git a/infra/libkookie/overlays/kookie/emacs/notmuch/default.nix b/infra/libkookie/overlays/kookie/emacs/notmuch/default.nix
new file mode 100644
index 000000000000..3ce390ca7a4f
--- /dev/null
+++ b/infra/libkookie/overlays/kookie/emacs/notmuch/default.nix
@@ -0,0 +1,4 @@
+{ buildModule, epkgs, pkgs }:
+
+with epkgs; with pkgs;
+(buildModule "kookie-notmuch" ./. [ magit notmuch ])
diff --git a/infra/libkookie/overlays/kookie/emacs/org/default.el b/infra/libkookie/overlays/kookie/emacs/org/default.el
new file mode 100644
index 000000000000..2dc752379758
--- /dev/null
+++ b/infra/libkookie/overlays/kookie/emacs/org/default.el
@@ -0,0 +1,31 @@
+;; org.el
+;; Configure org-mode key bindings and custom functions
+;;
+;; This module depends on org mode.
+;;
+;;
+;; This file is part of LIBKOOKIE, a collection of nix expressions.
+;; LIBKOOKIE is licensed under the GPL-3.0 (or later) -- see LICENSE
+
+(provide 'kookie-org)
+(require 'org)
+
+;;; Set .org as my file ending of choice
+(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
+
+(defun org-open-at-point-in-current-window ()
+ "A utility function to easily navigate org-mode file trees"
+ (interactive)
+ (let ((org-link-frame-setup (quote
+ ((vm . vm-visit-folder)
+ (vm-imap . vm-visit-imap-folder)
+ (gnus . gnus)
+ (file . find-file)
+ (wl . wl)))
+ ))
+ (org-open-at-point)))
+
+;;; Org mode key bindings replicated here to make it easier for me
+(define-key org-mode-map "\C-c\C-o" 'org-open-at-point-in-current-window)
+(define-key org-mode-map "\C-S-<up>" nil)
+(define-key org-mode-map "\C-S-<down>" nil)
diff --git a/infra/libkookie/overlays/kookie/emacs/org/default.nix b/infra/libkookie/overlays/kookie/emacs/org/default.nix
new file mode 100644
index 000000000000..382f00d07f40
--- /dev/null
+++ b/infra/libkookie/overlays/kookie/emacs/org/default.nix
@@ -0,0 +1,4 @@
+{ buildModule, epkgs, pkgs }:
+
+with epkgs; with pkgs;
+(buildModule "kookie-org" ./. [ org ])
diff --git a/infra/libkookie/overlays/kookie/emacs/rust/default.el b/infra/libkookie/overlays/kookie/emacs/rust/default.el
index 0dc40909d93e..9467b18689bf 100644
--- a/infra/libkookie/overlays/kookie/emacs/rust/default.el
+++ b/infra/libkookie/overlays/kookie/emacs/rust/default.el
@@ -21,3 +21,7 @@
;;; Use projectile to find project roots
(projectile-mode t)
(setq lsp-auto-guess-root t)
+
+(setq lsp-ui-doc-position 'top)
+(setq lsp-ui-doc-max-width 40)
+(setq lsp-ui-doc-max-height 20)
diff --git a/infra/libkookie/overlays/kookie/emacs/rust/default.nix b/infra/libkookie/overlays/kookie/emacs/rust/default.nix
index 2c49caf06cbc..ddc691d049d2 100644
--- a/infra/libkookie/overlays/kookie/emacs/rust/default.nix
+++ b/infra/libkookie/overlays/kookie/emacs/rust/default.nix
@@ -7,6 +7,9 @@ with epkgs; with pkgs;
# lsp integration
lsp-mode lsp-ui company
+ # ??? Not sure why these are required
+ dash-functional spinner
+
# projectile mode
projectile