Dirvish, easy-escape, and devdocs

This commit is contained in:
2024-12-24 03:50:06 -08:00
parent 96b64a144e
commit b307a21e11
2 changed files with 285 additions and 1 deletions

119
init.el
View File

@ -713,6 +713,12 @@ visual states."
:bind (("C-c q" . vr/replace)
("C-M-%" . vr/query-replace)))
;; better `align-regexp'
(use-package ialign
:defer t
:custom
(ialign-initial-repeat t))
;; ace-window
(use-package ace-window
:diminish ace-window-mode
@ -1340,6 +1346,13 @@ With PROJECT, give diagnostics for all buffers in the current project."
(if my/project-run-dir
(expand-file-name my/project-run-dir)
default-directory)))
(defvar my/compile-use-comint t
"Weather or not to use comint by default for compile buffers.")
(defun my/-compile-use-comint-by-default (args)
(if my/compile-use-comint
(list (car args) t)
args))
(advice-add 'compile :filter-args 'my/-compile-use-comint-by-default)
(defun my/project-run (command comint)
"Like `project-compile', but for running a project.
COMMAND and COMINT are like `compile'."
@ -1370,6 +1383,13 @@ COMMAND and COMINT are like `compile'."
(list 'vc nil root)))
(add-hook 'project-find-functions #'my/project-try-dotfile))
;; comint
(use-package comint
:ensure nil
:after evil
:config
(evil-set-initial-state 'comint-mode 'normal))
;; nxml
(use-package nxml-mode
:ensure nil
@ -1385,6 +1405,10 @@ COMMAND and COMINT are like `compile'."
(regexp-opt '("gschema" "gresource" "ui")) "\\'")
. nxml-mode)))
;; devdocs
(use-package devdocs
:bind (("C-h D" . devdocs-lookup)))
;; Bibtex (built in)
(require 'bibtex)
;; Better URL highlighting and matching
@ -2053,6 +2077,86 @@ functions (only eshell uses it at the time of writing)."
"u" #'dired-unmark
"U" #'dired-unmark-all-marks))
;; dirvish
(use-package dirvish
:defer nil
:hook ((dirvish-directory-view-mode dired-mode dirvish-mode) .
my/-setup-darvish-lines)
:custom
(dired-listing-switches
"-l --almost-all --human-readable --group-directories-first --no-group")
(dirvish-subtree-always-show-state t)
(dirvish-reuse-session nil)
(dired-hide-details-hide-symlink-targets nil)
:init
(defun my/-setup-darvish-lines ()
(let ((inhibit-message t))
(setq-local truncate-lines t)))
:config
(require 'dirvish-extras)
(defvar-local my/-dirvish-uid-name-cache nil
"Cons of path and a hash table mapping user ids to their names.")
(dirvish-define-attribute file-owner-mode
"The file's owner and mode."
:index 2
:when (and (dirvish-prop :root) dired-hide-details-mode
(> win-width 60))
(let ((root (dirvish-prop :root))
(uid (file-attribute-user-id f-attrs)))
(unless (or (dirvish-prop :remote) (stringp uid))
(unless (and (equal root (car my/-dirvish-uid-name-cache))
(hash-table-p (cdr my/-dirvish-uid-name-cache)))
(setq my/-dirvish-uid-name-cache
(cons root (make-hash-table :test 'equal))))
(if-let ((name (gethash uid (cdr my/-dirvish-uid-name-cache))))
(setq uid name)
(let* ((new-attrs (file-attributes f-name 'string))
(new-name (file-attribute-user-id new-attrs)))
(puthash uid new-name
(cdr my/-dirvish-uid-name-cache))
(setq uid new-name))))
(cons 'right (propertize (format "%s %s" uid (file-attribute-modes f-attrs))
'face (or hl-face 'dirvish-file-time)))))
(let ((cur-val dirvish-ui-setup-items))
(cl-pushnew '("o" file-owner-mode "File owner and mode")
cur-val :test 'equal)
(setopt dirvish-ui-setup-items cur-val))
(add-to-list 'dirvish-libraries '(dirvish file-owner-mode))
(setopt dirvish-attributes
'(vc-state subtree-state nerd-icons file-size file-owner-mode))
(evil-define-key 'normal dirvish-mode-map
(kbd "q") #'dirvish-quit
(kbd "a") #'dirvish-quick-access
(kbd "f") #'dirvish-file-info-menu
(kbd "y") #'dirvish-yank-menu
(kbd "N") #'dirvish-narrow
(kbd "^") #'dirvish-history-last
(kbd "h") #'dirvish-history-jump
(kbd "s") #'dirvish-quicksort
(kbd "o") #'dirvish-quicksort
(kbd "v") #'dirvish-vc-menu
(kbd "TAB") #'dirvish-subtree-toggle
(kbd "M-f") #'dirvish-history-go-forward
(kbd "M-b") #'dirvish-history-go-backward
(kbd "M-l") #'dirvish-history-go-forward
(kbd "M-h") #'dirvish-history-go-backward
(kbd "M-l") #'dirvish-ls-switches-menu
(kbd "M-m") #'dirvish-mark-menu
(kbd "M-t") #'dirvish-layout-toggle
(kbd "M-s") #'dirvish-setup-menu
(kbd "M-e") #'dirvish-emerge-menu
(kbd "M-j") #'dirvish-fd-jump
(kbd "/") #'dirvish-fd
(kbd "?") #'dirvish-dispatch)
(dirvish-override-dired-mode)
(dirvish-define-preview eza (file)
"Use `eza' to generate directory preview."
:require ("eza")
(when (file-directory-p file)
`(shell . ("eza" "-la" "--color=always" "--icons"
"--group-directories-first" ,file))))
(add-to-list 'dirvish-preview-dispatchers 'eza))
;; ibuffer
(use-package ibuffer
:bind ("C-x C-b" . ibuffer))
@ -2438,6 +2542,15 @@ one of the normal rainbow-delimiters-depth-N-face faces."
(setopt rainbow-delimiters-pick-face-function
'my/rainbow-delimiters-parinfer-pick-face))
;; make regexp look nicer
(use-package easy-escape
:hook ((emacs-lisp-mode reb-mode) . easy-escape-minor-mode)
:config
(face-spec-set 'easy-escape-face
'((t (:foreground unspecified
:weight bold
:inherit 'font-lock-regexp-grouping-backslash)))))
;; auto-highlight-symbol
(use-package auto-highlight-symbol
:hook (lisp-data-mode . auto-highlight-symbol-mode)
@ -2476,7 +2589,11 @@ one of the normal rainbow-delimiters-depth-N-face faces."
:config
(nerd-icons-completion-mode))
(use-package nerd-icons-dired
:hook (dired-mode . nerd-icons-dired-mode))
:hook (dired-mode . my/-maybe-enable-nerd-icons-dired)
:init
(defun my/-maybe-enable-nerd-icons-dired ()
(unless (bound-and-true-p dirvish--this)
(nerd-icons-dired-mode))))
(use-package kind-icon
:after corfu
:init