Auto-format added to init.el
This commit is contained in:
parent
b307a21e11
commit
80a0d4aefe
134
init.el
134
init.el
@ -3,8 +3,9 @@
|
||||
;;; Code:
|
||||
|
||||
;; Some other config files
|
||||
(cl-eval-when (compile load eval)
|
||||
(add-to-list 'load-path (expand-file-name "elisp" user-emacs-directory))
|
||||
(add-to-list 'load-path (expand-file-name "third-party" user-emacs-directory))
|
||||
(add-to-list 'load-path (expand-file-name "third-party" user-emacs-directory)))
|
||||
|
||||
;; Set package dir to follow no-littering conventions
|
||||
(setq package-user-dir (expand-file-name "var/elpa"
|
||||
@ -206,6 +207,21 @@ 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")))
|
||||
|
||||
(use-package tramp
|
||||
:ensure nil
|
||||
:config
|
||||
(connection-local-set-profile-variables
|
||||
'remote-direct-async-process
|
||||
'((tramp-direct-async-process . t)))
|
||||
(connection-local-set-profiles
|
||||
'(:protocol "ssh")
|
||||
'remote-direct-async-process))
|
||||
|
||||
(use-package midnight
|
||||
:ensure nil
|
||||
:config
|
||||
@ -367,7 +383,7 @@ PRED is nil, the value of `my/kill-some-buffers-default-pred' is used."
|
||||
;; bookmarks
|
||||
(use-package bookmark
|
||||
:ensure nil
|
||||
:bind ("C-c b" . my/bookmark-find-file)
|
||||
:bind ("C-c B" . my/bookmark-find-file)
|
||||
:config
|
||||
(defun my/bookmark-find-file (&optional name)
|
||||
"Run `find-file' in or on bookmark NAME.
|
||||
@ -1198,6 +1214,17 @@ With PROJECT, give diagnostics for all buffers in the current project."
|
||||
;; LTeX (languagetool)
|
||||
(require 'ltex-eglot)
|
||||
|
||||
;; apheleia (code formatter)
|
||||
(use-package apheleia
|
||||
:defer nil
|
||||
:bind ("C-c o" . apheleia-format-buffer)
|
||||
:init
|
||||
(add-to-list 'auto-mode-alist `(,(rx "/.clang-format" eos) . yaml-ts-mode))
|
||||
:config
|
||||
(setf (alist-get 'java-mode apheleia-mode-alist) 'clang-format
|
||||
(alist-get 'java-ts-mode apheleia-mode-alist) 'clang-format)
|
||||
(apheleia-global-mode +1))
|
||||
|
||||
;; gud
|
||||
(use-package gud
|
||||
:demand t
|
||||
@ -1935,9 +1962,13 @@ argument."
|
||||
:config
|
||||
(defvar my/project-eat-hash-table (make-hash-table :test 'equal)
|
||||
"Hash table that maps project root dirs to eat buffers.")
|
||||
(defun my/project-eat (prompt)
|
||||
(defun my/-eat-shell-for-cwd ()
|
||||
"Return a good shell for CWD, or nil if the default shell should be used."
|
||||
(when (file-remote-p default-directory)
|
||||
"/bin/sh"))
|
||||
(defun my/project-eat (prompt &optional arg)
|
||||
"Switch to or create a eat buffer in the current projects root."
|
||||
(interactive (list t))
|
||||
(interactive (list t current-prefix-arg))
|
||||
(if-let ((proj (project-current prompt))
|
||||
(default-directory (project-root proj)))
|
||||
(if-let ((eat-buff (gethash default-directory
|
||||
@ -1950,11 +1981,11 @@ argument."
|
||||
"xterm-256color"
|
||||
eat-term-name)))
|
||||
(puthash default-directory
|
||||
(eat)
|
||||
(eat (my/-eat-shell-for-cwd) arg)
|
||||
my/project-eat-hash-table)))))
|
||||
(defun my/project-eat-or-default ()
|
||||
(defun my/project-eat-or-default (&optional arg)
|
||||
"Open an eat for the current project, otherwise, open a normal eat."
|
||||
(interactive)
|
||||
(interactive "P")
|
||||
(unless (my/project-eat nil)
|
||||
(if-let ((eat-buff (gethash nil my/project-eat-hash-table))
|
||||
((buffer-live-p eat-buff)))
|
||||
@ -1962,7 +1993,7 @@ argument."
|
||||
(puthash nil (let ((eat-term-name (if (file-remote-p default-directory)
|
||||
"xterm-256color"
|
||||
eat-term-name)))
|
||||
(eat))
|
||||
(eat (my/-eat-shell-for-cwd) arg))
|
||||
my/project-eat-hash-table)))))
|
||||
|
||||
;; eshell stuff
|
||||
@ -1971,14 +2002,30 @@ argument."
|
||||
:defer nil
|
||||
:hook ((eshell-load . eat-eshell-visual-command-mode)
|
||||
(eshell-load . eat-eshell-mode)
|
||||
(eshell-mode . my/-eshell-mode-setup))
|
||||
(eshell-mode . my/-eshell-mode-setup)
|
||||
(eshell-directory-change . my/-eshell-maybe-setup-remote-aliases))
|
||||
:bind (:map eshell-mode-map
|
||||
("TAB" . completion-at-point)
|
||||
("<tab>" . completion-at-point))
|
||||
:init
|
||||
(defun my/-eshell-filter-alias-list ()
|
||||
(cl-remove-if-not (lambda (elt)
|
||||
(or (string-match-p
|
||||
(rx bos
|
||||
(or "clear" "find-file"
|
||||
"ls" "la" "git"
|
||||
(and "eshell/" (+ (not " "))))
|
||||
(or " " eos))
|
||||
(cl-second elt))))
|
||||
eshell-command-aliases-list))
|
||||
(defun my/-eshell-maybe-setup-remote-aliases ()
|
||||
(if (file-remote-p default-directory)
|
||||
(setq-local eshell-command-aliases-list (my/-eshell-filter-alias-list))
|
||||
(kill-local-variable 'eshell-command-aliases-list)))
|
||||
(defun my/-eshell-mode-setup ()
|
||||
"Setup function run from `eshell-mode-hook'"
|
||||
(setq-local corfu-auto nil))
|
||||
(setq-local corfu-auto nil)
|
||||
(my/-eshell-maybe-setup-remote-aliases))
|
||||
(setq-default eshell-command-aliases-list
|
||||
'(("clear" "clear t")
|
||||
("e" "find-file $1")
|
||||
@ -2060,6 +2107,10 @@ functions (only eshell uses it at the time of writing)."
|
||||
;; dired
|
||||
(use-package dired
|
||||
:ensure nil
|
||||
:custom
|
||||
(dired-listing-switches
|
||||
"-l --almost-all --human-readable --group-directories-first --no-group")
|
||||
(dired-hide-details-hide-symlink-targets nil)
|
||||
:init
|
||||
(setq-default dired-kill-when-opening-new-dired-buffer t)
|
||||
(setq delete-by-moving-to-trash t
|
||||
@ -2080,20 +2131,61 @@ functions (only eshell uses it at the time of writing)."
|
||||
;; dirvish
|
||||
(use-package dirvish
|
||||
:defer nil
|
||||
:hook ((dirvish-directory-view-mode dired-mode dirvish-mode) .
|
||||
my/-setup-darvish-lines)
|
||||
:bind (("C-c b" . dirvish-quick-access)
|
||||
:map dirvish-mode-map
|
||||
("<mouse-1>" . dirvish-subtree-toggle-or-open)
|
||||
("<mouse-2>" . dired-mouse-find-file-other-window)
|
||||
("<mouse-3>" . dired-mouse-find-file))
|
||||
:hook (((dirvish-directory-view-mode dired-mode dirvish-mode) .
|
||||
my/-setup-dirvish-lines)
|
||||
((dirvish-directory-view-mode dired-mode dirvish-mode) .
|
||||
auto-revert-mode)
|
||||
((dirvish-mode dired-mode) . my/-setup-dirvish-mouse))
|
||||
: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)
|
||||
(dirvish-reuse-session t)
|
||||
(dirvish-quick-access-function 'dired)
|
||||
:init
|
||||
(defun my/-setup-darvish-lines ()
|
||||
(let ((inhibit-message t))
|
||||
(setq-local truncate-lines t)))
|
||||
(defun my/-setup-dirvish-lines ()
|
||||
(setq-local truncate-lines t))
|
||||
(defun my/-setup-dirvish-mouse ()
|
||||
(setq-local mouse-1-click-follows-link nil
|
||||
mouse-1-click-in-non-selected-windows nil))
|
||||
(defvar my/-dirvish-base-quick-access-entries
|
||||
`(("h" "~/" "Home")
|
||||
("d" "~/downloads/" "Downloads")
|
||||
("e" ,user-emacs-directory "Emacs user directory")
|
||||
("z" "~/.config/zsh/" "Zsh user directory")
|
||||
("o" "~/docs/" "Documents")
|
||||
("w." "~/workspace/" "Workspace")))
|
||||
(defun my/-dirvish-build-quick-access-entries (bookmarks)
|
||||
;; NOTE called from a variable watcher for `bookmark-alist' and so must
|
||||
;; never set that variable
|
||||
(let (out)
|
||||
(dolist (bme bookmarks
|
||||
(append my/-dirvish-base-quick-access-entries
|
||||
(sort out
|
||||
(lambda (elt1 elt2)
|
||||
(string< (car elt1) (car elt2))))))
|
||||
(let ((name (car bme)))
|
||||
(let-alist (cdr bme)
|
||||
(when (and (file-directory-p .filename)
|
||||
(string-match (rx bos (group (any "a-z" "A-Z")) "ws" eos)
|
||||
name))
|
||||
(setf (alist-get (concat "w" (match-string 1 name)) out
|
||||
nil nil 'equal)
|
||||
(list .filename
|
||||
(concat
|
||||
(capitalize
|
||||
(car (last (string-split .filename "/" t))))
|
||||
" Workspace")))))))))
|
||||
:config
|
||||
(require 'dirvish-extras)
|
||||
(defun my/-dirvish-bookmark-alist-watcher (_sym newval oper where)
|
||||
(when (and (not where) (memq oper '(set makunbound defvaralias)))
|
||||
(setopt dirvish-quick-access-entries
|
||||
(my/-dirvish-build-quick-access-entries newval))))
|
||||
(add-variable-watcher 'bookmark-alist #'my/-dirvish-bookmark-alist-watcher)
|
||||
(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
|
||||
@ -2167,6 +2259,10 @@ functions (only eshell uses it at the time of writing)."
|
||||
(evil-define-key '(normal visual motion) magit-mode-map
|
||||
"s" #'magit-stage-file
|
||||
"S" #'magit-stage-modified))
|
||||
(use-package forge
|
||||
:config
|
||||
(add-to-list 'forge-alist '("git.zander.im" "git.zander.im/api/v1"
|
||||
"git.zander.im" forge-gitea-repository)))
|
||||
|
||||
;; org-mode
|
||||
(use-package org
|
||||
|
Loading…
Reference in New Issue
Block a user