diff --git a/init.el b/init.el index bb16383..fc5bb46 100644 --- a/init.el +++ b/init.el @@ -46,8 +46,8 @@ ;; basic stuff (use-package emacs - :hook (;(emacs-lisp-mode . my/-emacs-lisp-mode-setup-evil-lookup) - (prog-mode . electric-pair-local-mode) + :hook (;;(emacs-lisp-mode . my/-emacs-lisp-mode-setup-evil-lookup) + ;;(prog-mode . electric-pair-local-mode) ((text-mode message-mode tex-mode) . flyspell-mode) ((text-mode message-mode tex-mode prog-mode) . auto-fill-mode) (prog-mode . flyspell-prog-mode)) @@ -137,7 +137,8 @@ (setq-default indent-tabs-mode nil tab-width 4 fill-column 80 - comment-multi-line t) + comment-multi-line t + comment-empty-lines 'eol) ;; Tree sitter download locations (setq treesit-language-source-alist @@ -209,8 +210,8 @@ Interactively, force the recompile if called with a prefix." (use-package flyspell :config (setq ispell-program-name "hunspell" - flyspell-issue-message-flag nil - flyspell-issue-welcome-flag nil) + flyspell-issue-message-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)) @@ -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/dec-at-pt-incremental))) (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-" . paredit-RET) + ("C-RET" . paredit-RET)) :custom + (eldoc-add-command 'paredit-RET) (evil-cleverparens-use-s-and-S nil)) ;; make lisp editing nicer @@ -372,12 +378,12 @@ visual states." ;; vertico (use-package vertico :bind (:map vertico-map - ("C-S-k" . kill-line) - ("C-k" . vertico-previous) - ("C-j" . vertico-next) - ("RET" . vertico-directory-enter) - ("DEL" . vertico-directory-delete-char) - ("M-DEL" . vertico-directory-delete-word)) + ("C-S-k" . kill-line) + ("C-k" . vertico-previous) + ("C-j" . vertico-next) + ("RET" . vertico-directory-enter) + ("DEL" . vertico-directory-delete-char) + ("M-DEL" . vertico-directory-delete-word)) :hook (minibuffer-setup . cursor-intangible-mode) :init (defun my/crm-indicator (args) @@ -392,8 +398,8 @@ visual states." enable-recursive-minibuffers t read-extended-command-predicate #'command-completion-default-include-p minibuffer-prompt-properties '(read-only t - cursor-intangible t - face minibuffer-prompt)) + cursor-intangible t + face minibuffer-prompt)) (vertico-mode 1)) ;; orderless @@ -414,10 +420,10 @@ visual states." (command (styles my/orderless-with-initialism basic))))) -; marginalia +;; marginalia (use-package marginalia :bind (:map minibuffer-local-map - ("M-a" . marginalia-cycle)) + ("M-a" . marginalia-cycle)) :init (marginalia-mode 1)) @@ -455,6 +461,9 @@ visual states." ("M-g i" . consult-imenu) ("M-g I" . 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-" . newline) :map help-map ("TAB". consult-info) ("C-m" . consult-man)) @@ -484,7 +493,7 @@ visual states." :config (defun my/-company-setup-shell-mode () (setq-local company-backends '(company-files company-keywords - company-dabbrev-code))) + company-dabbrev-code))) (defun my/-company-search-mode-add-lighter () (if company-search-mode (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" "--header-insertion=never" "--pch-storage=memory" "--function-arg-placeholders")))) - ;"--malloc-trim" "--function-arg-placeholders")))) ;; gud (use-package gud @@ -645,7 +653,7 @@ to `posframe-show' if the display is graphical." :ensure nil :after (project evil) :bind (:map project-prefix-map - ("U" . my/project-gdb)) + ("U" . my/project-gdb)) :init (setq gdb-debuginfod-enable-setting t) (defvar my/project-gdb-command nil @@ -973,11 +981,80 @@ COMMAND and COMINT are like `compile'." ;; yuck (config language for eww) (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 (use-package sly :hook (lisp-mode . my/-lisp-mode-autoconnect-sly) :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 :init (defun my/-lisp-mode-autoconnect-sly () @@ -1343,7 +1420,7 @@ If no name is given, list all bookmarks instead." (trashed)." (interactive) (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) (when mu4e-headers-advance-after-mark (mu4e-headers-next))) @@ -1378,11 +1455,11 @@ If no name is given, list all bookmarks instead." (mu4e-drafts-folder . "/protonmail/Drafts") (mu4e-trash-folder . "/protonmail/Trash") (mu4e-bookmarks . ((:name "Inbox" - :query "maildir:/protonmail/Inbox" - :key ?i) + :query "maildir:/protonmail/Inbox" + :key ?i) (:name "Unread" - :query "flag:unread AND NOT flag:trashed AND NOT maildir:/protonmail/Spam" - :key ?u)))))))) + :query "flag:unread AND NOT flag:trashed AND NOT maildir:/protonmail/Spam" + :key ?u)))))))) (use-package mu4e-alert :after mu4e :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) (helpful-mode . my/-setup-helpful-mode)) :bind (:map help-map - ("f" . helpful-callable) - ("v" . helpful-variable) - ("k" . helpful-key) - ("o" . helpful-symbol) - ("x" . helpful-command) - ("F" . helpful-function) - :map helpful-mode-map - ("" . my/helpful-history-back) - ("" . my/helpful-history-forward) - ("<" . my/helpful-history-back) - (">" . my/helpful-history-forward)) + ("f" . helpful-callable) + ("v" . helpful-variable) + ("k" . helpful-key) + ("o" . helpful-symbol) + ("x" . helpful-command) + ("F" . helpful-function) + :map helpful-mode-map + ("" . my/helpful-history-back) + ("" . my/helpful-history-forward) + ("<" . my/helpful-history-back) + (">" . my/helpful-history-forward)) :init (defun my/-helpful-setup-emacs-lisp-mode () (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 (use-package page-break-lines + :hook (helpful-mode . page-break-lines-mode) :config (global-page-break-lines-mode 1) (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! (use-package mines)