This commit is contained in:
Joe Frikker
2026-04-29 23:02:53 -04:00
parent 09bfc2f8a6
commit 4bec74fd5f

208
home.org
View File

@@ -752,19 +752,19 @@ These are just some general settings that apply everywhere. First, a few package
Turn off some default settings that I don't find useful. Turn off some default settings that I don't find useful.
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(setq inhibit-startup-screen t) (setopt inhibit-startup-screen t)
(setq initial-scratch-message nil) (setopt initial-scratch-message nil)
(menu-bar-mode -1) (menu-bar-mode -1)
(scroll-bar-mode -1) (scroll-bar-mode -1)
(tool-bar-mode -1) (tool-bar-mode -1)
(setq make-backup-files nil) (setopt make-backup-files nil)
(setq split-width-threshold 200) (setopt split-width-threshold 200)
(setq split-height-threshold nil) (setopt split-height-threshold nil)
(setopt display-buffer-base-action (setopt display-buffer-base-action
'((display-buffer-reuse-window display-buffer-same-window '((display-buffer-reuse-window display-buffer-same-window
display-buffer-in-previous-window display-buffer-in-previous-window
display-buffer-use-some-window))) display-buffer-use-some-window)))
(setq view-read-only t) (setopt view-read-only t)
#+END_SRC #+END_SRC
Make sure which-key mode is always on. The on-the-fly keymap help it gives is indespensable. Make sure which-key mode is always on. The on-the-fly keymap help it gives is indespensable.
@@ -791,7 +791,7 @@ From the docs: "If complete, TAB first tries to indent the current line, a
already indented, then try to complete the thing at point." Recommended by [[https://github.com/minad/corfu][the ~corfu~ readme]]. already indented, then try to complete the thing at point." Recommended by [[https://github.com/minad/corfu][the ~corfu~ readme]].
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(setq tab-always-indent 'complete) (setopt tab-always-indent 'complete)
#+END_SRC #+END_SRC
Set the cursor to be a bar. I'm not sure what the benefit would be of a block cursor, since the Set the cursor to be a bar. I'm not sure what the benefit would be of a block cursor, since the
@@ -845,7 +845,6 @@ cool, so I'm turning it on in prog mode. The enabled ligatures are font-specific
ligature wiki]]. ligature wiki]].
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(require 'ligature)
(ligature-set-ligatures 'prog-mode (ligature-set-ligatures 'prog-mode
'("--" "---" "==" "===" "!=" "!==" "=!=" '("--" "---" "==" "===" "!=" "!==" "=!="
"=:=" "=/=" "<=" ">=" "&&" "&&&" "&=" "++" "+++" "***" ";;" "!!" "=:=" "=/=" "<=" ">=" "&&" "&&&" "&=" "++" "+++" "***" ";;" "!!"
@@ -878,7 +877,6 @@ Use variable-width fonts in text buffers. ~mixed-pitch-mode~ keeps most code blo
A basic ace-window setup. Allows switching between windows quickly (although avy can do the same...). A basic ace-window setup. Allows switching between windows quickly (although avy can do the same...).
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(require 'ace-window)
(bind-keys ("M-o" . ace-window) (bind-keys ("M-o" . ace-window)
("s-o" . ace-window)) ("s-o" . ace-window))
(setopt aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)) (setopt aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))
@@ -890,8 +888,10 @@ Set up a few project- / workspace-related key bindings.
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(bind-keys ("s-f" . project-find-file) (bind-keys ("s-f" . project-find-file)
("s-F" . project-switch-project)) ("s-F" . project-switch-project))
(bind-keys :map tab-bar-mode-map
("s-s" . tab-bar-switch-to-tab)) (with-eval-after-load tab-bar-mode
(bind-keys :map tab-bar-mode-map
("s-s" . tab-bar-switch-to-tab)))
#+END_SRC #+END_SRC
Don't run a server. I'm not using this, I can always turn it back on if I need to. Don't run a server. I'm not using this, I can always turn it back on if I need to.
@@ -904,7 +904,7 @@ All the beeping is annoying. This flashes a huge icon over the screen, which is
less so? less so?
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(setq visible-bell t) (setopt visible-bell t)
#+END_SRC #+END_SRC
I'm trying this out. This disables visual selections. It's bold, which is why I like it :) I'm trying this out. This disables visual selections. It's bold, which is why I like it :)
@@ -922,14 +922,19 @@ change when drilling into a help page or something. I've set up repeat mode to m
move backward / forward through history. move backward / forward through history.
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(require 'tab-bar)
(bind-keys :repeat-map tab-bar-repeat-map (bind-keys :repeat-map tab-bar-repeat-map
("<left>" . tab-bar-history-back) ("<left>" . tab-bar-history-back)
("<right>" . tab-bar-history-forward)) ("<right>" . tab-bar-history-forward))
(tab-bar-history-mode) (tab-bar-history-mode)
#+END_SRC #+END_SRC
Make compilation mode buffers auto-scroll to the first error:
#+BEGIN_SRC elisp
(setopt compilation-scroll-output 'first-error)
#+END_SRC
*** Window Placement *** Window Placement
This section contains rules about where ~display-buffer~ should place windows. I guess I'm currently This section contains rules about where ~display-buffer~ should place windows. I guess I'm currently
going for an IDE-style layout, with one main editor window, and auxiliary bottom and right side going for an IDE-style layout, with one main editor window, and auxiliary bottom and right side
@@ -987,6 +992,7 @@ content to be.
window-persistent-parameters)) window-persistent-parameters))
#+END_SRC #+END_SRC
** Editing ** Editing
:PROPERTIES: :PROPERTIES:
:header-args:elisp: :tangle target/desktop/emacs-editing.el :header-args:elisp: :tangle target/desktop/emacs-editing.el
@@ -1062,11 +1068,9 @@ ideas from Karthinks' article [[https://karthinks.com/software/avy-can-do-anythi
his article. his article.
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(require 'avy)
(require 'embark)
(defun avy-goto-char-timer-embark () (defun avy-goto-char-timer-embark ()
(interactive) (interactive)
(require 'avy)
(let ((avy-action-oneshot (let ((avy-action-oneshot
(lambda (pt) (lambda (pt)
(unwind-protect (unwind-protect
@@ -1090,7 +1094,6 @@ Just "silently" wrap when searching at the bottom of a document.
#+END_SRC #+END_SRC
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(require 'string-inflection)
(defun string-inflection-rust-style-cycle-function (str) (defun string-inflection-rust-style-cycle-function (str)
(cond (cond
((string-inflection-snake-case-p str) ((string-inflection-snake-case-p str)
@@ -1102,6 +1105,7 @@ Just "silently" wrap when searching at the bottom of a document.
(defun string-inflection-rust-style-cycle () (defun string-inflection-rust-style-cycle ()
(interactive) (interactive)
(require 'string-inflection)
(string-inflection--symbol-or-region #'string-inflection-rust-style-cycle-function)) (string-inflection--symbol-or-region #'string-inflection-rust-style-cycle-function))
(bind-keys :repeat-map string-inflection-java-map (bind-keys :repeat-map string-inflection-java-map
@@ -1149,57 +1153,59 @@ available? It seems to work for now anyway...
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(electric-pair-mode 1) (electric-pair-mode 1)
(require 'prog-mode) (autoload 'flymake-show-project-diagnostics "flymake")
(defun my-prog-fill-reindent-defun (&optional argument) (autoload 'flymake-goto-next-error "flymake")
"Refill or reindent the paragraph or defun that contains point. (autoload 'flymake-goto-prev-error "flymake")
(with-eval-after-load 'prog-mode
(defun my-prog-fill-reindent-defun (&optional argument)
"Refill or reindent the paragraph or defun that contains point.
If the point is in a string or a comment, fill the paragraph that If the point is in a string or a comment, fill the paragraph that
contains point or follows point. contains point or follows point.
Otherwise, reindent the function definition that contains point Otherwise, reindent the function definition that contains point
or follows point." or follows point."
(interactive "P") (interactive "P")
(save-excursion (save-excursion
(let ((treesit-text-node (let ((treesit-text-node
(and (treesit-available-p) (and (treesit-available-p)
(treesit-parser-list) (treesit-parser-list)
(treesit-node-match-p (treesit-node-match-p
(treesit-node-at (point)) 'text t)))) (treesit-node-at (point)) 'text t))))
(if (or treesit-text-node (if (or treesit-text-node
(and (not (and (treesit-available-p) (treesit-parser-list))) (nth 8 (syntax-ppss))) (and (not (and (treesit-available-p) (treesit-parser-list))) (nth 8 (syntax-ppss)))
(re-search-forward "\\s-*\\s<" (line-end-position) t)) (re-search-forward "\\s-*\\s<" (line-end-position) t))
(fill-paragraph argument (region-active-p)) (fill-paragraph argument (region-active-p))
(beginning-of-defun) (beginning-of-defun)
(let ((start (point))) (let ((start (point)))
(end-of-defun) (end-of-defun)
(indent-region start (point) nil)))))) (indent-region start (point) nil))))))
(advice-add 'prog-fill-reindent-defun :override #'my-prog-fill-reindent-defun) (advice-add 'prog-fill-reindent-defun :override #'my-prog-fill-reindent-defun)
(require 'flymake) (bind-keys :map prog-mode-map
(bind-keys :map prog-mode-map ("C-c D" . flymake-show-project-diagnostics)
("C-c D" . flymake-show-project-diagnostics) ("M-n" . flymake-goto-next-error)
("M-n" . flymake-goto-next-error) ("M-p" . flymake-goto-prev-error))
("M-p" . flymake-goto-prev-error)) (defun jf-init-fill-column ()
(display-fill-column-indicator-mode 1))
(add-hook 'prog-mode-hook 'jf-init-fill-column))
(setq-default indent-tabs-mode nil) (setq-default indent-tabs-mode nil)
(setq-default tab-width 4) (setq-default tab-width 4)
(global-tree-sitter-mode 1) (global-tree-sitter-mode 1)
(setq-default fill-column 100) (setq-default fill-column 100)
(defun jf-init-fill-column ()
(display-fill-column-indicator-mode 1))
(add-hook 'prog-mode-hook 'jf-init-fill-column)
(setopt eglot-ignored-server-capabilities '(:inlayHintProvider :semanticTokensProvider)) (setopt eglot-ignored-server-capabilities '(:inlayHintProvider :semanticTokensProvider))
(add-hook 'eglot-managed-mode-hook (lambda () (eglot-inlay-hints-mode -1)) nil t) (add-hook 'eglot-managed-mode-hook (lambda () (eglot-inlay-hints-mode -1)) nil t)
(require 'eglot)
(setopt eglot-code-action-indications nil) (setopt eglot-code-action-indications nil)
(bind-keys :map eglot-mode-map (with-eval-after-load 'eglot
("C-c a" . eglot-code-actions) (bind-keys :map eglot-mode-map
("C-c r" . eglot-rename) ("C-c a" . eglot-code-actions)
("C-c i" . eglot-find-implementation)) ("C-c r" . eglot-rename)
(add-to-list 'eglot-stay-out-of 'yasnippet) ("C-c i" . eglot-find-implementation))
(add-to-list 'eglot-stay-out-of 'yasnippet))
(setopt ediff-split-window-function 'split-window-horizontally) (setopt ediff-split-window-function 'split-window-horizontally)
@@ -1208,9 +1214,9 @@ available? It seems to work for now anyway...
(nix-flake (project-root (project-current t)))) (nix-flake (project-root (project-current t))))
(bind-keys ("C-x p n" . project-nix-flake)) (bind-keys ("C-x p n" . project-nix-flake))
(require 'flymake) (with-eval-after-load 'flymake
(bind-keys :map flymake-project-diagnostics-mode-map (bind-keys :map flymake-project-diagnostics-mode-map
("q" . quit-window)) ("q" . quit-window)))
#+END_SRC #+END_SRC
*** Rust *** Rust
@@ -1219,15 +1225,13 @@ available? It seems to work for now anyway...
(setopt rust-mode-treesitter-derive t) (setopt rust-mode-treesitter-derive t)
(require 'rust-ts-mode) (with-eval-after-load 'rust-prog-mode
(bind-keys :map rust-ts-mode-map (bind-keys :map rust-mode-map
("C-c u" . string-inflection-rust-style-cycle)) ("C-c u" . string-inflection-rust-style-cycle)))
#+END_SRC #+END_SRC
*** YAML *** YAML
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(require 'yaml-ts-mode)
(defun yaml-validate () (defun yaml-validate ()
(interactive) (interactive)
(compile (concat "yamllint -d '{extends: default, rules: {indentation: {indent-sequences: false}, braces: {max-spaces-inside: 1}}}' " (buffer-file-name)) t)) (compile (concat "yamllint -d '{extends: default, rules: {indentation: {indent-sequences: false}, braces: {max-spaces-inside: 1}}}' " (buffer-file-name)) t))
@@ -1242,59 +1246,59 @@ available? It seems to work for now anyway...
(setopt lispy-compat '(god-mode edebug)) (setopt lispy-compat '(god-mode edebug))
(add-hook 'emacs-lisp-mode-hook (lambda () (lispy-mode 1))) (add-hook 'emacs-lisp-mode-hook (lambda () (lispy-mode 1)))
(add-hook 'lisp-mode-hook (lambda () (lispy-mode 1))) (add-hook 'lisp-mode-hook (lambda () (lispy-mode 1)))
(require 'lispy) (with-eval-after-load 'lispy
(bind-keys :map lispy-mode-map (bind-keys :map lispy-mode-map
("i" . (lambda () ("i" . (lambda ()
(interactive) (interactive)
(if god-global-mode (if (and (featurep 'god-mode) god-global-mode)
(god-mode-all -1) (god-mode-all -1)
(special-lispy-tab))))) (special-lispy-tab))))))
#+END_SRC #+END_SRC
*** Typescript *** Typescript
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(setopt typescript-ts-mode-indent-offset 4) (setopt typescript-ts-mode-indent-offset 4)
(require 'typescript-ts-mode) (with-eval-after-load 'typescript-ts-mode
(defun my-tsx-ts-mode--indent-compatibility-b893426 () (defun my-tsx-ts-mode--indent-compatibility-b893426 ()
"Indent rules helper, to handle different releases of tree-sitter-tsx. "Indent rules helper, to handle different releases of tree-sitter-tsx.
Check if a node type is available, then return the right indent rules." Check if a node type is available, then return the right indent rules."
;; handle https://github.com/tree-sitter/tree-sitter-typescript/commit/b893426b82492e59388a326b824a346d829487e8 ;; handle https://github.com/tree-sitter/tree-sitter-typescript/commit/b893426b82492e59388a326b824a346d829487e8
(condition-case nil (condition-case nil
(progn (treesit-query-capture 'tsx '((jsx_fragment) @capture)) (progn (treesit-query-capture 'tsx '((jsx_fragment) @capture))
`(((match "<" "jsx_fragment") parent 0) `(((match "<" "jsx_fragment") parent 0)
((parent-is "jsx_fragment") parent typescript-ts-mode-indent-offset))) ((parent-is "jsx_fragment") parent typescript-ts-mode-indent-offset)))
(treesit-query-error (treesit-query-error
`(((match "<" "jsx_text") parent 0) `(((match "<" "jsx_text") parent 0)
((parent-is "jsx_text") grand-parent typescript-ts-mode-indent-offset))))) ((parent-is "jsx_text") grand-parent typescript-ts-mode-indent-offset)))))
(advice-add 'tsx-ts-mode--indent-compatibility-b893426 :override #'my-tsx-ts-mode--indent-compatibility-b893426) (advice-add 'tsx-ts-mode--indent-compatibility-b893426 :override #'my-tsx-ts-mode--indent-compatibility-b893426))
#+END_SRC #+END_SRC
*** Java *** Java
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(require 'java-ts-mode) (with-eval-after-load 'java-ts-mode
(bind-keys :map java-ts-mode-map (bind-keys :map java-ts-mode-map
("C-c u" . string-inflection-java-style-cycle)) ("C-c u" . string-inflection-java-style-cycle))
(push `((n-p-gp nil "block" "lambda_expression") parent-bol java-ts-mode-indent-offset) (push `((n-p-gp nil "block" "lambda_expression") parent-bol java-ts-mode-indent-offset)
(cdar java-ts-mode--indent-rules)) (cdar java-ts-mode--indent-rules))
(push `((n-p-gp "}" "block" "lambda_expression") parent-bol 0) (push `((n-p-gp "}" "block" "lambda_expression") parent-bol 0)
(cdar java-ts-mode--indent-rules)) (cdar java-ts-mode--indent-rules))
(add-hook 'java-mode-hook (lambda () (c-set-offset 'arglist-intro '+))) (add-hook 'java-mode-hook (lambda () (c-set-offset 'arglist-intro '+)))
(defvar jf/class-name-to-file-search-path (list "src/main/java" "src/test/java")) (defvar jf/class-name-to-file-search-path (list "src/main/java" "src/test/java"))
(defun jf/class-name-to-file (class-name) (defun jf/class-name-to-file (class-name)
(let ((root (project-root (project-current t))) (let ((root (project-root (project-current t)))
(fragment (format "%s.java" (replace-regexp-in-string "\\." "/" class-name))) (fragment (format "%s.java" (replace-regexp-in-string "\\." "/" class-name)))
(result)) (result))
(dolist (p jf/class-name-to-file-search-path result) (dolist (p jf/class-name-to-file-search-path result)
(unless result (unless result
(let ((path (format "%s/%s" p fragment))) (let ((path (format "%s/%s" p fragment)))
(when (file-exists-p (concat root path)) (when (file-exists-p (concat root path))
(setq result path))))))) (setq result path)))))))
(defun jf/compile-class-to-file () (defun jf/compile-class-to-file ()
(jf/class-name-to-file (concat (match-string 1) (match-string 2)))) (jf/class-name-to-file (concat (match-string 1) (match-string 2)))))
;(add-to-list 'compilation-error-regexp-alist-alist ;(add-to-list 'compilation-error-regexp-alist-alist
; '(java-stack-trace . ; '(java-stack-trace .
@@ -1357,7 +1361,7 @@ available? It seems to work for now anyway...
#+END_SRC #+END_SRC
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(setq magit-define-global-key-bindings 'recommended) (setopt magit-define-global-key-bindings 'recommended)
(setopt magit-save-repository-buffers 'dontask) (setopt magit-save-repository-buffers 'dontask)
(setopt magit-commit-show-diff nil) (setopt magit-commit-show-diff nil)
@@ -1476,8 +1480,8 @@ available? It seems to work for now anyway...
(setopt corfu-popupinfo-mode nil) (setopt corfu-popupinfo-mode nil)
(setopt corfu-quit-at-boundary nil) (setopt corfu-quit-at-boundary nil)
(setopt corfu-on-exact-match 'show) (setopt corfu-on-exact-match 'show)
;; (global-corfu-mode) (global-corfu-mode)
(setq completion-in-region-function #'consult-completion-in-region) ;; (setq completion-in-region-function #'consult-completion-in-region)
;; Consult users will also want the embark-consult package. ;; Consult users will also want the embark-consult package.
(add-hook 'embark-collect-mode-hook 'consult-preview-at-point-mode) (add-hook 'embark-collect-mode-hook 'consult-preview-at-point-mode)