From 5cd8c090dfa1a4d5947d3555f65a35ec5737ba3c Mon Sep 17 00:00:00 2001 From: Daniel Ziltener Date: Fri, 17 Nov 2023 12:20:24 +0100 Subject: [PATCH] . --- emacs/emacs.nix | 3 ++- emacs/init.el | 38 ++++++++++++++++++++------------------ flake.lock | 18 +++++++++--------- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/emacs/emacs.nix b/emacs/emacs.nix index 63f4acc..137dac9 100644 --- a/emacs/emacs.nix +++ b/emacs/emacs.nix @@ -36,6 +36,7 @@ embark embark-consult evil + evil-cleverparens evil-collection forge geiser @@ -57,12 +58,12 @@ org-rainbow-tags org-roam org-roam-ui - parinfer-rust-mode pass password-store password-store-otp plan9-theme rainbow-delimiters + smartparens tempel tree-sitter tree-sitter-langs diff --git a/emacs/init.el b/emacs/init.el index 6160551..04cdb32 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -53,6 +53,14 @@ ;; See: https://github.com/radian-software/el-patch (use-package el-patch) +;;;; Helper Functions +(defun conditional-keybind (filter-fn target-fn) + (lambda (_prefix) + (interactive "P") + (if (funcall filter-fn) + (call-interactively target-fn) + (call-interactively #'self-insert-command)))) + ;;;; Emacs (use-package emacs :custom @@ -298,26 +306,20 @@ ;;;; Lisp Navigation and Editing ;;;;; Basic -(use-package parinfer-rust-mode - :custom - (parinfer-rust-auto-download t) - (parinfer-rust-troublesome-modes - (delete 'electric-pair-mode parinfer-rust-troublesome-modes)) +(use-package smartparens :hook - emacs-lisp-mode - clojure-ts-mode - scheme-mode - (parinfer-rust-mode . electric-pair-local-mode) + (smartparens-mode . show-smartparens-mode) + (smartparens-mode . smartparens-strict-mode) :config - (setq-local electric-pair-inhibit-predicate - (lambda (c) - (if (or (char-equal c ?\() - (char-equal c ?\[) - (char-equal c ?\{)) - t - (electric-pair-default-inhibit c)))) - (evil-define-key 'normal 'parinfer-rust-mode-map - (kbd "r") #'raise-sexp)) + (evil-define-key 'insert smartparens-mode-map + (kbd "r") (conditional-keybind (lambda () (looking-at "(")) + #'sp-raise-sexp) + (kbd ">") (conditional-keybind (lambda () (thing-at-point-looking-at ")")) + #'sp-forward-slurp-sexp))) + +(use-package evil-cleverparens + :after smartparens + :hook smartparens) ;; (use-package lispy ;; :custom ;; (lispy-close-quotes-at-end-p t) diff --git a/flake.lock b/flake.lock index 7fb2b4b..3b5c5cc 100644 --- a/flake.lock +++ b/flake.lock @@ -27,11 +27,11 @@ ] }, "locked": { - "lastModified": 1700087144, - "narHash": "sha256-LJP1RW0hKNWmv2yRhnjkUptMXInKpn/rV6V6ofuZkHU=", + "lastModified": 1700118404, + "narHash": "sha256-XkqpZpVoy1FV7UbiLkP+fQxxv/6KnwLYkFEHgE8z2IQ=", "owner": "nix-community", "repo": "home-manager", - "rev": "ab1459a1fb646c40419c732d05ec0bf2416d4506", + "rev": "c1a033122df8a3c74fda3780c83a104a7d60873c", "type": "github" }, "original": { @@ -50,11 +50,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1700137447, - "narHash": "sha256-OcE1gFs/Fj2CEhYjx352arsSwZ9Nf63qfuTJ620o0WM=", + "lastModified": 1700168597, + "narHash": "sha256-N+FsHxNTnSnqQW0e1SbMm3Vw59PZ7KTj+vR1hivSWCw=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "859841f4d1ceb4060dcfcd2a94976805eaa39d62", + "rev": "1d9bfa60a19975274afb5fd9a3492f8cb6742c2e", "type": "github" }, "original": { @@ -138,11 +138,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1699781429, - "narHash": "sha256-UYefjidASiLORAjIvVsUHG6WBtRhM67kTjEY4XfZOFs=", + "lastModified": 1699963925, + "narHash": "sha256-LE7OV/SwkIBsCpAlIPiFhch/J+jBDGEZjNfdnzCnCrY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e44462d6021bfe23dfb24b775cc7c390844f773d", + "rev": "bf744fe90419885eefced41b3e5ae442d732712d", "type": "github" }, "original": {