(with-eval-after-load 'package (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)) (setopt inhibit-splash-screen t) ;; Don't litter. (setopt make-backup-files nil) (setopt create-lockfiles nil) ;; Ensure that scratch starts in fundamental-mode. (setopt initial-major-mode 'fundamental-mode) ;; Don't show load average in modeline. (setopt display-time-default-load-average nil) ;; Automatically reread from disk if the underlying file changes. (setopt auto-revert-avoid-polling t) (setopt auto-revert-interval 5) (setopt auto-revert-check-vc-info t) (global-auto-revert-mode) ;; Save history in EMACS DIR. (savehist-mode) ;; Setup ctrl+arrowkey to move between emacs defined windows. Will try to make vim-like at some point. (windmove-default-keybindings 'control) ;; Define killing current buffer using C-x c. (global-set-key (kbd "C-x c") #'kill-current-buffer) ;; Some legacy shit. (setopt sentence-end-double-space nil) (defun foehammer--backup-file-name (fpath) "Return a new file path of a given file path. If the new path's directories does not exist, create them." (let* ((backupRootDir "~/.emacs.d/emacs-backup/") (filePath (replace-regexp-in-string "[A-Za-z]:" "" fpath )) ; remove Windows driver letter in path (backupFilePath (replace-regexp-in-string "//" "/" (concat backupRootDir filePath "~") ))) (make-directory (file-name-directory backupFilePath) (file-name-directory backupFilePath)) backupFilePath)) (setopt make-backup-file-name-function 'foehammer--backup-file-name) ;; Globally escape. (global-set-key (kbd "") 'keyboard-escape-quit) ;; Fix some bs with 2~. (global-set-key (kbd "S-SPC") 'just-one-space) (use-package which-key :ensure t :config (which-key-mode)) (use-package evil :ensure t :init (setq evil-respect-visual-line-mode t) (setq evil-undo-system 'undo-redo) (setq evil-want-C-u-scroll t) :config (evil-mode) (define-key evil-normal-state-map (kbd "C-v") 'evil-visual-block) (define-key evil-visual-state-map (kbd "C-v") 'evil-visual-block) (evil-set-initial-state 'vterm-mode 'emacs) ) (use-package cua-base :ensure nil :config (define-key evil-insert-state-map (kbd "C-S-v") 'cua-paste) (define-key evil-normal-state-map (kbd "C-S-v") 'cua-paste) (define-key evil-visual-state-map (kbd "C-S-v") 'cua-paste)) (setopt enable-recursive-minibuffers t) (setopt completion-cycle-threshold 1) (setopt completions-detailed t) (setopt tab-always-indent 'complete) (setopt completion-styles '(basic initials substring)) (setopt completion-auto-help 'always) (setopt completions-max-height 20) (setopt completions-detailed t) (setopt completions-format 'one-column) (setopt completions-group t) (setopt completion-auto-select 'second-tab) ; Much more eager (setopt completion-auto-select t) ; See `C-h v completion-auto-select' for more possible values (keymap-set minibuffer-mode-map "TAB" 'minibuffer-complete) ;; Interface Things. (setopt line-number-mode t) (setopt column-number-mode t) (setopt scroll-margin 10) (setq scroll-conservatively 10) (setopt x-underline-at-descent-line nil) (setopt switch-to-buffer-obey-display-actions t) (setopt show-trailing-whitespace t) (setopt indicate-buffer-boundaries 'left) (blink-cursor-mode -1) ; Steady cursor (pixel-scroll-precision-mode) ; Smooth Scrolling. ;; Line number displays. (add-hook 'prog-mode-hook 'display-line-numbers-mode) (setopt display-line-numbers-width 1) (add-hook 'text-mode-hook 'visual-line-mode) (let ((hl-line-hooks '(text-mode-hook prog-mode-hook))) (mapc (lambda (hook) (add-hook hook 'hl-line-mode)) hl-line-hooks)) (setopt tab-bar-show 1) ;; Gruvbox theme. (setq custom-safe-themes t) (use-package gruvbox-theme :ensure t :init (load-theme 'gruvbox-dark-medium) ) (use-package vertico :ensure t :init (vertico-mode)) (use-package vertico-directory :after vertico :bind (:map vertico-map ("M-DEL" . vertico-directory-delete-word))) (use-package marginalia :ensure t :config (marginalia-mode)) ;; Special, telescope-like bindings. (use-package consult :ensure t :bind ( ("C-x b" . consult-buffer) ; orig. switch-to-buffer ("M-y" . consult-yank-pop) ; orig. yank-pop ("M-s r" . consult-ripgrep) ("M-s l" . consult-line) ("C-s" . consult-line) ("M-s s" . consult-line) ; consult-line instead of isearch, bind ("M-s L" . consult-line-multi) ; isearch to M-s s ("M-s o" . consult-outline) :map isearch-mode-map ("M-e" . consult-isearch-history) ; orig. isearch-edit-string ("M-s e" . consult-isearch-history) ; orig. isearch-edit-string ("M-s l" . consult-line) ; needed by consult-line to detect isearch ("M-s L" . consult-line-multi) ; needed by consult-line to detect isearch ) :config (setq consult-narrow-key "<")) ;; Magit: (use-package magit :ensure t :bind (("C-x g" . magit-status))) ;; Completion: (use-package company :ensure t :config (global-company-mode)) ;; Language specific major modes. (use-package markdown-mode :ensure t :hook ((markdown-mode . visual-line-mode))) (use-package yaml-mode :ensure t) (use-package nix-mode :ensure t) (use-package json-mode :ensure t) (use-package rust-mode :ensure t) (use-package projectile :ensure t :config (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map) (projectile-mode)) (use-package eshell :init (defun foehammer/setup-eshell () ;; Something funny is going on with how Eshell sets up its keymaps; this is ;; a work-around to make C-r bound in the keymap (keymap-set eshell-mode-map "C-r" 'consult-history)) :hook ((eshell-mode . foehammer/setup-eshell))) ;; Eat: Emulate A Terminal (use-package eat :ensure t :custom (eat-term-name "xterm") :config (eat-eshell-mode) (eat-eshell-visual-command-mode)) (use-package elcord :ensure t :config (elcord-mode)) ;; Don't change this (or else gg). (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 '(company consult corfu-candidate-overlay corfu-terminal eat elcord evil gruvbox-theme json-mode kbd-mode lsp-mode magit marginalia nix-mode projectile rust-mode vertico yaml-mode))) (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. )