Add some elisp editing stuff
This commit is contained in:
parent
35797a591d
commit
a3791c4048
153
init.el
153
init.el
@ -46,8 +46,8 @@
|
|||||||
|
|
||||||
;; basic stuff
|
;; basic stuff
|
||||||
(use-package emacs
|
(use-package emacs
|
||||||
:hook (;(emacs-lisp-mode . my/-emacs-lisp-mode-setup-evil-lookup)
|
:hook (;;(emacs-lisp-mode . my/-emacs-lisp-mode-setup-evil-lookup)
|
||||||
(prog-mode . electric-pair-local-mode)
|
;;(prog-mode . electric-pair-local-mode)
|
||||||
((text-mode message-mode tex-mode) . flyspell-mode)
|
((text-mode message-mode tex-mode) . flyspell-mode)
|
||||||
((text-mode message-mode tex-mode prog-mode) . auto-fill-mode)
|
((text-mode message-mode tex-mode prog-mode) . auto-fill-mode)
|
||||||
(prog-mode . flyspell-prog-mode))
|
(prog-mode . flyspell-prog-mode))
|
||||||
@ -137,7 +137,8 @@
|
|||||||
(setq-default indent-tabs-mode nil
|
(setq-default indent-tabs-mode nil
|
||||||
tab-width 4
|
tab-width 4
|
||||||
fill-column 80
|
fill-column 80
|
||||||
comment-multi-line t)
|
comment-multi-line t
|
||||||
|
comment-empty-lines 'eol)
|
||||||
|
|
||||||
;; Tree sitter download locations
|
;; Tree sitter download locations
|
||||||
(setq treesit-language-source-alist
|
(setq treesit-language-source-alist
|
||||||
@ -209,8 +210,8 @@ Interactively, force the recompile if called with a prefix."
|
|||||||
(use-package flyspell
|
(use-package flyspell
|
||||||
:config
|
:config
|
||||||
(setq ispell-program-name "hunspell"
|
(setq ispell-program-name "hunspell"
|
||||||
flyspell-issue-message-flag nil
|
flyspell-issue-message-flag nil
|
||||||
flyspell-issue-welcome-flag nil)
|
flyspell-issue-welcome-flag nil)
|
||||||
(define-key flyspell-mode-map (kbd "C-;") nil t)
|
(define-key flyspell-mode-map (kbd "C-;") nil t)
|
||||||
(define-key flyspell-mode-map (kbd "C-,") nil t))
|
(define-key flyspell-mode-map (kbd "C-,") nil t))
|
||||||
|
|
||||||
@ -300,8 +301,13 @@ Interactively, force the recompile if called with a prefix."
|
|||||||
("C-c C-+" . evil-numbers/inc-at-pt-incremental)
|
("C-c C-+" . evil-numbers/inc-at-pt-incremental)
|
||||||
("C-c C--" . evil-numbers/dec-at-pt-incremental)))
|
("C-c C--" . evil-numbers/dec-at-pt-incremental)))
|
||||||
(use-package evil-cleverparens
|
(use-package evil-cleverparens
|
||||||
:hook ((lisp-mode emacs-lisp-mode) . evil-cleverparens-mode)
|
:hook (((lisp-mode emacs-lisp-mode) . evil-cleverparens-mode)
|
||||||
|
(evil-cleverparens-mode . paredit-mode))
|
||||||
|
:bind (:map paredit-mode-map
|
||||||
|
("C-<return>" . paredit-RET)
|
||||||
|
("C-RET" . paredit-RET))
|
||||||
:custom
|
:custom
|
||||||
|
(eldoc-add-command 'paredit-RET)
|
||||||
(evil-cleverparens-use-s-and-S nil))
|
(evil-cleverparens-use-s-and-S nil))
|
||||||
|
|
||||||
;; make lisp editing nicer
|
;; make lisp editing nicer
|
||||||
@ -372,12 +378,12 @@ visual states."
|
|||||||
;; vertico
|
;; vertico
|
||||||
(use-package vertico
|
(use-package vertico
|
||||||
:bind (:map vertico-map
|
:bind (:map vertico-map
|
||||||
("C-S-k" . kill-line)
|
("C-S-k" . kill-line)
|
||||||
("C-k" . vertico-previous)
|
("C-k" . vertico-previous)
|
||||||
("C-j" . vertico-next)
|
("C-j" . vertico-next)
|
||||||
("RET" . vertico-directory-enter)
|
("RET" . vertico-directory-enter)
|
||||||
("DEL" . vertico-directory-delete-char)
|
("DEL" . vertico-directory-delete-char)
|
||||||
("M-DEL" . vertico-directory-delete-word))
|
("M-DEL" . vertico-directory-delete-word))
|
||||||
:hook (minibuffer-setup . cursor-intangible-mode)
|
:hook (minibuffer-setup . cursor-intangible-mode)
|
||||||
:init
|
:init
|
||||||
(defun my/crm-indicator (args)
|
(defun my/crm-indicator (args)
|
||||||
@ -392,8 +398,8 @@ visual states."
|
|||||||
enable-recursive-minibuffers t
|
enable-recursive-minibuffers t
|
||||||
read-extended-command-predicate #'command-completion-default-include-p
|
read-extended-command-predicate #'command-completion-default-include-p
|
||||||
minibuffer-prompt-properties '(read-only t
|
minibuffer-prompt-properties '(read-only t
|
||||||
cursor-intangible t
|
cursor-intangible t
|
||||||
face minibuffer-prompt))
|
face minibuffer-prompt))
|
||||||
(vertico-mode 1))
|
(vertico-mode 1))
|
||||||
|
|
||||||
;; orderless
|
;; orderless
|
||||||
@ -414,10 +420,10 @@ visual states."
|
|||||||
(command
|
(command
|
||||||
(styles my/orderless-with-initialism basic)))))
|
(styles my/orderless-with-initialism basic)))))
|
||||||
|
|
||||||
; marginalia
|
;; marginalia
|
||||||
(use-package marginalia
|
(use-package marginalia
|
||||||
:bind (:map minibuffer-local-map
|
:bind (:map minibuffer-local-map
|
||||||
("M-a" . marginalia-cycle))
|
("M-a" . marginalia-cycle))
|
||||||
:init
|
:init
|
||||||
(marginalia-mode 1))
|
(marginalia-mode 1))
|
||||||
|
|
||||||
@ -455,6 +461,9 @@ visual states."
|
|||||||
("M-g i" . consult-imenu)
|
("M-g i" . consult-imenu)
|
||||||
("M-g I" . consult-imenu-multi)
|
("M-g I" . consult-imenu-multi)
|
||||||
("M-g r" . consult-imenu-multi)
|
("M-g r" . consult-imenu-multi)
|
||||||
|
;; these are so that you can still newline even if a completion popup is open
|
||||||
|
("C-RET" . newline)
|
||||||
|
("C-<return>" . newline)
|
||||||
:map help-map
|
:map help-map
|
||||||
("TAB". consult-info)
|
("TAB". consult-info)
|
||||||
("C-m" . consult-man))
|
("C-m" . consult-man))
|
||||||
@ -484,7 +493,7 @@ visual states."
|
|||||||
:config
|
:config
|
||||||
(defun my/-company-setup-shell-mode ()
|
(defun my/-company-setup-shell-mode ()
|
||||||
(setq-local company-backends '(company-files company-keywords
|
(setq-local company-backends '(company-files company-keywords
|
||||||
company-dabbrev-code)))
|
company-dabbrev-code)))
|
||||||
(defun my/-company-search-mode-add-lighter ()
|
(defun my/-company-search-mode-add-lighter ()
|
||||||
(if company-search-mode
|
(if company-search-mode
|
||||||
(cl-pushnew company-search-lighter global-mode-string :test 'equal)
|
(cl-pushnew company-search-lighter global-mode-string :test 'equal)
|
||||||
@ -637,7 +646,6 @@ to `posframe-show' if the display is graphical."
|
|||||||
"--clang-tidy" "--completion-style=detailed"
|
"--clang-tidy" "--completion-style=detailed"
|
||||||
"--header-insertion=never" "--pch-storage=memory"
|
"--header-insertion=never" "--pch-storage=memory"
|
||||||
"--function-arg-placeholders"))))
|
"--function-arg-placeholders"))))
|
||||||
;"--malloc-trim" "--function-arg-placeholders"))))
|
|
||||||
|
|
||||||
;; gud
|
;; gud
|
||||||
(use-package gud
|
(use-package gud
|
||||||
@ -645,7 +653,7 @@ to `posframe-show' if the display is graphical."
|
|||||||
:ensure nil
|
:ensure nil
|
||||||
:after (project evil)
|
:after (project evil)
|
||||||
:bind (:map project-prefix-map
|
:bind (:map project-prefix-map
|
||||||
("U" . my/project-gdb))
|
("U" . my/project-gdb))
|
||||||
:init
|
:init
|
||||||
(setq gdb-debuginfod-enable-setting t)
|
(setq gdb-debuginfod-enable-setting t)
|
||||||
(defvar my/project-gdb-command nil
|
(defvar my/project-gdb-command nil
|
||||||
@ -973,11 +981,80 @@ COMMAND and COMINT are like `compile'."
|
|||||||
;; yuck (config language for eww)
|
;; yuck (config language for eww)
|
||||||
(use-package yuck-mode)
|
(use-package yuck-mode)
|
||||||
|
|
||||||
|
;; Some Elisp indentation stuff
|
||||||
|
;; Source: https://github.com/magit/emacsql
|
||||||
|
;; emacsql.el line 394
|
||||||
|
(defun my/lisp-inside-plist-p ()
|
||||||
|
"Return t if point is inside a plist."
|
||||||
|
(save-excursion
|
||||||
|
(let ((start (point)))
|
||||||
|
(beginning-of-defun)
|
||||||
|
(when-let ((sexp (nth 1 (parse-partial-sexp (point) start))))
|
||||||
|
(goto-char sexp)
|
||||||
|
(looking-at (rx "(" (* (syntax whitespace)) ":"))))))
|
||||||
|
|
||||||
|
(defun my/-calculate-indent-fix-plists (oldfun &rest args)
|
||||||
|
"This function is meant to advise `calculate-lisp-indent'.
|
||||||
|
It calls OLDFUN with ARGS in such an environment as to prevent the default
|
||||||
|
indentation of plists."
|
||||||
|
(if (save-excursion
|
||||||
|
(beginning-of-line)
|
||||||
|
(my/lisp-inside-plist-p))
|
||||||
|
(let ((lisp-indent-offset 1))
|
||||||
|
(apply oldfun args))
|
||||||
|
(apply oldfun args)))
|
||||||
|
|
||||||
|
(advice-add 'calculate-lisp-indent :around
|
||||||
|
'my/-calculate-indent-fix-plists)
|
||||||
|
|
||||||
|
(defvar my/max-lisp-noindent-comment-search-lines 10
|
||||||
|
"Max lines to search for the noindent comment.")
|
||||||
|
|
||||||
|
(defun my/-calculate-lisp-indent-noindent-comment (oldfun &rest args)
|
||||||
|
"This function is meant to advise `calculate-lisp-indent'.
|
||||||
|
It calls OLDFUN with ARGS, unless the line ends with the comment
|
||||||
|
; noindent [LINES]
|
||||||
|
In this case, it just returns the current amount of indentation. LINES is the
|
||||||
|
number of lines that this comment affects. This is limited by
|
||||||
|
`my/max-lisp-noindent-comment-search-lines'.
|
||||||
|
|
||||||
|
This only works if its on the first or second form in a block. I think this is
|
||||||
|
because the indentation code only checks those and then assumes the same
|
||||||
|
indentation for every following line in the same block. This is probably OK as
|
||||||
|
I can't imagine too many instances where you need to randomly change the indent
|
||||||
|
midway through a block, and in those cases you can just stick this on the first
|
||||||
|
line in the block and manually deal with indentation."
|
||||||
|
(if (and (save-excursion
|
||||||
|
(end-of-line)
|
||||||
|
(re-search-backward
|
||||||
|
(rx (+ ";") (syntax whitespace) "noindent"
|
||||||
|
(? (syntax whitespace) (group (+ num)))
|
||||||
|
line-end)
|
||||||
|
(pos-bol (- my/max-lisp-noindent-comment-search-lines))
|
||||||
|
t))
|
||||||
|
(save-excursion
|
||||||
|
;; if we are on a blank line, move forward a line
|
||||||
|
(when (zerop (length (buffer-substring-no-properties
|
||||||
|
(pos-bol) (pos-eol))))
|
||||||
|
(beginning-of-line 2))
|
||||||
|
(<= (count-lines (match-beginning 0) (pos-eol))
|
||||||
|
(if-let ((match (match-string 1)))
|
||||||
|
(string-to-number match)
|
||||||
|
1))))
|
||||||
|
(save-excursion
|
||||||
|
(beginning-of-line)
|
||||||
|
(looking-at (rx (* blank)))
|
||||||
|
(length (match-string 0)))
|
||||||
|
(apply oldfun args)))
|
||||||
|
|
||||||
|
(advice-add 'calculate-lisp-indent :around
|
||||||
|
'my/-calculate-lisp-indent-noindent-comment)
|
||||||
|
|
||||||
;; sly
|
;; sly
|
||||||
(use-package sly
|
(use-package sly
|
||||||
:hook (lisp-mode . my/-lisp-mode-autoconnect-sly)
|
:hook (lisp-mode . my/-lisp-mode-autoconnect-sly)
|
||||||
:bind (:map sly-mode-map
|
:bind (:map sly-mode-map
|
||||||
("C-c e" . my/sly-show-notes-at-point))
|
("C-c e" . my/sly-show-notes-at-point)) ; noindent
|
||||||
:autoload sly-connected-p
|
:autoload sly-connected-p
|
||||||
:init
|
:init
|
||||||
(defun my/-lisp-mode-autoconnect-sly ()
|
(defun my/-lisp-mode-autoconnect-sly ()
|
||||||
@ -1343,7 +1420,7 @@ If no name is given, list all bookmarks instead."
|
|||||||
(trashed)."
|
(trashed)."
|
||||||
(interactive)
|
(interactive)
|
||||||
(when (mu4e-thread-message-folded-p)
|
(when (mu4e-thread-message-folded-p)
|
||||||
(mu4e-warn "Cannot mark folded messages"))
|
(mu4e-warn "Cannot mark folded messages"))
|
||||||
(mu4e-mark-at-point 'move mu4e-trash-folder)
|
(mu4e-mark-at-point 'move mu4e-trash-folder)
|
||||||
(when mu4e-headers-advance-after-mark
|
(when mu4e-headers-advance-after-mark
|
||||||
(mu4e-headers-next)))
|
(mu4e-headers-next)))
|
||||||
@ -1378,11 +1455,11 @@ If no name is given, list all bookmarks instead."
|
|||||||
(mu4e-drafts-folder . "/protonmail/Drafts")
|
(mu4e-drafts-folder . "/protonmail/Drafts")
|
||||||
(mu4e-trash-folder . "/protonmail/Trash")
|
(mu4e-trash-folder . "/protonmail/Trash")
|
||||||
(mu4e-bookmarks . ((:name "Inbox"
|
(mu4e-bookmarks . ((:name "Inbox"
|
||||||
:query "maildir:/protonmail/Inbox"
|
:query "maildir:/protonmail/Inbox"
|
||||||
:key ?i)
|
:key ?i)
|
||||||
(:name "Unread"
|
(:name "Unread"
|
||||||
:query "flag:unread AND NOT flag:trashed AND NOT maildir:/protonmail/Spam"
|
:query "flag:unread AND NOT flag:trashed AND NOT maildir:/protonmail/Spam"
|
||||||
:key ?u))))))))
|
:key ?u))))))))
|
||||||
(use-package mu4e-alert
|
(use-package mu4e-alert
|
||||||
:after mu4e
|
:after mu4e
|
||||||
:hook (after-init . mu4e-alert-enable-notifications)
|
:hook (after-init . mu4e-alert-enable-notifications)
|
||||||
@ -1413,17 +1490,17 @@ If no name is given, list all bookmarks instead."
|
|||||||
:hook ((emacs-lisp-mode . my/-helpful-setup-emacs-lisp-mode)
|
:hook ((emacs-lisp-mode . my/-helpful-setup-emacs-lisp-mode)
|
||||||
(helpful-mode . my/-setup-helpful-mode))
|
(helpful-mode . my/-setup-helpful-mode))
|
||||||
:bind (:map help-map
|
:bind (:map help-map
|
||||||
("f" . helpful-callable)
|
("f" . helpful-callable)
|
||||||
("v" . helpful-variable)
|
("v" . helpful-variable)
|
||||||
("k" . helpful-key)
|
("k" . helpful-key)
|
||||||
("o" . helpful-symbol)
|
("o" . helpful-symbol)
|
||||||
("x" . helpful-command)
|
("x" . helpful-command)
|
||||||
("F" . helpful-function)
|
("F" . helpful-function)
|
||||||
:map helpful-mode-map
|
:map helpful-mode-map
|
||||||
("<mouse-8>" . my/helpful-history-back)
|
("<mouse-8>" . my/helpful-history-back)
|
||||||
("<mouse-9>" . my/helpful-history-forward)
|
("<mouse-9>" . my/helpful-history-forward)
|
||||||
("<normal-state><" . my/helpful-history-back)
|
("<normal-state><" . my/helpful-history-back)
|
||||||
("<normal-state>>" . my/helpful-history-forward))
|
("<normal-state>>" . my/helpful-history-forward))
|
||||||
:init
|
:init
|
||||||
(defun my/-helpful-setup-emacs-lisp-mode ()
|
(defun my/-helpful-setup-emacs-lisp-mode ()
|
||||||
(setq-local evil-lookup-func #'helpful-at-point))
|
(setq-local evil-lookup-func #'helpful-at-point))
|
||||||
@ -1634,10 +1711,12 @@ one of the normal rainbow-delimiters-depth-N-face faces."
|
|||||||
|
|
||||||
;; page break lines
|
;; page break lines
|
||||||
(use-package page-break-lines
|
(use-package page-break-lines
|
||||||
|
:hook (helpful-mode . page-break-lines-mode)
|
||||||
:config
|
:config
|
||||||
(global-page-break-lines-mode 1)
|
(global-page-break-lines-mode 1)
|
||||||
(add-to-list 'page-break-lines-modes 'prog-mode)
|
(add-to-list 'page-break-lines-modes 'prog-mode)
|
||||||
(add-to-list 'page-break-lines-modes 'text-mode))
|
(add-to-list 'page-break-lines-modes 'text-mode)
|
||||||
|
(add-to-list 'page-break-lines-modes 'helpful-mode))
|
||||||
|
|
||||||
;; fun!
|
;; fun!
|
||||||
(use-package mines)
|
(use-package mines)
|
||||||
|
Loading…
Reference in New Issue
Block a user