Add some elisp editing stuff
This commit is contained in:
parent
35797a591d
commit
a3791c4048
95
init.el
95
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
|
||||||
@ -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
|
||||||
@ -414,7 +420,7 @@ 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))
|
||||||
@ -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))
|
||||||
@ -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
|
||||||
@ -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 ()
|
||||||
@ -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