This commit is contained in:
Daniel Ziltener 2023-12-13 12:46:11 +01:00
parent 4c22c9c414
commit fdfda0d8aa
Signed by: zilti
GPG key ID: B38976E82C9DAE42
6 changed files with 376 additions and 75 deletions

View file

@ -13,6 +13,14 @@
enable = true;
text = builtins.readFile ./templates;
};
home.file.".emacs.d/lib/smartparens-emacs-lisp.el" = {
enable = true;
text = builtins.readFile ./lib/smartparens-emacs-lisp.el;
};
home.file.".emacs.d/lib/smartparens-scheme.el" = {
enable = true;
text = builtins.readFile ./lib/smartparens-scheme.el;
};
programs.emacs = {
enable = true;
package = pkgs.emacs29-gtk3;

View file

@ -28,10 +28,12 @@
(require 'cl-macs)
;;;; Early Variables
(setq custom-file "~/.emacs.d/custom.el")
(setq custom-file "~/.config/emacs/custom.el")
(when (file-exists-p custom-file)
(load custom-file))
(defvar init-dir (file-name-directory (or load-file-name (buffer-file-name))))
;;;; Personal Information Setup
(setq user-full-name "Daniel Ziltener"
user-mail-address "dziltener@lyrion.ch")
@ -53,12 +55,15 @@
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
;;(setq straight-use-package-by-default t)
(setq straight-use-package-by-default t)
;;;; Package Management Configuration
;; See: https://github.com/radian-software/el-patch
(use-package el-patch)
;;;;; Guix Management
(use-package guix)
;;;; Helper Functions
(cl-defun conditional-keybind
(filter-fn target-fn
@ -92,25 +97,27 @@
(tab-always-indent 'complete)
(tool-bar-mode nil)
:custom-face
(default ((t (:weight bold :height 113 :width normal :family "VictorMono Nerd Font"))))
;;(default ((t (:weight bold :height 113 :width normal :family "VictorMono Nerd Font"))))
(default ((t (:weight regular :height 105 :width normal :family "MonaspiceXe Nerd Font Mono"))))
:hook
(minibuffer-setup . cursor-intangible-mode)
:config
(advice-add 'risky-local-variable-p :override #'ignore)
(global-display-fill-column-indicator-mode t))
(global-display-fill-column-indicator-mode t)
(pixel-scroll-precision-mode 1))
;;;; Org Mode
(use-package org
:ensure t
:custom
(org-babel-load-languages '((emacs-lisp . t)
(scheme . t)))
:hook
(org-mode . org-indent-mode)
(org-src-mode . hack-local-variables)
(org-mode . auto-fill-mode)
(org-mode . visual-line-mode)
:config
(setq org-directory "~/org")
(org-babel-do-load-languages
'org-babel-load-languages
'((scheme . t)))
(add-to-list 'org-modules 'collector))
(use-package org-roam
@ -118,7 +125,7 @@
:custom
(org-roam-directory "~/org/roam")
:config
(progn (org-roam-db-autosync-mode)))
(org-roam-db-autosync-mode))
(use-package consult-notes
:config
@ -162,21 +169,40 @@
;;(load-theme 'catppuccin)
)
(use-package unicode-fonts
:ensure t
:config
(unicode-fonts-setup))
(use-package ligature
:config
(ligature-set-ligatures
't
'( ;; SS01
"==" "===" "=/=" "!=" "!==" "/=" "/==" "~~" "=~" "!~"
;; SS02
">=" "<="
;; SS03
"->" "<-" "=>" "<!--" "-->" "<~" "<~~" "~>" "~~>" "<~>"
;; SS04
"</" "/>" "</>" "/\\" "\\/"
;; SS05
"|>" "<|"
;; SS06
"##" "###"
;; SS07
"***" "/*" "*/" "/*/" "(*" "*)" "(*)"
;; SS08
".=" ".-" "..<"
;; CALT
"//" "///" "&&" "!!" "??" "?." "?:" "||" "::" ":::" ";;" ".." "..." "=!=" "#=" ":=" "=:" "=:="
":>" ">:" "<:" ":<" "..=" "..-"
))
(global-ligature-mode t))
(set-frame-parameter nil 'alpha-background 80)
(add-to-list 'default-frame-alist '(alpha-background . 80))
;; (use-package powerline
;; :init
;; (require 'powerline)
;; :config
;; (powerline-default-theme))
;; (use-package airline-themes
;; :after powerline
;; :init (require 'airline-themes)
;; :config
;; (load-theme 'airline-badwolf t))
(use-package lambda-line
:straight (:type git :host github :repo "lambda-emacs/lambda-line")
:custom
@ -223,6 +249,15 @@
;; load preferred theme
(load-theme 'lambda-dark))
(use-package visual-fill-column
:custom
(visual-fill-column-center-text t)
(visual-fill-column-enable-sensible-window-split t)
:hook visual-line-mode)
(use-package adaptive-wrap
:hook visual-fill-column)
;;;; Security
(use-package keychain-environment
:init
@ -278,7 +313,15 @@
completion-category-defaults nil
completion-category-overrides '((file (styles basic partial-completion)))))
(use-package embark-consult
:after (embark consult)
:hook
(embark-collect-mode . consult-preview-at-point-mode))
(use-package consult
:config
(require 'consult-flymake)
(require 'consult-xref)
:bind
(:map evil-normal-state-map
("<leader><SPC>" . 'consult-find)
@ -294,11 +337,6 @@
("C-<SPC>" . 'embark-act)
("C-M-<return>" . 'embark-bindings))
(use-package embark-consult
:after (embark consult)
:hook
(embark-collect-mode . consult-preview-at-point-mode))
(use-package wgrep
:config
(setq wgrep-auto-save-buffer t))
@ -332,8 +370,22 @@
;;;;; Code Completion
(use-package cape
:preface
(defun my/capf ()
(setq completion-at-point-functions
(list (cape-capf-super
#'tempel-complete
#'cape-dabbrev
#'cape-file
#'cape-dict
#'cape-line
#'cape-emoji
#'cape-keyword))))
:config
(advice-add 'eglot-completion-at-point :around #'cape-wrap-buster))
(advice-add 'eglot-completion-at-point :around #'cape-wrap-buster)
:hook
(org-mode . my/capf)
(prog-mode . my/capf))
(defun my/corfu-combined-sort (candidates)
"Sort CANDIDATES using both display-sort-function and corfu-sort-function."
@ -354,25 +406,16 @@
(corfu-scroll-margin 5)
(corfu-quit-no-match 'separator)
(evil-collection-corfu-key-themes '(tab-n-go))
(corfu-popupinfo-delay '(0.1 . 0.5))
:config
(setq corfu-sort-override-function #'my/corfu-combined-sort)
(add-to-list 'savehist-additional-variables 'corfu-history)
:commands
global-corfu-mode
:init
(global-corfu-mode))
(use-package corfu-history
:config
(add-to-list 'savehist-additional-variables 'corfu-history)
:hook
global-corfu-mode)
(use-package corfu-popupinfo
:after corfu
:custom
(corfu-popupinfo-delay '(0.1 . 0.5))
:hook
global-corfu-mode)
(global-corfu-mode)
(corfu-popupinfo-mode 1)
(corfu-history-mode 1))
(use-package nerd-icons-corfu
:after corfu
@ -453,6 +496,8 @@ Point must be at the beginning of balanced expression (sexp)."
clojure-ts-mode
emacs-lisp-mode
scheme-mode
:custom
(sp-undo-pairs-separately t)
:config
(add-to-list 'sp-clojure-modes 'clojure-ts-mode)
(add-to-list 'sp-clojure-modes 'clojurec-ts-mode)
@ -460,6 +505,11 @@ Point must be at the beginning of balanced expression (sexp)."
(add-to-list 'sp-lisp-modes 'clojure-ts-mode)
(add-to-list 'sp-lisp-modes 'clojurec-ts-mode)
(add-to-list 'sp-lisp-modes 'clojurescript-ts-mode)
(load-file (concat init-dir "lib/smartparens-emacs-lisp.el"))
(load-file (concat init-dir "lib/smartparens-scheme.el"))
(require 'smartparens-clojure)
(require 'smartparens-emacs-lisp)
(require 'smartparens-scheme)
(evil-define-key 'insert smartparens-mode-map
(kbd "r") (conditional-keybind #'looking-at-opening-paren
#'sp-raise-sexp)
@ -469,6 +519,8 @@ Point must be at the beginning of balanced expression (sexp)."
#'cc/move-sexp-forward)
(kbd "c") (conditional-keybind #'looking-at-opening-paren
#'sp-clone-sexp)
(kbd "m") (conditional-keybind #'looking-at-opening-paren
#'sp-mark-sexp)
(kbd "DEL") (conditional-keybind #'being-past-closing-paren
#'sp-backward-delete-sexp
#'evil-delete-backward-char-and-join)
@ -507,19 +559,19 @@ Point must be at the beginning of balanced expression (sexp)."
(use-package flymake
:delight '(:eval (cons "" (flymake--mode-line-counters))))
(use-package consult-flymake
:after (consult flymake))
(defun my/eglot-capf ()
(setq-local completion-at-point-functions
(list (cape-super-capf
(use-package eglot
:preface
(defun my/eglot-capf ()
(setq completion-at-point-functions
(list (cape-capf-super
#'eglot-completion-at-point
#'tempel-complete
#'cape-dabbrev
#'cape-file
#'cape-dict))))
(use-package eglot
#'cape-dict
#'cape-line
#'cape-emoji
#'cape-keyword))))
:custom
(eglot-connect-timeout 90)
(eglot-autoshutdown t)
@ -558,7 +610,7 @@ Point must be at the beginning of balanced expression (sexp)."
(call-interactively #'eglot-format-buffer))
nil 'local)))
(eglot-managed-mode . eglot-inlay-hints-mode)
(eglot-managed-mode . #'my/eglot-capf))
(eglot-managed-mode . my/eglot-capf))
(use-package consult-eglot
:after (consult eglot))
@ -605,13 +657,41 @@ Point must be at the beginning of balanced expression (sexp)."
(evil-define-key 'normal 'cider-mode-map
(kbd "<localleader>ce") #'cider-eval-sexp-at-point))
;;;;; Chicken Scheme
;;;;; Scheme
(use-package geiser
:preface
(defun my/geiser-capf ()
(setq completion-at-point-functions
(append geiser-capf--capfs
(list (cape-capf-super
#'tempel-complete
#'cape-dabbrev
#'cape-file
#'cape-dict
#'cape-line
#'cape-emoji
#'cape-keyword)))))
:custom
(geiser-chicken-match-limit 200)
:config
(defalias 'run-geiser 'geiser)
:hook
(geiser-mode . my/geiser-capf))
(use-package paren-face
:hook
scheme-mode
emacs-lisp-mode)
(use-package highlight-parentheses
:hook prog-mode)
;;;;;; Chicken Scheme
(use-package scheme
:config
(eval-after-load 'eglot
'(add-to-list 'eglot-server-programs
'(scheme-mode
. ("env" "CHICKEN_DOC_REPOSITORY=/home/zilti/.local/share/chicken-doc" "chicken-lsp-server"))))
(setq prettify-symbols-alist
'(("lambda" . "λ")))
:hook
(scheme-mode . eglot-ensure))
@ -620,11 +700,9 @@ Point must be at the beginning of balanced expression (sexp)."
#'flymake-chicken-backend nil t)
(flymake-mode))
(use-package geiser
:custom
(geiser-chicken-match-limit 200)
:config
(defalias 'run-geiser 'geiser))
(use-package geiser-chicken)
;;;;;; Guile
(use-package geiser-guile
:config
@ -648,11 +726,6 @@ Point must be at the beginning of balanced expression (sexp)."
(zig-mode . eglot-ensure)
:mode ("\\.zig\\'" . zig-mode))
(use-package nix-mode
:hook
(nix-mode . eglot-ensure)
:mode ("\\.nix\\'" . nix-mode))
;; (use-package lsp-tailwindcss
;; :init
;; (setq lsp-tailwindcss-add-on-mode t
@ -723,5 +796,10 @@ Point must be at the beginning of balanced expression (sexp)."
:encryption tls
:channels ()))))
;;;; Wrapping Up
(use-package envrc
:config
(envrc-global-mode))
(provide 'init)
;;; init.el ends here

View file

@ -0,0 +1,60 @@
;;; smartparens-clojure.el --- Additional configuration for Emacs Lisp mode. -*- lexical-binding: t; -*-
;; Copyright (C) 2023 Daniel Ziltener
;; Author: Daniel Ziltener <dziltener@lyrion.ch>
;; Created: 13 December 2023
;; Keywords: abbrev convenience editing
;; URL: https://github.com/Fuco1/smartparens
;;
;; This file is not part of GNU Emacs.
;;
;;; License:
;;
;; This file is part of Smartparens.
;;
;; Smartparens is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; Smartparens is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with Smartparens. If not, see <http://www.gnu.org/licenses/>.
;;
;;; Commentary:
;;
;; This file provides some additional configuration for Emacs Lisp mode. To use
;; it, simply add:
;;
;; (require 'smartparens-emacs-lisp)
;;
;; into your configuration. You can use this in conjunction with the
;; default config or your own configuration.
;;
;;; Code:
(require 'smartparens)
(defvar sp-emacs-lisp-prefix "\\(?:[@`'#,_]+\\)"
"Prefix used in `sp-sexp-prefix' for emacs lisp mode.")
(defvar sp-emacs-lisp-modes '(emacs-lisp-mode lisp-data-mode)
"List of Emacs Lisp-related modes.")
(dolist (mode sp-emacs-lisp-modes)
(add-to-list 'sp-sexp-prefix `(,mode regexp ,sp-emacs-lisp-prefix)))
;; Match "`" with "`" in strings and comments
(sp-with-modes sp-emacs-lisp-modes
(sp-local-pair "`" "`"
:when '(sp-in-string-p
sp-in-comment-p)
:unless '(sp-lisp-invalid-hyperlink-p)))
(provide 'smartparens-emacs-lisp)
;;; smartparens-emacs-lisp.el ends here

View file

@ -0,0 +1,60 @@
;;; smartparens-clojure.el --- Additional configuration for Emacs Lisp mode. -*- lexical-binding: t; -*-
;; Copyright (C) 2023 Daniel Ziltener
;; Author: Daniel Ziltener <dziltener@lyrion.ch>
;; Created: 13 December 2023
;; Keywords: abbrev convenience editing
;; URL: https://github.com/Fuco1/smartparens
;;
;; This file is not part of GNU Emacs.
;;
;;; License:
;;
;; This file is part of Smartparens.
;;
;; Smartparens is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; Smartparens is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with Smartparens. If not, see <http://www.gnu.org/licenses/>.
;;
;;; Commentary:
;;
;; This file provides some additional configuration for Emacs Lisp mode. To use
;; it, simply add:
;;
;; (require 'smartparens-scheme)
;;
;; into your configuration. You can use this in conjunction with the
;; default config or your own configuration.
;;
;;; Code:
(require 'smartparens)
(defvar sp-scheme-prefix "\\(?:[@`'#,_]+\\)"
"Prefix used in `sp-sexp-prefix' for emacs lisp mode.")
(defvar sp-scheme-modes '(scheme-mode geiser-mode)
"List of Scheme-related modes.")
(dolist (mode sp-scheme-modes)
(add-to-list 'sp-sexp-prefix `(,mode regexp ,sp-scheme-prefix)))
;; Match "`" with "`" in strings and comments
(sp-with-modes sp-scheme-modes
(sp-local-pair "`" "`"
:when '(sp-in-string-p
sp-in-comment-p)
:unless '(sp-lisp-invalid-hyperlink-p)))
(provide 'smartparens-scheme)
;;; smartparens-scheme.el ends here

View file

@ -13,6 +13,101 @@ prog-mode
(bug (if (derived-mode-p 'emacs-lisp-mode) ";; " comment-start) "BUG ")
(hack (if (derived-mode-p 'emacs-lisp-mode) ";; " comment-start) "HACK ")
scheme-mode
(crate-dependency
"(\"rust-" crate-name "\" ,rust-" (s crate-name) "-" p ")")
(define-guix-crate
"(define-public rust-" (s egg-name) "-" (s maj-version)
n> "(package"
n> "(name \"rust-" egg-name "\")"
n> "(version \"" maj-version "." (s egg-version) "\")"
n> "(source"
n> "(origin"
n> "(method url-fetch)"
n> "(uri (crate-uri \"" egg-name "\" version))"
n> "(sha256"
n> "(base32"
n> "\"0z05x7f154n9bgmainrsmncf5i6dil43r9ymr3rdgwbg4wnxmz4s\"))))"
n> "(build-system cargo-build-system)"
n> "(arguments"
n> "`(#:cargo-inputs"
n> "(" p ")"
n> "#:cargo-development-inputs"
n> "(" p ")"
n> "#:cargo-build-inputs"
n> "(" p ")))"
n> "(synopsis \"" (s synopsis) "\")"
n> "(home-page \"https://crates.io/crates/" egg-name "\")"
n> "(description \"" synopsis ".\")"
n> "(license license:" (s license) ")))")
(define-guix-egg
"(define-public chicken-" (s egg-name)
n> "(package"
n> "(name \"chicken-" egg-name "\")"
n> "(version \"" (s egg-version) "\")"
n> "(source"
n> "(origin"
n> "(method url-fetch)"
n> "(uri (egg-uri \"" egg-name "\" version))"
n> "(sha256"
n> "(base32"
n> "\"0z05x7f154n9bgmainrsmncf5i6dil43r9ymr3rdgwbg4wnxmz4s\"))))"
n> "(propagated-inputs"
n> "(list " (s inputs) "))"
n> "(native-inputs"
n> "(list " (s native-inputs) "))"
n> "(build-system chicken-build-system)"
n> "(arguments '(#:egg-name \"" egg-name "\"))"
n> "(synopsis \"" (s synopsis) "\")"
n> "(home-page \"https://wiki.call-cc.org/eggref/5/" egg-name "\")"
n> "(description \"" synopsis "\")"
n> "(license license:" (s license) ")))")
org-mode
(src
"#+begin_src " p
n p n
"#+end_src")
(advent-of-code-day
"* Day " (s day) ": " p
n> n> "Get the puzzle solution as [[./day" day ".scm][tangled .scm file]]."
n> n> "** Part One"
n> n> "#+NAME: day" day "-imports"
n> "#+begin_src scheme :exports none :noweb yes :tangle day" day ".scm"
n>
n> "#+end_src"
n> n> "#+NAME: day" day "-input-scm"
n> "#+begin_src scheme :exports none :noweb yes :tangle day" day ".scm"
n> "(define input \""
n> "<<day" day "-input>>\")"
n> "#+end_src"
n> n> "*** Quest"
n> n> "*** Puzzle Solution"
n> n> "**** Calculation"
n> n> "#+NAME: day" day "-part1-calc-fn"
n> "#+begin_src scheme :tangle day" day ".scm :noweb strip-tangle"
n> ""
n> "#+end_src"
n> n> "#+CALL: day" day "-part1-calc-fn[:var input=day" day "-input[] :epilogue \"(calc-part-1)\"]()"
n> n> "** Part Two"
n> n> "*** Quest"
n> n> "*** Puzzle Solution"
n> n> "**** Calculation"
n> n> "#+NAME: day" day "-part2-calc-fn"
n> "#+begin_src scheme :tangle day" day ".scm :noweb strip-tangle"
n> ""
n> "#+end_src"
n>n> "#+CALL: day" day "-part2-calc-fn[:var input=day" day "-input[] :epilogue \"(calc-part-2)\"]()"
n> n> "** Puzzle Input"
n> n> "#+NAME: day" day "-input"
n> "#+begin_src fundamental"
n> "#+end_src")
;; Local Variables:
;; mode: lisp-data
;; outline-regexp: "[a-z]"

View file

@ -27,11 +27,11 @@
]
},
"locked": {
"lastModified": 1700814205,
"narHash": "sha256-lWqDPKHRbQfi+zNIivf031BUeyciVOtwCwTjyrhDB5g=",
"lastModified": 1702195709,
"narHash": "sha256-+zRjWkm5rKqQ57PuLZ3JF3xi3vPMiOJzItb1m/43Cq4=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "aeb2232d7a32530d3448318790534d196bf9427a",
"rev": "6761b8188b860f374b457eddfdb05c82eef9752f",
"type": "github"
},
"original": {
@ -138,11 +138,11 @@
},
"nixpkgs_3": {
"locked": {
"lastModified": 1701539137,
"narHash": "sha256-nVO/5QYpf1GwjvtpXhyxx5M3U/WN0MwBro4Lsk+9mL0=",
"lastModified": 1702233072,
"narHash": "sha256-H5G2wgbim2Ku6G6w+NSaQaauv6B6DlPhY9fMvArKqRo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "933d7dc155096e7575d207be6fb7792bc9f34f6d",
"rev": "781e2a9797ecf0f146e81425c822dca69fe4a348",
"type": "github"
},
"original": {