This commit is contained in:
Daniel Ziltener 2023-12-13 16:29:25 +01:00
parent b40402889e
commit afb348f363
Signed by: zilti
GPG key ID: B38976E82C9DAE42

View file

@ -481,6 +481,17 @@ Point must be at the beginning of balanced expression (sexp)."
(transpose-sexps 1)
(forward-sexp -1))
(defvar last-sexp nil)
(defun cc/clone-sexp ()
"Clone the sexp right after the cursor."
(interactive)
(call-interactively #'mark-sexp)
(call-interactively #'kill-ring-save)
(call-interactively #'evil-paste-before)
(call-interactively #'forward-char)
(call-interactively #'paredit-newline))
(defun looking-at-opening-paren ()
(looking-at (rx (or "(" "{" "["))))
@ -488,61 +499,77 @@ Point must be at the beginning of balanced expression (sexp)."
(looking-back (rx (or ")" "}" "]"))))
;;;;; Basic
(use-package smartparens
:delight (smartparens-mode " 󰅲 ")
(use-package paredit
:hook
(smartparens-mode . show-smartparens-mode)
(smartparens-mode . smartparens-strict-mode)
clojure-ts-mode
clojure-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)
(add-to-list 'sp-clojure-modes 'clojurescript-ts-mode)
(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)
;; TODO: Remove the following three lines once merge request got accepted
(load-file (concat init-dir "lib/smartparens-clojure.el"))
(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
(evil-define-key 'insert paredit-mode-map
(kbd "r") (conditional-keybind #'looking-at-opening-paren
#'sp-raise-sexp)
(kbd "w") (conditional-keybind #'looking-at-opening-paren
#'paredit-raise-sexp)
(kbd "w") (conditional-keybind #'looking-at-opening-paren
#'cc/move-sexp-backward)
(kbd "s") (conditional-keybind #'looking-at-opening-paren
#'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)
(kbd ">") (conditional-keybind #'being-past-closing-paren
(lambda (prefix)
(interactive "P")
(call-interactively #'backward-char)
(call-interactively #'sp-forward-slurp-sexp)
(call-interactively #'sp-forward-sexp)
(call-interactively #'forward-char)))
(kbd "<") (conditional-keybind #'being-past-closing-paren
(lambda (prefix)
(interactive "P")
(call-interactively #'backward-char)
(call-interactively #'sp-forward-barf-sexp)
(call-interactively #'forward-char)))))
(kbd "c") (conditional-keybind #'looking-at-opening-paren
#'cc/clone-sexp)))
(use-package evil-cleverparens
:after smartparens
:hook smartparens)
;; (use-package smartparens
;; :delight (smartparens-mode " 󰅲 ")
;; :hook
;; (smartparens-mode . show-smartparens-mode)
;; (smartparens-mode . smartparens-strict-mode)
;; 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)
;; (add-to-list 'sp-clojure-modes 'clojurescript-ts-mode)
;; (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)
;; ;; TODO: Remove the following three lines once merge request got accepted
;; (load-file (concat init-dir "lib/smartparens-clojure.el"))
;; (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)
;; (kbd "w") (conditional-keybind #'looking-at-opening-paren
;; #'cc/move-sexp-backward)
;; (kbd "s") (conditional-keybind #'looking-at-opening-paren
;; #'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)
;; (kbd ">") (conditional-keybind #'being-past-closing-paren
;; (lambda (prefix)
;; (interactive "P")
;; (call-interactively #'backward-char)
;; (call-interactively #'sp-forward-slurp-sexp)
;; (call-interactively #'sp-forward-sexp)
;; (call-interactively #'forward-char)))
;; (kbd "<") (conditional-keybind #'being-past-closing-paren
;; (lambda (prefix)
;; (interactive "P")
;; (call-interactively #'backward-char)
;; (call-interactively #'sp-forward-barf-sexp)
;; (call-interactively #'forward-char)))))
;; (use-package evil-cleverparens
;; :after smartparens
;; :hook smartparens)
;;;;; Visual Aid
;; (use-package rainbow-delimiters
@ -585,7 +612,7 @@ Point must be at the beginning of balanced expression (sexp)."
(setq-default eglot-workspace-configuration
'((clojure-lsp (maxCompletions . 300))))
(add-to-list 'eglot-server-programs
'((clojure-ts-mode clojurec-ts-mode clojurescript-ts-mode)
'((clojure-mode clojurec-mode clojurescript-mode)
"clojure-lsp"
:initializationOptions
(:preferences
@ -621,38 +648,36 @@ Point must be at the beginning of balanced expression (sexp)."
:ensure t)
;;;;; Clojure
(use-package clojure-ts-mode
:delight ""
:after tree-sitter
:config
(require 'sesman)
(sesman-install-menu clojure-mode-map)
:hook
((clojure-ts-mode . eglot-ensure)
(clojure-ts-mode . (lambda ()
(setq-local sesman-system 'CIDER)))
(clojure-ts-mode . (lambda ()
(sesman-install-menu clojure-mode-map)))
(clojurec-ts-mode . (lambda ()
(sesman-install-menu clojurec-mode-map)))
(clojurescript-ts-mode . (lambda ()
(sesman-install-menu clojurescript-mode-map))))
:mode
("\\.clj\\'" . #'clojure-ts-mode)
("\\.cljc\\'" . #'clojurec-ts-mode)
("\\.cljs\\'" . #'clojurescript-ts-mode)
:init
(add-to-list 'tree-sitter-major-mode-language-alist
'(clojure-ts-mode . clojure))
(add-to-list 'tree-sitter-major-mode-language-alist
'(clojurec-ts-mode . clojure))
(add-to-list 'tree-sitter-major-mode-language-alist
'(clojurescript-ts-mode . clojure)))
;; (use-package clojure-ts-mode
;; :delight ""
;; :after tree-sitter
;; :config
;; (require 'sesman)
;; (sesman-install-menu clojure-mode-map)
;; :hook
;; ((clojure-ts-mode . eglot-ensure)
;; (clojure-ts-mode . (lambda ()
;; (setq-local sesman-system 'CIDER)))
;; (clojure-ts-mode . (lambda ()
;; (sesman-install-menu clojure-mode-map)))
;; (clojurec-ts-mode . (lambda ()
;; (sesman-install-menu clojurec-mode-map)))
;; (clojurescript-ts-mode . (lambda ()
;; (sesman-install-menu clojurescript-mode-map))))
;; :mode
;; ("\\.clj\\'" . #'clojure-ts-mode)
;; ("\\.cljc\\'" . #'clojurec-ts-mode)
;; ("\\.cljs\\'" . #'clojurescript-ts-mode)
;; :init
;; (add-to-list 'tree-sitter-major-mode-language-alist
;; '(clojure-ts-mode . clojure))
;; (add-to-list 'tree-sitter-major-mode-language-alist
;; '(clojurec-ts-mode . clojure))
;; (add-to-list 'tree-sitter-major-mode-language-alist
;; '(clojurescript-ts-mode . clojure)))
(use-package cider
:delight (cider-mode '(:eval (concat "  [" (cider--modeline-info) "]")))
:hook
(clojure-ts-mode . cider-mode)
:config
(evil-define-key 'insert 'cider-mode-map
"C-x C-e" #'cider-eval-last-sexp)