;; C, C++ ;; VHDL, Verilog ;; Latex + templates ;; pdf tools (add-to-list 'load-path (locate-user-emacs-file "lisp/")) (require 'functions) (require 'elpaca-loader) (my-use-package no-littering :ensure (:wait t) :demand t :init (setq no-littering-etc-directory (expand-file-name "stateful/config" user-emacs-directory)) (setq no-littering-var-directory (expand-file-name "stateful/data" user-emacs-directory)) :config ;; (setq savehist-file (expand-file-name "savehist.el" no-littering-var-directory)) ;; (setq recentf-save-file (expand-file-name "recentf-save.el" no-littering-var-directory)) ;; (setq transient-history-file)) ) (elpaca-wait) ;; some visual configs (my-use-package nordic-night-theme :ensure t :demand t :config (load-theme 'nordic-night t) ) (setq-default inhibit-startup-screen t) (setq inhibit-splash-screen t) (setq inhibit-startup-message t) (setq initial-scratch-message "") (setq display-line-numbers-type 'relative) (global-display-line-numbers-mode 1) (setq-default scroll-step 1 scroll-margin 3 scroll-conservatively 101 hscroll-step 1 hscroll-margin 3) (defalias 'yes-or-no-p 'y-or-n-p) (setq-default resize-mini-windows t) ;; Default editing configs (setq create-lockfiles nil) (setq auto-save-default nil) (setq backup-directory-alist `(("." . ,(expand-file-name "saves/" no-littering-var-directory)))) (setq-default tab-width 2) (setq-default indent-tabs-mode nil) (setq-default sentence-end-double-space nil) (setq-default truncate-lines t) ;; ENV (my-use-package exec-path-from-shell :ensure t :demand t :custom (exec-path-from-shell-shell-name (getenv "SHELL")) (exec-path-from-shell-arguments nil) (exec-path-from-shell-variables '("PATH" "MANPATH" "CXX" "CC" "XDG_CONFIG_HOME" "XDG_CACHE_HOME" "XDG_DATA_HOME" "NIX_PATH")) :config (exec-path-from-shell-initialize)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; KEYS ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (my-use-package which-key :ensure t :demand t :custom (which-key-idle-delay 0.6) :config (which-key-mode 1)) (my-use-package general :ensure (:wait t) ; Adds general use-package keyword :config (general-create-definer my-leader :states '(motion normal) :keymaps 'override :prefix "SPC") (general-create-definer my-local-leader :states 'normal :keymaps 'override :prefix "SPC m") (my-leader "" '(nil :wk "global leader") "h" '(:keymap help-map :wk "Help") "C-g" '(keyboard-quit :wk "abort")) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; EVIL ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (my-use-package evil :ensure t :demand t :general (my-leader "u" '(universal-argument :wk "Universal argument")) :bind (:map evil-window-map ("d" . evil-window-delete) ("o" . ace-window)) :custom (evil-undo-system 'undo-redo) (evil-want-integration t) (evil-want-keybinding nil) :config (my-unbind-key-in-evil-states "C-.") (evil-mode)) (my-use-package evil-collection :after evil :ensure t :demand t :config (evil-collection-init)) (my-use-package evil-easymotion :after evil :ensure t :demand t :config (evilem-default-keybindings "\\") ) (my-use-package evil-surround :after evil :ensure t :demand t :config (global-evil-surround-mode 1)) (my-use-package evil-goggles :after evil :ensure t :demand t :custom (evil-goggles-duration 0.1) :config (evil-goggles-mode)) (my-use-package evil-commentary :after evil :ensure t :demand t :config (evil-commentary-mode)) (my-use-package evil-snipe :after evil :ensure t :demand t :config (evil-snipe-mode)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; VERTICO, CONSULT, EMBARK ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (my-use-package vertico :ensure t :after savehist :hook (minibuffer-setup . vertico-repeat-save) :bind (:map vertico-map ("M-P" . vertico-repeat-previous) ("M-N" . vertico-repeat-next) ("S-" . vertico-repeat-previous) ("S-" . vertico-repeat-next) ("?" . minibuffer-completion-help) ("M-RET" . minibuffer-force-complete-and-exit) ("M-TAB" . minibuffer-complete)) :general (my-leader "'" '(vertico-repeat :wk "Last search")) :init (vertico-mode 1) (add-to-list 'savehist-additional-variables 'vertico-repeat-history)) (my-use-package vertico-directory :ensure nil :after vertico :bind (:map vertico-map ("C-h" . vertico-directory-up))) (my-use-package vertico-quick :ensure nil :after vertico :bind (:map vertico-map ("M-q" . vertico-quick-insert) ("C-q" . vertico-quick-exit))) (use-package marginalia :ensure t :bind (:map minibuffer-local-map ("M-A" . marginalia-cycle)) :config (marginalia-mode)) (use-package embark :ensure t :general (my-leader "." '(embark-act :wk "Act") ";" '(embark-dwim :wk "Dwim")) :bind (("C-." . embark-act) ;; pick some comfortable binding ("C-;" . embark-dwim) ;; good alternative: M-. ("C-h B" . embark-bindings)) ;; alternative for `describe-bindings' :custom (prefix-help-command #'embark-prefix-help-command) :init ;; Show the Embark target at point via Eldoc. You may adjust the ;; Eldoc strategy, if you want to see the documentation from ;; multiple providers. Beware that using this can be a little ;; jarring since the message shown in the minibuffer can be more ;; than one line, causing the modeline to move up and down: ;; (add-hook 'eldoc-documentation-functions #'embark-eldoc-first-target) ;; (setq eldoc-documentation-strategy #'eldoc-documentation-compose-eagerly) :config ;; Hide the mode line of the Embark live/completions buffers (add-to-list 'display-buffer-alist '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*" nil (window-parameters (mode-line-format . none))))) ;; Consult users will also want the embark-consult package. (use-package embark-consult :ensure t :hook (embark-collect-mode . consult-preview-at-point-mode)) (my-use-package consult :ensure t :general (my-leader "f" '(nil :wk "File") "f f" '(find-file :wk "Find file") "f r" '(consult-recent-file :wk "Recent file") "f s" '(save-buffer :wk "Save file") "f l" '(consult-locate : "Locate file") "b" '(nil :wk "Buffer") "b b" '(consult-buffer :wk "Switch buffer") "b B" '(consult-project-buffer :wk "Switch project buffer") "," '(consult-buffer :wk "Switch buffer") "c" '(nil :wk "Mode specific") "c h" '(consult-history :wk "History") "c k" '(consult-kmacro :wk "Kmacro") "c m" '(consult-man :wk "Man") "c i" '(consult-info :wk "Info") "y" '(consult-yank-pop :wk "Yank pop") ;; "g" '(nil :wk "Goto") ;; "g f" '(consult-flymake :wk "Goto flymake") ;; "g l" '(consult-goto-line :wk "Goto line") ;; "g o" '(consult-outline :wk "Goto outline") ;; "g m" '(consult-mark :wk "Goto mark") ;; "g k" '(consult-global-mark :wk "Goto global mark") ;; "g i" '(consult-imenu :wk "Goto imenu") ;; "g I" '(consult-imenu-multi :wk "Goto imenu multi") "s" '(:keymap search-map :wk "Search") ) :bind (;; C-c bindings in `mode-specific-map' ("C-c M-x" . consult-mode-command) ("C-c h" . consult-history) ("C-c k" . consult-kmacro) ("C-c m" . consult-man) ("C-c i" . consult-info) ([remap Info-search] . consult-info) ;; C-x bindings in `ctl-x-map' ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command ("C-x b" . consult-buffer) ;; orig. switch-to-buffer ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame ("C-x t b" . consult-buffer-other-tab) ;; orig. switch-to-buffer-other-tab ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer ;; Custom M-# bindings for fast register access ("M-#" . consult-register-load) ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated) ("C-M-#" . consult-register) ;; Other custom bindings ("M-y" . consult-yank-pop) ;; orig. yank-pop ;; M-g bindings in `goto-map' ("M-g e" . consult-compile-error) ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck ("M-g g" . consult-goto-line) ;; orig. goto-line ("M-g M-g" . consult-goto-line) ;; orig. goto-line ("M-g o" . consult-outline) ;; Alternative: consult-org-heading ("M-g m" . consult-mark) ("M-g k" . consult-global-mark) ("M-g i" . consult-imenu) ("M-g I" . consult-imenu-multi) ;; M-s bindings in `search-map' ("M-s d" . consult-find) ;; Alternative: consult-fd ("M-s c" . consult-locate) ("M-s g" . consult-grep) ("M-s G" . consult-git-grep) ("M-s r" . consult-ripgrep) ("M-s l" . consult-line) ("M-s L" . consult-line-multi) ("M-s k" . consult-keep-lines) ("M-s u" . consult-focus-lines) ;; Isearch integration ("M-s e" . consult-isearch-history) :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 ;; Minibuffer history :map minibuffer-local-map ("M-s" . consult-history) ;; orig. next-matching-history-element ("M-r" . consult-history)) ;; orig. previous-matching-history-element :custom (register-preview-delay 0.5) (register-preview-function #'consult-register-format) (xref-show-xrefs-function #'consult-xref) (xref-show-definitions-function #'consult-xref) (consult-narrow-key "<") :init (advice-add #'register-preview :override #'consult-register-window) :config (recentf-mode 1)) (my-use-package orderless :ensure t :custom ;; Configure a custom style dispatcher (see the Consult wiki) ;; (setq orderless-style-dispatchers '(+orderless-consult-dispatch orderless-affix-dispatch)) ;; orderless-component-separator #'orderless-escapable-split-on-space) (completion-styles '(orderless basic)) (completion-category-defaults nil) (completion-category-overrides '((file (styles partial-completion)))) ) ;;; NAVIGATION (my-use-package ace-window :ensure t :general (my-leader "`" '(evil-switch-to-windows-last-buffer :wk "Switch to last buffer") "w" '(:keymap evil-window-map :wk "Windows") ) :custom (aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)) (aw-char-position 'left) (aw-leading-char-style 'char) (aw-scope 'frame) :bind (("M-o" . ace-window))) (my-use-package savehist :init (savehist-mode 1)) (my-use-package emacs :hook (minibuffer-setup . cursor-intangible-mode) :general (my-leader "n" '(:keymap narrow-map :wk "Narrowing")) :custom (enable-recursive-minibuffers t) (read-extended-command-predicate #'command-completion-default-include-p) :init (put 'narrow-to-region 'disabled nil) (setq minibuffer-prompt-properties '(read-only t cursor-intangible t face minibuffer-prompt))) ;; Help (my-use-package helpful :ensure t :general (my-leader "d d" '(helpful-at-point)) :bind ( ([remap describe-function] . helpful-function) ([remap describe-variable] . helpful-variable) ([remap describe-key] . helpful-key) ([remap describe-command] . helpful-command) ([remap describe-symbol] . helpful-symbol))) ;; Projects (my-use-package projectile :ensure t :demand t :custom (projectile-switch-project-action 'projectile-dired) (projectile-completion-system 'default) (projectile-current-project-on-switch 'keep) (evil-shift-width tab-width) :general (my-leader "p" '(:keymap projectile-command-map :wk "projectile")) :bind (:map projectile-mode-map ("C-c p" . projectile-command-map)) :config (projectile-mode 1)) ;; Modeline (my-use-package vs-modeline :ensure (vs-modeline :type git :host github :repo "VojtechStep/vs-modeline.el") :demand t :config (vs-modeline-mode)) ;; File browser (my-use-package dired :ensure nil :custom (dired-dwim-target t)) (my-use-package diredfl :ensure t :config (diredfl-global-mode)) (my-use-package fd-dired :ensure t :general (my-leader "s d" '(fd-dired :wk "Search dired") "s D" '(fd-grep-dired :wk "Search contents dired"))) ;; Git (my-use-package transient :ensure t) (my-use-package magit :ensure t :hook (with-editor-mode . evil-insert-state) :general (my-leader "g" '(nil :wk "Magit") "g g" '(magit-status :wk "Magit") "g /" '(magit-dispatch :wk "Dispatch") "g b" '(magit-blame :wk "Blame")) :custom (magit-save-repository-buffers 'dontask) (magit-diff-refine-hunk 'all) :config ;; I don't know why, but if this is in :custom block, ;; magit-dispatch ends up in an error... (setq evil-collection-magit-want-horizontal-movement t) (evil-set-initial-state #'git-commit-mode 'insert)) (my-use-package hl-todo :ensure (:pin t :tag "v3.6.0") :hook ((prog-mode text-mode) . hl-todo-mode) :general (my-local-leader hl-todo-mode-map "t j" '(hl-todo-next :wk "next TODO" :jump t) "t k" '(hl-todo-previous :wk "previous TODO" :jump t))) (my-use-package magit-todos :ensure t :after magit :config (magit-todos-mode 1)) (my-use-package git-gutter :ensure t :general (my-leader "g p" '(git-gutter:previous-hunk :wk "Previous hunk") "g n" '(git-gutter:next-hunk :wk "Next hunk") "g C-g" '(git-gutter :wk "Git gutter") "g v =" '(git-gutter:popup-hunk :wk "Popup hunk") "g v s" '(git-gutter:stage-hunk :wk "Stage hunk") "g v r" '(git-gutter:revert-hunk :wk "Revert hunk") "g v SPC" '(git-gutter:mark-hunk :wk "Mark hunk")) :config (global-git-gutter-mode 1)) (my-use-package git-timemachine :ensure t :general (my-leader "g t" '(git-timemachine-toggle :wk "Git timemachine")) :config (evil-define-key 'normal git-timemachine-mode-map "?" 'git-timemachine-help "gtc" 'git-timemachine-show-commit) ;; Since the mapping for git-timemachine-help is not ;; updated by updating the map, update it manually. (transient-define-prefix git-timemachine-help () "Show online help." ["Navigate" [("C-k" "show previous revision" git-timemachine-show-previous-revision) ("C-j" "show next revision" git-timemachine-show-next-revision) ("gtg" "show nth revision" git-timemachine-show-nth-revision) ("gtt" "show fuzzy revision" git-timemachine-show-revision-fuzzy)]] ["Kill current revision" [("gty" "kill abbreviated revision" git-timemachine-kill-abbreviated-revision) ("gtY" "kill revision" git-timemachine-kill-revision)]] ["Misc" [("gtb" "blame current revision" git-timemachine-blame) ("gtc" "show commit" git-timemachine-show-commit) ("?" "show help" git-timemachine-help) ("q" "quit" git-timemachine-quit)]]) ) ;; Git timemachine, ... ;; Editing (use-package flycheck :ensure t :config (global-flycheck-mode 1)) ;; Vterm (use-package vterm :ensure t :config (add-to-list 'vterm-eval-cmds '("update-pwd" (lambda (path) (setq default-directory path)))) (push (list "find-file-below" (lambda (path) (if-let* ((buf (find-file-noselect path)) (window (display-buffer-below-selected buf nil))) (select-window window) (message "Failed to open file: %s" path)))) vterm-eval-cmds)) ;; MMM mode (my-use-package mmm-mode :ensure t :config (setq mmm-global-mode 'maybe)) ;; Completion (my-use-package company :ensure t :custom (company-idle-delay nil) :bind ("C-SPC" . company-complete) :config (global-company-mode 1)) ;; Programming (my-use-package lsp-mode :ensure t :general (my-leader "l" '(:keymap lsp-command-map :wk "LSP")) :custom (lsp-keymap-prefix "C-c l") (lsp-enable-suggest-server-download nil) :hook (lsp-mode . lsp-enable-which-key-integration) :commands lsp) (my-use-package envrc :ensure t :demand t :general (my-leader "e" '(:keymap envrc-command-map :wk "Direnv")) :config (envrc-global-mode 1)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Languages ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Lisp (my-use-package elisp-mode :custom (lisp-indent-offset 2)) (defun my-use-package-indent (indent-point state) "Indent always by two" (goto-char (elt state 1)) (+ 2 (current-column))) (put 'my-use-package 'lisp-indent-function 'my-use-package-indent) ;; Nix (my-use-package nix-mode :ensure (nix-mode :fetcher github :repo "NixOS/nix-mode" :files (:defaults (:exclude "nix-company.el"))) :after mmm-mode :mode "\\.nix\\'" :init (load (expand-file-name "nix-mode-mmm.el" (file-name-directory (locate-library "nix-mode"))))) ;; Rust (my-use-package rustic :ensure t :init (add-to-list 'auto-mode-alist '("\\.rs\\'" . rustic-mode)) (load (expand-file-name "nix-mode-mmm.el" (file-name-directory (locate-library "nix-mode"))))) ;; Some additional stuff (add-hook 'write-file-hooks 'delete-trailing-whitespace nil t) ;; Last step - async (elpaca-process-queues) (elpaca-wait)