1
0
Fork 0
dotfiles/.config/emacs/init.el
rhjr b96ab10a90 Added: correct win32 paths
2025-11-29 09:32:59 +00:00

249 lines
8.1 KiB
EmacsLisp

;; rhjr/paths
(defconst rhjr/base-config-dir
(if (eq system-type 'windows-nt)
"C:\\Users\\Rhjr\\AppData\\Roaming\\.emacs.d\\"
"~/.config/emacs/"))
(defconst rhjr/paths/config rhjr/base-config-dir)
(defconst rhjr/paths/packages (concat rhjr/paths/config "packages/"))
(defconst rhjr/paths/thirdparty (concat rhjr/paths/config "thirdparty/"))
(defconst rhjr/paths/no-littering/etc (concat rhjr/paths/config "config/"))
(defconst rhjr/paths/no-littering/var (concat rhjr/paths/config "data/"))
(defconst rhjr/paths/eln-cache (concat rhjr/paths/config "data/eln-cache"))
(defconst rhjr/paths/home
(if (eq system-type 'windows-nt)
"C:\\Users\\Rhjr\\Home\\"
"~"))
;; rhjr/archives
(require 'package)
(setq package-user-dir rhjr/paths/packages
package-archives '(("melpa" . "https://melpa.org/packages/")
("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-and-compile
(setq use-package-always-ensure t
use-package-expand-minimally t))
(require 'use-package)
;;; rhjr/config-folder
(setq user-emacs-directory rhjr/paths/config)
(use-package compat
:ensure t) ; no-littering dependency
(add-to-list'load-path rhjr/paths/thirdparty)
(eval-and-compile
(setq no-littering-etc-directory rhjr/paths/no-littering/etc)
(setq no-littering-var-directory rhjr/paths/no-littering/var)
(require 'no-littering))
(when (fboundp 'startup-redirect-eln-cache)
(startup-redirect-eln-cache
(convert-standard-filename rhjr/paths/eln-cache)))
(load-theme 'misterioso)
;;; rhjr/defaults
(setq-default
initial-major-mode 'text-mode
initial-scratch-message ""
use-dialog-box nil
inhibit-startup-message ""
inhibit-splash-screen t
inhibit-startup-echo-area-message t
create-lockfiles nil
make-backup-files nil
auto-save-default nil)
;;; rhjr/standard-packages
(use-package dired-x
:ensure nil
:config
(setq-default
dired-free-space nil
default-directory rhjr/paths/home
dired-omit-files
(rx (or
(seq bol "." eol)
(seq bol ".git" eol)
(seq bol ".dir-locals.el" eol)))
dired-use-ls-dired t
insert-directory-program "/usr/bin/ls"
dired-recursive-copies 'always
dired-recursive-deletes 'always
dired-listing-switches "-laGh1v --group-directories-first"))
;;; rhjr/win32
(when (eq system-type 'windows-nt)
(setq select-enable-clipboard t
grep-program "C:\\ProgramData\\chocolatey\\bin\\grep.exe"
find-program "C:\\Windows\\System32\\find.exe"))
;;; rhjr/functions
;; private functions
(defun display-startup-echo-area-message ()
(message ""))
;; public functions
;;; rhjr/mode
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(cua-mode 1)
(set-fringe-mode '(2 . 0))
;;; rhjr/packages
(use-package magit
:defer t)
(use-package corfu
;; Optional customizations
;; :custom
;; (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary
;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match
;; (corfu-preview-current nil) ;; Disable current candidate preview
;; (corfu-preselect 'prompt) ;; Preselect the prompt
;; (corfu-on-exact-match 'insert) ;; Configure handling of exact matches
:init
(global-corfu-mode)
;; Enable optional extension modes:
;; (corfu-history-mode)
;; (corfu-popupinfo-mode)
)
(use-package consult
:bind (("C-x b" . consult-buffer)
("C-x 4 b" . consult-buffer-other-window)
("C-x 5 b" . consult-buffer-other-frame)
;; M-s bindings in `search-map'
("C-f" . consult-find)
("C-s" . consult-ripgrep))
:init
;; use consult to select xref locations with preview.
(setq xref-show-xrefs-function #'consult-xref
xref-show-definitions-function #'consult-xref))
(use-package vertico
:custom
;; (vertico-scroll-margin 0) ;; Different scroll margin
;; (vertico-count 20) ;; Show more candidates
;; (vertico-resize t) ;; Grow and shrink the Vertico minibuffer
(vertico-cycle t) ;; Enable cycling for `vertico-next/previous'
:init
(vertico-mode))
(use-package savehist ;; store history when emacs closes.
:init
(savehist-mode))
(use-package orderless
:custom
;; (orderless-style-dispatchers '(orderless-affix-dispatch))
;; (orderless-component-separator #'orderless-escapable-split-on-space)
(completion-styles '(orderless basic))
(completion-category-overrides '((file (styles partial-completion))))
(completion-category-defaults nil) ;; Disable defaults, use our settings
(completion-pcm-leading-wildcard t))
(use-package cape
;; Bind prefix keymap providing all Cape commands under a mnemonic key.
;; Press C-c p ? to for help.
:bind ("C-c p" . cape-prefix-map) ;; Alternative key: M-<tab>, M-p, M-+
;; Alternatively bind Cape commands individually.
;; :bind (("C-c p d" . cape-dabbrev)
;; ("C-c p h" . cape-history)
;; ("C-c p f" . cape-file)
;; ...)
:init
;; Add to the global default value of `completion-at-point-functions' which is
;; used by `completion-at-point'. The order of the functions matters, the
;; first function returning a result wins. Note that the list of buffer-local
;; completion functions takes precedence over the global list.
(add-hook 'completion-at-point-functions #'cape-abbrev)
(add-hook 'completion-at-point-functions #'cape-dabbrev)
(add-hook 'completion-at-point-functions #'cape-file)
)
(use-package emacs
:custom
;; Enable context menu. `vertico-multiform-mode' adds a menu in the minibuffer
;; to switch display modes.
(context-menu-mode t)
;; Support opening new minibuffers from inside existing minibuffers.
(enable-recursive-minibuffers t)
;; Hide commands in M-x which do not work in the current mode. Vertico
;; commands are hidden in normal buffers. This setting is useful beyond
;; Vertico.
(read-extended-command-predicate #'command-completion-default-include-p)
;; Do not allow the cursor in the minibuffer prompt
(minibuffer-prompt-properties
'(read-only t cursor-intangible t face minibuffer-prompt))
;; TAB cycle if there are only few candidates
(completion-cycle-threshold 3)
;; Enable indentation+completion using the TAB key.
;; `completion-at-point' is often bound to M-TAB.
(tab-always-indent 'complete)
;; Emacs 30 and newer: Disable Ispell completion function.
;; Try `cape-dict' as an alternative.
(text-mode-ispell-word-completion nil)
;; Hide commands in M-x which do not apply to the current mode. Corfu
;; commands are hidden, since they are not used via M-x. This setting is
;; useful beyond Corfu.
(read-extended-command-predicate #'command-completion-default-include-p))
(use-package dabbrev
;; Swap M-/ and C-M-/
:bind (("M-/" . dabbrev-completion)
("C-M-/" . dabbrev-expand))
:config
(add-to-list 'dabbrev-ignored-buffer-regexps "\\` ")
(add-to-list 'dabbrev-ignored-buffer-modes 'authinfo-mode)
(add-to-list 'dabbrev-ignored-buffer-modes 'doc-view-mode)
(add-to-list 'dabbrev-ignored-buffer-modes 'pdf-view-mode)
(add-to-list 'dabbrev-ignored-buffer-modes 'tags-table-mode))
;;; rhjr/keybindings
(global-unset-key (kbd "C-y")) ;; redundant due to cua-mode
(global-unset-key (kbd "C-w"))
(global-unset-key (kbd "M-w"))
(global-unset-key (kbd "C-x u"))
(global-set-key (kbd "C-x C-g") 'bookmark-jump)
(global-set-key (kbd "C-z") 'undo)
;;; rhjr/programming
(setq-default show-trailing-whitespace t)
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages '(cape vertico orderless magit esup corfu consult)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)