From 2dcbc828892c34e2753beb794d1483c0eccf3419 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Tue, 25 Aug 2026 01:16:44 -0700 Subject: [PATCH] Changes --- elisp/zsh-ts-mode.el | 46 ++++----- init.el | 231 +++++++++++++++++++++++-------------------- 2 files changed, 146 insertions(+), 131 deletions(-) diff --git a/elisp/zsh-ts-mode.el b/elisp/zsh-ts-mode.el index 21b86c0..4065638 100644 --- a/elisp/zsh-ts-mode.el +++ b/elisp/zsh-ts-mode.el @@ -143,24 +143,24 @@ command.") ;; reserved words (command_name ((word) @font-lock-keyword-face - (:match ,(rx-to-string - `(seq bos - (or ,@(zsh-ts-mode--other-keywords)) - eos)) - @font-lock-keyword-face)))) + (:match? ,(rx-to-string + `(seq bos + (or ,@(zsh-ts-mode--other-keywords)) + eos)) + @font-lock-keyword-face)))) :feature 'command :language 'zsh `(;; builtin commands (command_name ((word) @font-lock-builtin-face - (:match ,(let ((builtins - (sh-feature sh-builtins))) - (rx-to-string - `(seq bos - (or ,@builtins) - eos))) - @font-lock-builtin-face))) + (:match? ,(let ((builtins + (sh-feature sh-builtins))) + (rx-to-string + `(seq bos + (or ,@builtins) + eos))) + @font-lock-builtin-face))) ;; function/non-builtin command calls (command_name (word) @font-lock-function-name-face)) @@ -182,8 +182,8 @@ command.") :override 'prepend `((declaration_command argument: ((_) @font-lock-variable-name-face - (:match ,(rx-to-string '(seq bos (not "-"))) - @font-lock-variable-name-face)))) + (:match? ,(rx-to-string '(seq bos (not "-"))) + @font-lock-variable-name-face)))) ;; let variable declarations (handled differently by the parser) @@ -192,10 +192,10 @@ command.") :override 'prepend `((command (command_name ((word) @ignore - (:equal "let" @ignore))) + (:eq? "let" @ignore))) argument: ((_) @zsh-ts-mode--fontify-let-arg - (:match ,(rx-to-string '(seq bos (not "-"))) - @zsh-ts-mode--fontify-let-arg)))) + (:match? ,(rx-to-string '(seq bos (not "-"))) + @zsh-ts-mode--fontify-let-arg)))) :feature 'for-variable :language 'zsh @@ -213,7 +213,7 @@ command.") :feature 'number :language 'zsh `(((word) @font-lock-number-face - (:match "\\`[0-9]+\\'" @font-lock-number-face)) + (:match? "\\`[0-9]+\\'" @font-lock-number-face)) ((number) @font-lock-number-face)) :feature 'bracket @@ -287,7 +287,7 @@ Return non-nil if NODE is not an anonymous function." @var)) ((variable_name) @var) ((word) @func - (:pred zsh-ts-mode--not-let-predicate @func)))) + (:pred? zsh-ts-mode--not-let-predicate @func)))) "Query for `zsh-ts-mode' `xref-backend-identifier-at-point'.") (cl-defun zsh-ts-mode--extract-variable-from-face-at (&optional (pos (point))) @@ -381,10 +381,10 @@ Return non-nil if NODE is not an anonymous function." (binary_expression left: (variable_name) @non-let operator: "=") (command name: ((command_name) @let.name - (:equal @let.name "let")) + (:eq? @let.name "let")) argument: ((word) @let-arg - (:match ,(rx-to-string '(seq bos (not "-"))) - @let-arg))))) + (:match? ,(rx-to-string '(seq bos (not "-"))) + @let-arg))))) "Variable query for `zsh-ts-mode--xref-variable-definitions'.") (defun zsh-ts-mode--xref-variable-definitions (identifier) @@ -490,7 +490,7 @@ Return non-nil if NODE is not an anonymous function." 'zsh '(((simple_variable_name) @ident) ((special_variable_name) @ident) ((variable_name) @ident) - (command name: (command_name ((word) @cname (:equal @cname "let"))) + (command name: (command_name ((word) @cname (:eq? @cname "let"))) argument: (word) @ident) (declaration_command argument: (word) @ident) (command name: (command_name (word) @ident)) diff --git a/init.el b/init.el index edfa386..907d25a 100644 --- a/init.el +++ b/init.el @@ -58,12 +58,6 @@ ;; Load the local system's configuration (load (expand-file-name "local-init" user-emacs-directory) t t) -;; diminish -(use-package diminish - :config - (diminish 'visual-line-mode) - (diminish 'abbrev-mode)) - ;; Private config loading (require 'private nil t) (defun my/get-private (key) @@ -175,7 +169,18 @@ Apply OLDFUN with to ARGS." kill-do-not-save-duplicates t) ;; Terminal mouse support -(xterm-mouse-mode 1) +(xterm-mouse-mode 1) ;; Emacs 31.1 enables this by default +(defvar xterm-update-cursor) +(setq xterm-update-cursor t) + +;; Extend the region with the mouse +(mouse-shift-adjust-mode 1) + +;; TTY child frames +(tty-tip-mode 1) + +;; Don't break multiple tty frames +(setq multiple-terminals-merge-keyboards t) ;; Make cursor more visible (global-hl-line-mode 1) @@ -187,9 +192,13 @@ Apply OLDFUN with to ARGS." ;; Make window balancing better (setq window-combination-resize t) +;; Because I use tiling window managers +(setq frame-inhibit-implied-resize 'force) + ;; Stop some annoying stuff (setq extended-command-suggest-shorter nil - suggest-key-bindings nil) + suggest-key-bindings nil + quit-window-kill-buffer t) ;; Better scrolling (setq mouse-scroll-delay 0 @@ -197,10 +206,27 @@ Apply OLDFUN with to ARGS." scroll-margin 2 scroll-preserve-screen-position t) -;; Make show paren instant -(setq show-paren-delay 0) +;; Register stuff +(setopt register-use-preview t) + +;; Show paren options +(setq show-paren-delay 0 + show-paren-not-in-comments-or-strings 'on-mismatch) (show-paren-mode 1) +;; Form feed characters +(face-spec-set 'whitespace-page-delimiter + '((((supports :strike-through t)) + :strike-through t :extend t :inherit shadow) + (t :extend t :inherit shadow :inverse-video t))) +(define-globalized-minor-mode my/global-whitespace-page-delimiters-mode + whitespace-page-delimiters-mode + whitespace-page-delimiters-mode + :group 'whitespace) +(my/global-whitespace-page-delimiters-mode 1) + + + ;; Display line numbers (global-display-line-numbers-mode 1) @@ -277,17 +303,8 @@ Apply OLDFUN with to ARGS." ;; Minibuffer stuff (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) -(defun my/-crm-indicator (args) - "Filter args for `completing-read-multiple' to add an indicator. -ARGS are the args to filter." - (cons (format "[CRM%s] %s" - (replace-regexp-in-string - "\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" "" - crm-separator) - (car args)) - (cdr args))) -(advice-add #'completing-read-multiple :filter-args #'my/-crm-indicator) -(setopt enable-recursive-minibuffers t +(setopt crm-prompt "[CRM%s] %p" + enable-recursive-minibuffers t read-extended-command-predicate nil) (unless (plist-get minibuffer-prompt-properties 'cursor-intangible) (setopt minibuffer-prompt-properties @@ -296,46 +313,32 @@ ARGS are the args to filter." ;; Tree sitter download locations (with-eval-after-load 'treesit (defvar treesit-language-source-alist) - (setq treesit-language-source-alist - '((c "https://github.com/tree-sitter/tree-sitter-c") - (cpp "https://github.com/tree-sitter/tree-sitter-cpp") - (java "https://github.com/tree-sitter/tree-sitter-java") - ;; (glsl "https://github.com/tree-sitter-grammars/tree-sitter-glsl") - (python "https://github.com/tree-sitter/tree-sitter-python") - (rust "https://github.com/tree-sitter/tree-sitter-rust") - (json "https://github.com/tree-sitter/tree-sitter-json") - (yaml "https://github.com/ikatyang/tree-sitter-yaml") - (css "https://github.com/tree-sitter/tree-sitter-css") - (go "https://github.com/tree-sitter/tree-sitter-go") - (gomod "https://github.com/camdencheek/tree-sitter-go-mod") - (javascript "https://github.com/tree-sitter/tree-sitter-javascript") - (typescript "https://github.com/tree-sitter/tree-sitter-typescript" - nil "typescript/src") - (tsx "https://github.com/tree-sitter/tree-sitter-typescript" - nil "tsx/src") - (bash "https://github.com/tree-sitter/tree-sitter-bash") - (cmake "https://github.com/uyha/tree-sitter-cmake") - (blueprint "https://github.com/huanie/tree-sitter-blueprint") - (kdl "https://github.com/tree-sitter-grammars/tree-sitter-kdl") - (php "https://github.com/tree-sitter/tree-sitter-php") - (haskell "https://github.com/tree-sitter/tree-sitter-haskell") - (zsh "https://github.com/georgeharker/tree-sitter-zsh.git"))) + (dolist (ent '((c "https://github.com/tree-sitter/tree-sitter-c") + (cpp "https://github.com/tree-sitter/tree-sitter-cpp") + (java "https://github.com/tree-sitter/tree-sitter-java") + ;; (glsl "https://github.com/tree-sitter-grammars/tree-sitter-glsl") + (python "https://github.com/tree-sitter/tree-sitter-python") + (rust "https://github.com/tree-sitter/tree-sitter-rust") + (json "https://github.com/tree-sitter/tree-sitter-json") + (yaml "https://github.com/ikatyang/tree-sitter-yaml") + (css "https://github.com/tree-sitter/tree-sitter-css") + (go "https://github.com/tree-sitter/tree-sitter-go") + (gomod "https://github.com/camdencheek/tree-sitter-go-mod") + (javascript "https://github.com/tree-sitter/tree-sitter-javascript") + (typescript "https://github.com/tree-sitter/tree-sitter-typescript" + nil "typescript/src") + (tsx "https://github.com/tree-sitter/tree-sitter-typescript" + nil "tsx/src") + (bash "https://github.com/tree-sitter/tree-sitter-bash") + (cmake "https://github.com/uyha/tree-sitter-cmake") + (blueprint "https://github.com/huanie/tree-sitter-blueprint") + (kdl "https://github.com/tree-sitter-grammars/tree-sitter-kdl") + (haskell "https://github.com/tree-sitter/tree-sitter-haskell") + (zsh "https://github.com/georgeharker/tree-sitter-zsh.git"))) + (add-to-list 'treesit-language-source-alist ent)) ;; Tree sitter major mode conversions - (dolist (ent '((c-mode . c-ts-mode) - (c++-mode . c++-ts-mode) - (c-or-c++-mode . c-or-c++-ts-mode) - (python-mode . python-ts-mode) - (java-mode . java-ts-mode) - (rust-mode . rust-ts-mode) - (json-mode . json-ts-mode) - (jsonc-mode . json-ts-mode) - (yaml-mode . yaml-ts-mode) - (css-mode . css-ts-mode) - (javascript-mode . js-ts-mode) - (cmake-mode . cmake-ts-mode) - ;; (go-mode . go-ts-mode) <- doesn't work very well - )) - (add-to-list 'major-mode-remap-alist ent))) + (setopt treesit-enabled-modes t + treesit-auto-install-grammar 'ask)) (defun my/treesit-compile-all (force) "Compile all the modules defined in `treesit-language-source-alist'. If FORCE, recompile all modules, even ones that are already compiled. @@ -352,11 +355,6 @@ Interactively, force the recompile if called with a prefix." (unless did-build (message "All defined parsers installed!")))) -(use-package auth-source - :ensure nil - :custom - (auth-sources '("~/.authinfo.gpg"))) - (setopt remote-file-name-access-timeout 10) (use-package tramp :ensure nil @@ -514,8 +512,11 @@ PRED is nil, the value of `my/kill-some-buffers-default-pred' is used." (keymap-global-set "C-x K" 'my/kill-some-buffers) (use-package tab-bar + :defer nil :ensure nil - :init + :bind (("C-x t s" . split-tab) + ("C-x t e" . merge-tabs)) + :custom (setq tab-bar-show 1 tab-bar-tab-hints t icon-preference '(symbol text image emoji)) @@ -757,7 +758,6 @@ With NO-UPDATE-BAR, don't update any status bar's state." (use-package evil-collection :after evil :defer nil - :diminish evil-collection-unimpaired-mode :config (setf (plist-get (alist-get 'repl-submit evil-collection-binding-defaults) :state) @@ -777,11 +777,6 @@ With NO-UPDATE-BAR, don't update any status bar's state." "gz" #'evil-surround-region "gZ" #'evil-Surround-region) (global-evil-surround-mode 1)) -(use-package evil-terminal-cursor-changer - :after evil - :defer nil - :config - (evil-terminal-cursor-changer-activate)) (use-package evil-numbers :after evil :bind (("C-c =" . evil-numbers/inc-at-pt) @@ -789,11 +784,7 @@ With NO-UPDATE-BAR, don't update any status bar's state." ("C-c -" . evil-numbers/dec-at-pt) ("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)) - :config - ;; TODO remove this when emacs 31 releases - (when (< emacs-major-version 31) - (defalias 'incf 'cl-incf))) + ("C-c C--" . evil-numbers/dec-at-pt-incremental))) (use-package evil-cleverparens :hook ((prog-mode . my/-enable-evil-cleverparens) (evil-cleverparens-mode . paredit-mode)) @@ -1007,7 +998,6 @@ environment variable accordingly." ;; which-key (use-package which-key - :diminish which-key-mode :config (which-key-mode 1)) @@ -1066,7 +1056,6 @@ environment variable accordingly." ;; ace-window (use-package ace-window - :diminish ace-window-mode :bind ("M-o" . ace-window) :init (setq aw-scope 'frame @@ -1245,12 +1234,7 @@ environment variable accordingly." (corfu-on-exact-match nil) (corfu-popupinfo-delay '(1.0 . 0.5)) (completion-cycle-threshold nil) - (global-corfu-minibuffer - ;; only enable corfu in the minibuffer in graphical frames - (lambda () - (and (display-graphic-p) - (not (eq (current-local-map) - read-passwd-map))))) + (global-corfu-minibuffer t) :config (defvar corfu--extra) (defun my/corfu-move-to-minibuffer () @@ -1549,7 +1533,6 @@ With PROJECT, give diagnostics for all buffers in the current project." ;; eldoc (use-package eldoc - :diminish eldoc-mode :custom (eldoc-echo-area-use-multiline-p nil)) @@ -1657,8 +1640,6 @@ With PROJECT, give diagnostics for all buffers in the current project." (apheleia-formatters-respect-fill-column t) :init (add-to-list 'auto-mode-alist `(,(rx "/.clang-format" eos) . yaml-ts-mode)) - (defun my/apheleia-disable-in-current-buffer () - (setq-local apheleia-inhibit t)) :config (apheleia-global-mode 1) (add-to-list 'apheleia-formatters @@ -1666,6 +1647,8 @@ With PROJECT, give diagnostics for all buffers in the current project." (apheleia-formatters-fill-column "--width"))) (add-to-list 'apheleia-mode-alist '(racket-mode . lisp-indent)) + (add-to-list 'apheleia-mode-alist + '(mhtml-ts-mode . prettier-html)) (setf (alist-get 'java-mode apheleia-mode-alist) 'clang-format (alist-get 'java-ts-mode apheleia-mode-alist) 'clang-format)) @@ -1771,7 +1754,9 @@ With PROJECT, give diagnostics for all buffers in the current project." ;; code folding (use-package hideshow - :hook (prog-mode . hs-minor-mode)) + :hook (prog-mode . hs-minor-mode) + :custom + (hs-display-lines-hidden t)) ;; preserve folds (use-package hs-preserve-mode :ensure nil @@ -2100,6 +2085,8 @@ MAPS are expected to be keymaps for modes for languages with C-style comments." (use-package java-ts-mode :hook ((java-ts-mode . my/eglot-if-trusted) (java-ts-mode . my/-setup-java-ts-mode)) + :custom + (java-ts-mode-enable-doxygen t) :config (my/setup-c-style-newline-keys java-ts-mode-map) (defun my/-setup-java-ts-mode () @@ -2139,6 +2126,8 @@ EVENT is the same as the original command." (use-package c-ts-mode :after evil :hook ((c-ts-mode c++-ts-mode) . my/eglot-if-trusted) + :custom + (c-ts-mode-enable-doxygen t) :init (setq-default c-ts-mode-indent-offset 4) :config @@ -2174,20 +2163,29 @@ This is :around advice, so OLDFUN is the real function (use-package php-ts-mode :defer t :ensure nil - :hook (php-mode . my/eglot-if-trusted)) + :hook (php-mode . my/eglot-if-trusted) + :custom + (php-ts-mode-phpdoc-highlight-errors t)) -;; web-mode -(use-package web-mode +(use-package sgml-mode :defer t - :hook (web-mode . my/eglot-if-trusted) + :config + (define-key html-mode-map (kbd "M-o") nil t) + (define-key html-mode-map (kbd "C-c C-m") 'facemenu-keymap)) + +(use-package mhtml-ts-mode + :defer t + :hook (mhtml-ts-mode . my/eglot-if-trusted) :config (add-to-list 'eglot-server-programs - '(web-mode . ("vscode-html-language-server" "--stdio")))) + '(mhtml-ts-mode . ("vscode-html-language-server" "--stdio")))) ;; JavaScript (use-package js :ensure nil - :hook (js-ts-mode . my/eglot-if-trusted)) + :hook (js-ts-mode . my/eglot-if-trusted) + :config + (my/setup-c-style-newline-keys js-ts-mode-map)) ;; TypeScript (use-package typescript-ts-mode @@ -2239,8 +2237,11 @@ This is :around advice, so OLDFUN is the real function :hook (zig-mode . my/eglot-if-trusted)) ;; lua -(use-package lua-mode - :hook (lua-mode . my/eglot-if-trusted)) +(use-package lua-ts-mode + :ensure nil + :hook (lua-ts-mode . my/eglot-if-trusted) + :custom + (lua-ts-auto-close-block-comments t)) ;; markdown (use-package markdown-mode @@ -2296,7 +2297,8 @@ This is :around advice, so OLDFUN is the real function ;; yaml (use-package yaml-ts-mode :hook (;; (yaml-ts-mode . my/eglot-if-trusted) - (yaml-ts-mode . my/-setup-yaml-ts-mode)) + (yaml-ts-mode . my/-setup-yaml-ts-mode) + (yaml-ts-mode . my/flycheck-if-trusted)) :init (add-to-list 'auto-mode-alist `("\\.clangd\\'" . yaml-ts-mode)) (defun my/-setup-yaml-ts-mode () @@ -3211,6 +3213,13 @@ ARG is the same as for either of the above functions." "u" #'dired-unmark "U" #'dired-unmark-all-marks)) +(use-package image-dired + :ensure nil + :hook (image-dired-thumbnail-mode . my/-setup-image-dired-thumbnail-mode) + :init + (defun my/-setup-image-dired-thumbnail-mode () + (display-line-numbers-mode -1))) + ;; dirvish (use-package dirvish :demand t @@ -3330,13 +3339,26 @@ ARG is the same as for either of the above functions." "--group-directories-first" ,file)))) (add-to-list 'dirvish-preview-dispatchers 'eza)) +;; web stuff +(when-let* ((exec (cl-find-if #'executable-find + '("mullvad-browser" "firefox")))) + (setopt browse-url-firefox-program exec)) + ;; trashed (use-package trashed :bind ("C-c h" . trashed)) ;; ibuffer (use-package ibuffer - :bind ("C-x C-b" . ibuffer)) + :bind ("C-x C-b" . ibuffer) + :custom + (ibuffer-human-readable-size t) + :config + (define-key ibuffer-mode-map (kbd "M-o") nil t) + (keymap-set ibuffer-mode-map "M-O" #'ibuffer-visit-buffer-1-window)) + +;; Buffer menu +(setopt Buffer-menu-human-readable-sizes t) ;; magit (use-package magit @@ -3659,7 +3681,8 @@ BUFFER is the buffer-or-string to match against." (setq-local evil-lookup-func #'helpful-at-point)) (defun my/-setup-helpful-mode () (setq-local evil-lookup-func #'helpful-at-point - tab-width 8)) + tab-width 8 + quit-window-kill-buffer nil)) :custom (helpful-switch-buffer-function 'my/-helpful-switch-buffer-function) (helpful-max-buffers 2) @@ -4148,14 +4171,6 @@ vising, and their major mode" (dictionary-read-word-function . #'dictionary-completing-read-word) (dictionary-read-dictionary-function . #'dictionary-completing-read-dictionary)) -;; prettify ^L characters -(use-package form-feed - :custom-face - (form-feed-line ((((type graphic)) :strike-through "#555556") - (((type tty)) :inherit font-lock-comment-face :underline t))) - :config - (global-form-feed-mode 1)) - ;; fun! (use-package mines :config