Dirvish, easy-escape, and devdocs
This commit is contained in:
parent
96b64a144e
commit
b307a21e11
167
disabled.el
167
disabled.el
@ -179,3 +179,170 @@
|
|||||||
;; (add-to-list 'aggressive-indent-protected-commands
|
;; (add-to-list 'aggressive-indent-protected-commands
|
||||||
;; #'evil-undo))
|
;; #'evil-undo))
|
||||||
|
|
||||||
|
;; ;; easier identification of local variables
|
||||||
|
;; (use-package color-identifiers-mode
|
||||||
|
;; :hook (prog-mode . color-identifiers-mode-maybe)
|
||||||
|
;; :init
|
||||||
|
;; (setq color-identifiers:num-colors 10
|
||||||
|
;; color-identifiers:recoloring-delay 0.5)
|
||||||
|
;; :config
|
||||||
|
;; ;; make sure that remapped treesitter modes are handled
|
||||||
|
;; (defun my/color-identifiers-mode-remap-ts-modes ()
|
||||||
|
;; (dolist (entry color-identifiers:modes-alist)
|
||||||
|
;; (cl-destructuring-bind (mode &rest props) entry
|
||||||
|
;; (when-let ((remapped-mode (alist-get mode major-mode-remap-alist))
|
||||||
|
;; ((string-match-p "-ts-" (symbol-name remapped-mode)))
|
||||||
|
;; ((not (assq remapped-mode color-identifiers:modes-alist))))
|
||||||
|
;; ;; no need to test with `add-to-list'
|
||||||
|
;; (push (cons remapped-mode props) color-identifiers:modes-alist)))))
|
||||||
|
;; (my/color-identifiers-mode-remap-ts-modes)
|
||||||
|
;; (setf (alist-get 'lisp-interaction-mode color-identifiers:modes-alist)
|
||||||
|
;; (alist-get 'emacs-lisp-mode color-identifiers:modes-alist))
|
||||||
|
;; (defun my/-color-identifiers-elisp-handle-let-like (sexp output)
|
||||||
|
;; (cl-destructuring-bind (_name &optional vars &rest body) sexp
|
||||||
|
;; (dolist (entry vars body)
|
||||||
|
;; (cond
|
||||||
|
;; ((and entry (symbolp entry)) (puthash entry t output))
|
||||||
|
;; ((and (car entry) (symbolp (car entry)))
|
||||||
|
;; (puthash (car entry) t output))))))
|
||||||
|
;; (defun my/-color-identifiers-parse-lambda-list (list output)
|
||||||
|
;; (dolist (entry list)
|
||||||
|
;; (cond
|
||||||
|
;; ((and entry (symbolp entry)
|
||||||
|
;; (not (string-prefix-p ":" (symbol-name entry)))
|
||||||
|
;; (not (string-prefix-p "&" (symbol-name entry))))
|
||||||
|
;; (puthash entry t output))
|
||||||
|
;; ((and (car-safe entry) (symbolp (car entry)))
|
||||||
|
;; (puthash (car entry) t output)))))
|
||||||
|
;; (defun my/-color-identifiers-elisp-handle-destructing-bind-like
|
||||||
|
;; (sexp output)
|
||||||
|
;; (cl-destructuring-bind (_name &optional vars &rest expr-and-body) sexp
|
||||||
|
;; (my/-color-identifiers-parse-lambda-list vars output)
|
||||||
|
;; expr-and-body))
|
||||||
|
;; (defun my/-color-identifiers-elisp-handle-defun-like
|
||||||
|
;; (sexp output)
|
||||||
|
;; (cl-destructuring-bind (_name _func &optional vars &rest body) sexp
|
||||||
|
;; (my/-color-identifiers-parse-lambda-list vars output)
|
||||||
|
;; body))
|
||||||
|
;; (defun my/-color-identifiers-elisp-handle-dolist-like
|
||||||
|
;; (sexp output)
|
||||||
|
;; (cl-destructuring-bind (_name &optional spec &rest body) sexp
|
||||||
|
;; (cl-destructuring-bind (&optional var &rest forms) spec
|
||||||
|
;; (when (symbolp var)
|
||||||
|
;; (puthash var t output))
|
||||||
|
;; (append body forms))))
|
||||||
|
;; (defun my/-color-identifiers-elisp-handle-loop (sexp output)
|
||||||
|
;; (let (body-forms)
|
||||||
|
;; (cl-maplist
|
||||||
|
;; (lambda (kwds)
|
||||||
|
;; (cl-case (car kwds)
|
||||||
|
;; (for ;; this could be a dotted list
|
||||||
|
;; (let ((tail (ensure-list (cadr kwds))))
|
||||||
|
;; (while tail
|
||||||
|
;; (when (and (consp tail) (symbolp (car tail)))
|
||||||
|
;; (puthash (car tail) t output))
|
||||||
|
;; (when (and (consp tail) (symbolp (cdr tail)))
|
||||||
|
;; (puthash (cdr tail) t output))
|
||||||
|
;; (setq tail (cdr-safe tail)))))
|
||||||
|
;; (using
|
||||||
|
;; (when (and (listp (cdr kwds))
|
||||||
|
;; (symbolp (cl-second (cdr kwds))))
|
||||||
|
;; (puthash (cl-second (cdr kwds)) t output)))
|
||||||
|
;; ((with into)
|
||||||
|
;; (when (symbolp (cadr kwds))
|
||||||
|
;; (puthash (cadr kwds) t output)))
|
||||||
|
;; (t
|
||||||
|
;; (unless (atom (car kwds))
|
||||||
|
;; (push (car kwds) body-forms)))))
|
||||||
|
;; (cdr sexp))
|
||||||
|
;; body-forms))
|
||||||
|
;; (defun my/-color-identifiers-elisp-handle-do-like (sexp output)
|
||||||
|
;; (let ((eval-forms))
|
||||||
|
;; (cl-destructuring-bind (name &optional vars test-forms &rest body) sexp
|
||||||
|
;; (dolist (entry vars (append eval-forms test-forms body))
|
||||||
|
;; (cl-destructuring-bind (&optional var init step &rest _)
|
||||||
|
;; entry
|
||||||
|
;; (when (symbolp var)
|
||||||
|
;; (puthash var t output)
|
||||||
|
;; (cl-callf nconc eval-forms (list init step))))))))
|
||||||
|
;; (defvar my/-color-identifiers-eslip-handlers
|
||||||
|
;; (let ((table (make-hash-table)))
|
||||||
|
;; (puthash 'quote #'ignore table)
|
||||||
|
;; (puthash 'function #'ignore table)
|
||||||
|
;; (puthash 'let #'my/-color-identifiers-elisp-handle-let-like table)
|
||||||
|
;; (puthash 'let* #'my/-color-identifiers-elisp-handle-let-like table)
|
||||||
|
;; (puthash 'cl-destructuring-bind
|
||||||
|
;; #'my/-color-identifiers-elisp-handle-destructing-bind-like table)
|
||||||
|
;; (puthash 'with-slots
|
||||||
|
;; #'my/-color-identifiers-elisp-handle-destructing-bind-like table)
|
||||||
|
;; (puthash 'lambda
|
||||||
|
;; #'my/-color-identifiers-elisp-handle-destructing-bind-like table)
|
||||||
|
;; (puthash 'cl-function
|
||||||
|
;; #'my/-color-identifiers-elisp-handle-destructing-bind-like table)
|
||||||
|
;; (puthash 'defun
|
||||||
|
;; #'my/-color-identifiers-elisp-handle-defun-like table)
|
||||||
|
;; (puthash 'cl-defun
|
||||||
|
;; #'my/-color-identifiers-elisp-handle-defun-like table)
|
||||||
|
;; (puthash 'defmacro
|
||||||
|
;; #'my/-color-identifiers-elisp-handle-defun-like table)
|
||||||
|
;; (puthash 'cl-defmacro
|
||||||
|
;; #'my/-color-identifiers-elisp-handle-defun-like table)
|
||||||
|
;; (puthash 'cl-defmacro
|
||||||
|
;; #'my/-color-identifiers-elisp-handle-defun-like table)
|
||||||
|
;; (puthash 'cl-loop
|
||||||
|
;; #'my/-color-identifiers-elisp-handle-loop table)
|
||||||
|
;; (puthash 'dolist
|
||||||
|
;; #'my/-color-identifiers-elisp-handle-dolist-like table)
|
||||||
|
;; (puthash 'dotimes
|
||||||
|
;; #'my/-color-identifiers-elisp-handle-dolist-like table)
|
||||||
|
;; (puthash 'cl-dolist
|
||||||
|
;; #'my/-color-identifiers-elisp-handle-dolist-like table)
|
||||||
|
;; (puthash 'cl-dotimes
|
||||||
|
;; #'my/-color-identifiers-elisp-handle-dolist-like table)
|
||||||
|
;; (puthash 'cl-do
|
||||||
|
;; #'my/-color-identifiers-elisp-handle-do-like table)
|
||||||
|
;; table)
|
||||||
|
;; "A list of functions that find declarations in variables.
|
||||||
|
;; This is used in `my/-color-identifiers-elisp-declarations-in-sexp'. It is a
|
||||||
|
;; hash table of function (or macro) names and a function that handles them. The
|
||||||
|
;; functions should be of two arguments. The first is the sexp to parse. The
|
||||||
|
;; second is a hash table with the keys being the symbols of local variables. The
|
||||||
|
;; function should return a list of the forms that it contains that should be
|
||||||
|
;; recursively searched.")
|
||||||
|
;; (defun my/-color-identifiers-lisp-declarations-in-sexp (sexp output table)
|
||||||
|
;; "Get all of the variable declarations in SEXP and place them in OUTPUT.
|
||||||
|
;; OUTPUT is a hash table. TABLE is a table like
|
||||||
|
;; `my/-color-identifiers-elisp-declarations-in-sexp'."
|
||||||
|
;; (let ((stack (list sexp)))
|
||||||
|
;; (while (and stack (not (input-pending-p)))
|
||||||
|
;; (let ((entry (pop stack)))
|
||||||
|
;; (when (proper-list-p entry)
|
||||||
|
;; (if-let ((handler (gethash (car entry) table)))
|
||||||
|
;; (cl-callf nconc stack
|
||||||
|
;; (copy-sequence (funcall handler entry output)))
|
||||||
|
;; (cl-callf nconc stack
|
||||||
|
;; (copy-sequence (cdr entry)))))))))
|
||||||
|
;; (defun my/-color-identifiers-lisp-declarations-in-buffer (&optional buffer)
|
||||||
|
;; (let ((result (make-hash-table)))
|
||||||
|
;; (save-excursion
|
||||||
|
;; (goto-char (point-min))
|
||||||
|
;; (condition-case nil
|
||||||
|
;; (while t
|
||||||
|
;; (condition-case nil
|
||||||
|
;; (let ((sexp (read (or buffer (current-buffer)))))
|
||||||
|
;; (my/-color-identifiers-lisp-declarations-in-sexp
|
||||||
|
;; sexp result my/-color-identifiers-eslip-handlers))
|
||||||
|
;; (invalid-read-syntax nil)))
|
||||||
|
;; (end-of-file nil))
|
||||||
|
;; (let ((names))
|
||||||
|
;; (maphash (lambda (k _v)
|
||||||
|
;; (unless (or (eq k t) (not k) (boundp k))
|
||||||
|
;; (push (symbol-name k) names)))
|
||||||
|
;; result)
|
||||||
|
;; names))))
|
||||||
|
;; (color-identifiers:set-declaration-scan-fn
|
||||||
|
;; 'emacs-lisp-mode
|
||||||
|
;; 'my/-color-identifiers-lisp-declarations-in-buffer)
|
||||||
|
;; (color-identifiers:set-declaration-scan-fn
|
||||||
|
;; 'lisp-interaction-mode
|
||||||
|
;; 'my/-color-identifiers-lisp-declarations-in-buffer))
|
||||||
|
119
init.el
119
init.el
@ -713,6 +713,12 @@ visual states."
|
|||||||
:bind (("C-c q" . vr/replace)
|
:bind (("C-c q" . vr/replace)
|
||||||
("C-M-%" . vr/query-replace)))
|
("C-M-%" . vr/query-replace)))
|
||||||
|
|
||||||
|
;; better `align-regexp'
|
||||||
|
(use-package ialign
|
||||||
|
:defer t
|
||||||
|
:custom
|
||||||
|
(ialign-initial-repeat t))
|
||||||
|
|
||||||
;; ace-window
|
;; ace-window
|
||||||
(use-package ace-window
|
(use-package ace-window
|
||||||
:diminish ace-window-mode
|
:diminish ace-window-mode
|
||||||
@ -1340,6 +1346,13 @@ With PROJECT, give diagnostics for all buffers in the current project."
|
|||||||
(if my/project-run-dir
|
(if my/project-run-dir
|
||||||
(expand-file-name my/project-run-dir)
|
(expand-file-name my/project-run-dir)
|
||||||
default-directory)))
|
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)
|
(defun my/project-run (command comint)
|
||||||
"Like `project-compile', but for running a project.
|
"Like `project-compile', but for running a project.
|
||||||
COMMAND and COMINT are like `compile'."
|
COMMAND and COMINT are like `compile'."
|
||||||
@ -1370,6 +1383,13 @@ COMMAND and COMINT are like `compile'."
|
|||||||
(list 'vc nil root)))
|
(list 'vc nil root)))
|
||||||
(add-hook 'project-find-functions #'my/project-try-dotfile))
|
(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
|
;; nxml
|
||||||
(use-package nxml-mode
|
(use-package nxml-mode
|
||||||
:ensure nil
|
:ensure nil
|
||||||
@ -1385,6 +1405,10 @@ COMMAND and COMINT are like `compile'."
|
|||||||
(regexp-opt '("gschema" "gresource" "ui")) "\\'")
|
(regexp-opt '("gschema" "gresource" "ui")) "\\'")
|
||||||
. nxml-mode)))
|
. nxml-mode)))
|
||||||
|
|
||||||
|
;; devdocs
|
||||||
|
(use-package devdocs
|
||||||
|
:bind (("C-h D" . devdocs-lookup)))
|
||||||
|
|
||||||
;; Bibtex (built in)
|
;; Bibtex (built in)
|
||||||
(require 'bibtex)
|
(require 'bibtex)
|
||||||
;; Better URL highlighting and matching
|
;; 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
|
||||||
"U" #'dired-unmark-all-marks))
|
"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
|
;; ibuffer
|
||||||
(use-package ibuffer
|
(use-package ibuffer
|
||||||
:bind ("C-x C-b" . 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
|
(setopt rainbow-delimiters-pick-face-function
|
||||||
'my/rainbow-delimiters-parinfer-pick-face))
|
'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
|
;; auto-highlight-symbol
|
||||||
(use-package auto-highlight-symbol
|
(use-package auto-highlight-symbol
|
||||||
:hook (lisp-data-mode . auto-highlight-symbol-mode)
|
:hook (lisp-data-mode . auto-highlight-symbol-mode)
|
||||||
@ -2476,7 +2589,11 @@ one of the normal rainbow-delimiters-depth-N-face faces."
|
|||||||
:config
|
:config
|
||||||
(nerd-icons-completion-mode))
|
(nerd-icons-completion-mode))
|
||||||
(use-package nerd-icons-dired
|
(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
|
(use-package kind-icon
|
||||||
:after corfu
|
:after corfu
|
||||||
:init
|
:init
|
||||||
|
Loading…
x
Reference in New Issue
Block a user