(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
Use use-package for aesthetics, ensure that packages are installed automatically if not present in the system
(straight-use-package '(use-package
:ensure t))
(require 'use-package-ensure)
(setq straight-use-package-by-default t
use-package-always-ensure t)
(use-package doom-themes
:config
(load-theme 'doom-one t))
(use-package doom-modeline
:hook (after-init . doom-modeline-mode)
:config
(display-battery-mode 1))
To be presented with basic information when starting Emacs.
(use-package dashboard
:config
(setq dashboard-banner-logo-title "Welcome to Rust Emacs"
dashboard-items '((recents . 5)
(projects . 5)
(bookmarks . 5)
(agenda . 5)
(registers . 5))
dashboard-footer-message '("Happy hacking!")
dashboard-set-heading-icons t
dashboard-set-file-icons t
dashboard-center-content t)
(dashboard-setup-startup-hook))
Project management
(use-package projectile
:config
(setq projectile-mode-line-prefix " Proj "
projectile-project-search-path '("/storage/src/unnsvc")
projectile-globally-ignored-file-suffixes '(".log" ".gz" ".zip")
projectile-enable-caching t
projectile-completion-system 'default
projectile-switch-project-action 'projectile-dired)
(projectile-mode +1))
Enable fuzzy matching and searching of terms in any order as you type them
(use-package orderless)
(use-package vertico
:init
(vertico-mode)
:custom
(vertico-reverse-list nil)
(vertico-cycle t)
(vertico-count 100)
(vertico-resize nil)
(vertico-history nil))
Relative line numbers don’t seem to work at present, fix.
(use-package display-line-numbers
:straight nil
:custom
(display-line-numbers-type 'relative)
(display-line-numbers 't)
:init
(display-line-numbers-mode)
)
Enable persistent history?
(use-package savehist
:straight nil
:config
;;(setq savehist-additional-variables '(vertico-sort-function
;; vertico-recency-type))
(savehist-mode 1))
(use-package magit)
For observability into key combinations
(use-package which-key
:config
(which-key-mode))
This is used for searching
(use-package consult
:after projectile
;; :bind (("C-s" . consult-line)
;; ("C-x b" . consult-buffer)
;; ("M-y" . consult-yank-pop)
;; :map vertico-map
;; ("/" . consult-line))
:custom
;;(consult-preview-key nil)
(consult-project-root-function #'projectile-project-root)
(consult-find-command 'rg)
(consult-line-point-placement #'word-begin)
;; Integrate with vertico
(consult-project-root-function #'projectile-project-root))
;; Determine what these are for and if they will be needed
;;(xref-show-xrefs-function #'consul-xref)
;;(xref-show-definitions-function #'consul-xref)
;;(xref-prompt-for-identifier
;; '(not xref-find-definitions xref-find-definitions-other-window xref-find-references)))
;; Provides consult-projectile-find-file
(use-package consult-projectile
:after consult)
Observability into variables, functions, and keys
(use-package helpful
:bind (("C-h f" . #'helpful-callable)
("C-h v" . #'helpful-variable)
("C-h k" . #'helpful-key)))
(use-package lsp-mode
:hook (rust-mode . lsp)
:commands lsp
:custom
(lsp-rust-server 'rust-analyzer))
(use-package lsp-ui
:commands lsp-ui-mode)
(use-package consult-lsp
:commands consult-lsp-symbols)
(use-package rust-mode
:hook (rust-mode . (lambda ()
(setq-local lsp-ui-doc-enable t
lsp-ui-doc-position 'at-point
lsp-ui-doc-header t
lsp-ui-doc-border (face-foreground 'default)
lsp-ui-sideline-enable nil))))
Configure C-k to be a prefix key
;; Create a new keymap
(use-package bind-key
:after (simple magit)
:config
(defvar buffers-keymap (make-sparse-keymap))
(unbind-key "C-b")
(bind-key "C-b" buffers-keymap)
(defvar search-keymap (make-sparse-keymap))
(unbind-key "C-s")
(bind-key "C-s" search-keymap)
(defvar git-keymap (make-sparse-keymap))
(unbind-key "C-g")
(bind-key "C-g" git-keymap))
;; Group together keybindings for that keymap in a meta-package (virtual package)
(use-package meta-buffers-keymap
:straight (:type built-in)
:after bind-key
:bind (:map buffers-keymap
("k" . kill-current-buffer)
("b" . consult-buffer)
("s" . consult-line)))
(use-package meta-search-keymap
:straight (:type built-in)
:after bind-key
:bind (:map search-keymap
("s" . consult-find)
("R" . consult-recent-file)
("r" . consult-ripgrep)
("p" . consult-projectile-find-file)))
(use-package meta-git-keymap
:straight (:type built-in)
:after (bind-key magit)
:bind (:map git-keymap
("g" . magit-status)))
(use-package menu-bar
:straight (:type built-in)
:config
(menu-bar-mode -1))
Minibuffer is a built-in package so :straight nil otherwise it will try to pull minibuffer.el from repos.
(use-package minibuffer
:straight (:type built-in)
:after (orderless vertico)
:custom
(completion-styles '(orderless))
(completion-category-defaults nil)
(completion-category-overrides '((file (styles . (partial-completion))))))
For a table of contents in the github README. Org mode is already loaded through (org-babble-load-file “README.org”) by init.el, this means that we need to use the provided version of org mode or there will be a version mismatch.
(use-package org
:straight (:type built-in)
:custom
(org-startup-indented t))
(use-package org-make-toc
:after org
;; Don't use straight, to use the built-in org mode otherwise straight will attempt to load a more recent org mode
:hook (org-mode . #'org-mode-toc-mode))