chore: updated emacs config
6f3e80d7
6 file(s) · +191 −3
| 21 | 21 | (require 'init-evil) |
|
| 22 | 22 | (require 'init-ui) |
|
| 23 | 23 | (require 'init-erc) |
|
| 24 | + | (require 'init-jabber) |
|
| 25 | + | (require 'init-lang) |
|
| 24 | 26 | (require 'init-tools) |
|
| 27 | + | (require 'init-term) |
| 36 | 36 | "b" '(:ignore t :wk "buffer") |
|
| 37 | 37 | "bb" '(switch-to-buffer :wk "switch") |
|
| 38 | 38 | "bi" '(ibuffer :wk "ibuffer") |
|
| 39 | - | "bk" '(kill-current-buffer :wk "kill") |
|
| 39 | + | "bd" '(kill-current-buffer :wk "kill") |
|
| 40 | 40 | "bn" '(next-buffer :wk "next") |
|
| 41 | 41 | "bp" '(previous-buffer :wk "previous") |
|
| 42 | 42 | "bs" '(save-buffer :wk "save") |
|
| 55 | 55 | "o" '(:ignore t :wk "open") |
|
| 56 | 56 | "oe" '(elfeed :wk "elfeed") |
|
| 57 | 57 | "oi" '(my/erc-soju :wk "irc") |
|
| 58 | - | "ot" '(eshell :wk "eshell") |
|
| 58 | + | "oj" '(jabber-roster :wk "jabber") |
|
| 59 | + | "ot" '(ghostel :wk "terminal") |
|
| 60 | + | "oT" '(ghostel-project :wk "project terminal") |
|
| 61 | + | "os" '(eshell :wk "eshell") |
|
| 59 | 62 | ||
| 60 | 63 | "p" '(:ignore t :wk "project") |
|
| 61 | 64 | "pp" '(project-switch-project :wk "switch") |
|
| 1 | + | ;;; init-jabber.el -*- lexical-binding: t; -*- |
|
| 2 | + | ||
| 3 | + | (require 'auth-source-pass) |
|
| 4 | + | ||
| 5 | + | ;; Built from git for OMEMO. Native module needs `brew install mbedtls@3' |
|
| 6 | + | ;; (4.x dropped mbedtls/aes.h); macOS has no getrandom, so shim it. |
|
| 7 | + | (use-package jabber |
|
| 8 | + | :vc (:url "https://git.thanosapollo.org/emacs-jabber" |
|
| 9 | + | :lisp-dir "lisp" |
|
| 10 | + | :shell-command "PKG_CONFIG_PATH=/opt/homebrew/opt/mbedtls@3/lib/pkgconfig CFLAGS=\"-I/opt/homebrew/opt/emacs/include '-Dgetrandom(b,n,f)=(arc4random_buf((b),(n)),(ssize_t)(n))'\" MBED_STATIC=1 make module") |
|
| 11 | + | :defer t |
|
| 12 | + | :init |
|
| 13 | + | ;; `jabber-roster' autoloads from jabber-roster-menu, which never loads |
|
| 14 | + | ;; jabber.el, so :config (account list) would never run. Pull it in. |
|
| 15 | + | (with-eval-after-load 'jabber-roster-menu (require 'jabber)) |
|
| 16 | + | :config |
|
| 17 | + | (setq jabber-account-list |
|
| 18 | + | `(("stevedylandev@xmpp.is" |
|
| 19 | + | (:password . ,(auth-source-pass-get 'secret "xmpp/stevedylandev@xmpp.is"))))) |
|
| 20 | + | (jabber-modeline-mode 1)) |
|
| 21 | + | ||
| 22 | + | (with-eval-after-load 'jabber-omemo-trust |
|
| 23 | + | (evil-define-key 'normal jabber-omemo-trust-mode-map |
|
| 24 | + | "t" #'jabber-omemo-trust-set-verified |
|
| 25 | + | "u" #'jabber-omemo-trust-set-untrusted |
|
| 26 | + | "w" #'jabber-omemo-trust-copy-fingerprint |
|
| 27 | + | "r" #'jabber-omemo-reset-session |
|
| 28 | + | "d" #'jabber-omemo-trust-delete |
|
| 29 | + | "G" #'jabber-omemo-trust-refresh |
|
| 30 | + | "?" #'jabber-omemo-trust-menu)) |
|
| 31 | + | ||
| 32 | + | (provide 'init-jabber) |
| 1 | + | ;;; init-lang.el -*- lexical-binding: t; -*- |
|
| 2 | + | ||
| 3 | + | ;;; Syntax highlighting: tree-sitter (built-in) |
|
| 4 | + | ;; Every built-in *-ts-mode replaces its classic mode, and the grammar is |
|
| 5 | + | ;; compiled into ~/.config/emacs/tree-sitter the first time it's needed. |
|
| 6 | + | ;; Needs a C compiler (xcode-select --install). |
|
| 7 | + | (setopt treesit-enabled-modes t |
|
| 8 | + | treesit-auto-install-grammar 'always |
|
| 9 | + | treesit-font-lock-level 4) ; 4 = everything (calls, properties, operators) |
|
| 10 | + | ||
| 11 | + | ;;; LSP: eglot (built-in) |
|
| 12 | + | ;; Add a language: one line here. MODES is a ts-mode (or list of them), |
|
| 13 | + | ;; SERVER is the command eglot runs. Entries whose server binary isn't on |
|
| 14 | + | ;; PATH are skipped, so it's fine to list servers you haven't installed. |
|
| 15 | + | ;; A mode not built into Emacs needs its package first, e.g. |
|
| 16 | + | ;; (use-package zig-mode) then (zig-mode "zls") |
|
| 17 | + | (defvar my/lsp-servers |
|
| 18 | + | '(((typescript-ts-mode tsx-ts-mode js-ts-mode) "vtsls" "--stdio") |
|
| 19 | + | (rust-ts-mode "rust-analyzer") |
|
| 20 | + | ((go-ts-mode go-mod-ts-mode) "gopls") |
|
| 21 | + | ((c-ts-mode c++-ts-mode) "clangd") |
|
| 22 | + | (lua-ts-mode "lua-language-server") |
|
| 23 | + | (css-ts-mode "vscode-css-language-server" "--stdio") |
|
| 24 | + | ((mhtml-ts-mode html-ts-mode) "vscode-html-language-server" "--stdio") |
|
| 25 | + | (json-ts-mode "vscode-json-language-server" "--stdio") |
|
| 26 | + | (python-ts-mode "basedpyright-langserver" "--stdio") |
|
| 27 | + | (bash-ts-mode "bash-language-server" "start")) |
|
| 28 | + | "Alist of (MODES SERVER ARGS...) used to auto-start eglot.") |
|
| 29 | + | ||
| 30 | + | (use-package eglot |
|
| 31 | + | :ensure nil |
|
| 32 | + | :custom |
|
| 33 | + | (eglot-autoshutdown t) ; kill server when last buffer closes |
|
| 34 | + | (eglot-events-buffer-config '(:size 0 :format full)) ; no event logging |
|
| 35 | + | (eglot-extend-to-xref t) ; stay in eglot when jumping into deps |
|
| 36 | + | :config |
|
| 37 | + | (dolist (entry my/lsp-servers) |
|
| 38 | + | (let ((modes (ensure-list (car entry))) |
|
| 39 | + | (cmd (cdr entry))) |
|
| 40 | + | (when (executable-find (car cmd)) |
|
| 41 | + | (add-to-list 'eglot-server-programs (cons modes cmd)) |
|
| 42 | + | (dolist (mode modes) |
|
| 43 | + | (add-hook (intern (format "%s-hook" mode)) #'eglot-ensure)))))) |
|
| 44 | + | ||
| 45 | + | ;; Diagnostics |
|
| 46 | + | (setq flymake-show-diagnostics-at-end-of-line 'short) |
|
| 47 | + | ||
| 48 | + | (with-eval-after-load 'general |
|
| 49 | + | (my/leader |
|
| 50 | + | "c" '(:ignore t :wk "code") |
|
| 51 | + | "ca" '(eglot-code-actions :wk "actions") |
|
| 52 | + | "cr" '(eglot-rename :wk "rename") |
|
| 53 | + | "cf" '(eglot-format-buffer :wk "format") |
|
| 54 | + | "cd" '(xref-find-definitions :wk "definition") |
|
| 55 | + | "cR" '(xref-find-references :wk "references") |
|
| 56 | + | "ci" '(eglot-find-implementation :wk "implementation") |
|
| 57 | + | "ct" '(eglot-find-typeDefinition :wk "type def") |
|
| 58 | + | "ce" '(flymake-show-buffer-diagnostics :wk "errors") |
|
| 59 | + | "cE" '(flymake-show-project-diagnostics :wk "project errors") |
|
| 60 | + | "cn" '(flymake-goto-next-error :wk "next error") |
|
| 61 | + | "cp" '(flymake-goto-prev-error :wk "prev error") |
|
| 62 | + | "cl" '(eglot :wk "start lsp") |
|
| 63 | + | "cL" '(eglot-shutdown :wk "stop lsp"))) |
|
| 64 | + | ||
| 65 | + | (provide 'init-lang) |
| 1 | + | ;;; init-term.el -*- lexical-binding: t; -*- |
|
| 2 | + | ||
| 3 | + | ;; Ghostel: libghostty-vt backed terminal. Native module downloads on first use. |
|
| 4 | + | (use-package ghostel |
|
| 5 | + | :commands (ghostel ghostel-project) |
|
| 6 | + | :init |
|
| 7 | + | (setq ghostel-timer-delay 0.01 |
|
| 8 | + | ghostel-max-scrollback (* 1024 1024))) |
|
| 9 | + | ||
| 10 | + | (use-package evil-ghostel |
|
| 11 | + | :after (ghostel evil) |
|
| 12 | + | :hook (ghostel-mode . evil-ghostel-mode)) |
|
| 13 | + | ||
| 14 | + | ;; Terminal perf tweaks, adapted from James Cherti (MIT): |
|
| 15 | + | ;; https://www.jamescherti.com/emacs-terminal-performance-vterm-eat-ansi-term-ghostel/ |
|
| 16 | + | (defun my/speed-up-terminal-buffer () |
|
| 17 | + | "Reduce unnecessary Emacs features in terminal buffers." |
|
| 18 | + | (let ((ghostel-buffer (derived-mode-p 'ghostel-mode))) |
|
| 19 | + | (setq-local font-lock-defaults '(nil t)) |
|
| 20 | + | ||
| 21 | + | (setq-local scroll-conservatively most-positive-fixnum) |
|
| 22 | + | (setq-local hscroll-margin 0) |
|
| 23 | + | (setq-local scroll-margin 0) |
|
| 24 | + | (setq-local auto-hscroll-mode nil) |
|
| 25 | + | ||
| 26 | + | (setq-local truncate-lines t) |
|
| 27 | + | (setq-local nobreak-char-display nil) |
|
| 28 | + | (setq-local bidi-paragraph-direction 'left-to-right) |
|
| 29 | + | (setq-local bidi-inhibit-bpa t) |
|
| 30 | + | ||
| 31 | + | ;; Ghostel computes row height from ghostel-line-spacing |
|
| 32 | + | (unless ghostel-buffer |
|
| 33 | + | (setq-local line-spacing 0) |
|
| 34 | + | (setq-local mode-line-format nil)) |
|
| 35 | + | ||
| 36 | + | (setq-local process-adaptive-read-buffering nil) |
|
| 37 | + | (let ((output-max (* 1024 1024))) |
|
| 38 | + | (when (< read-process-output-max output-max) |
|
| 39 | + | (setq-local read-process-output-max output-max))) |
|
| 40 | + | ||
| 41 | + | (buffer-disable-undo) |
|
| 42 | + | ||
| 43 | + | ;; Evil jump list hooks (C-o / C-i won't work in terminals) |
|
| 44 | + | (remove-hook 'pre-command-hook 'evil--jump-hook t) |
|
| 45 | + | (remove-hook 'post-command-hook 'evil--jump-handle-buffer-crossing t) |
|
| 46 | + | ||
| 47 | + | (let ((inhibit-redisplay t) |
|
| 48 | + | (inhibit-message t) |
|
| 49 | + | (modes (list 'electric-pair-local-mode |
|
| 50 | + | 'electric-indent-local-mode |
|
| 51 | + | 'display-line-numbers-mode |
|
| 52 | + | 'display-fill-column-indicator-mode |
|
| 53 | + | 'hl-line-mode |
|
| 54 | + | 'show-paren-local-mode |
|
| 55 | + | 'flymake-mode |
|
| 56 | + | 'flycheck-mode |
|
| 57 | + | 'evil-surround-mode |
|
| 58 | + | 'yas-minor-mode |
|
| 59 | + | 'company-mode |
|
| 60 | + | 'corfu-mode))) |
|
| 61 | + | ;; Ghostel relies on eldoc (link targets) and auto-composition |
|
| 62 | + | (unless ghostel-buffer |
|
| 63 | + | (push 'eldoc-mode modes) |
|
| 64 | + | (push 'auto-composition-mode modes)) |
|
| 65 | + | (dolist (mode modes) |
|
| 66 | + | (when (fboundp mode) |
|
| 67 | + | (ignore-errors (funcall mode -1))))))) |
|
| 68 | + | ||
| 69 | + | (add-hook 'term-mode-hook #'my/speed-up-terminal-buffer t) |
|
| 70 | + | (add-hook 'ghostel-mode-hook #'my/speed-up-terminal-buffer t) |
|
| 71 | + | ||
| 72 | + | (provide 'init-term) |
| 114 | 114 | `(line-number-current-line ((t (:foreground ,orange :background ,bg)))) |
|
| 115 | 115 | `(vertical-border ((t (:foreground ,sel)))) |
|
| 116 | 116 | `(erc-prompt-face ((t (:foreground ,orange :weight bold)))) |
|
| 117 | - | ||
| 117 | + | ;; base16 makes this inherit gnus-group-news-6, whose default spec |
|
| 118 | + | ;; inherits this face back -> cycle error in enable-theme |
|
| 119 | + | `(gnus-group-news-6-empty ((t (:foreground ,base04 :inherit outline-2)))) |
|
| 120 | + | ;; base16 only themes the normal 8; bright ones (used by ghostel etc.) |
|
| 121 | + | ;; fall back to Emacs defaults. Match the darkmatter ghostty palette. |
|
| 122 | + | `(ansi-color-bright-black ((t (:foreground ,base03 :background ,base03)))) |
|
| 123 | + | `(ansi-color-bright-red ((t (:foreground ,base08 :background ,base08)))) |
|
| 124 | + | `(ansi-color-bright-green ((t (:foreground ,base0B :background ,base0B)))) |
|
| 125 | + | `(ansi-color-bright-yellow ((t (:foreground ,base0A :background ,base0A)))) |
|
| 126 | + | `(ansi-color-bright-blue ((t (:foreground ,base0D :background ,base0D)))) |
|
| 127 | + | `(ansi-color-bright-magenta ((t (:foreground ,base0E :background ,base0E)))) |
|
| 128 | + | `(ansi-color-bright-cyan ((t (:foreground ,base0C :background ,base0C)))) |
|
| 129 | + | `(ansi-color-bright-white ((t (:foreground ,base07 :background ,base07)))) |
|
| 130 | + | ||
| 118 | 131 | ;; Packages base16 has no faces for |
|
| 119 | 132 | `(elfeed-search-date-face ((t (:foreground ,const)))) |
|
| 120 | 133 | `(elfeed-search-feed-face ((t (:foreground ,func)))) |