This is a set of modules for basemacs
. As with the rest of basemacs
, the modules are only a starting point, these even moreso. They can be used as is, but they are intended to be examples of some of the cool packages that Emacs has to offer.
They are slightly more opinionated than the initial configuration, but are simple and easy to modify.
The UI module contains some things that make Emacs look nicer.
rainbow-delimiters
is a “rainbow parentheses”-like mode which highlights delimiters such as parentheses, brackets or braces according to their depth. Each successive level is highlighted in a different color. This makes it easy to spot matching delimiters, orient yourself in the code, and tell which statements are at a given depth.
Turn this on only for programming modes.
(use-package rainbow-delimiters
:straight t
:ghook 'prog-mode-hook)
variable-pitch-mode
allows us to have multiple fonts in a single buffer. This is useful for org-mode
which can have prose, code, and other things, in the same file.
Turn variable-pitch-mode
on for org-mode
.
(use-package face-remap
:straight nil
:ghook
('org-mode-hook #'variable-pitch-mode))
Now we set the main font to use in all buffers, and the proportional and mono fonts in variable-pitch-mode
.
(use-package faces
:straight nil
:config
;; Main typeface
(set-face-attribute 'default nil :family "DejaVu Sans Mono" :height 110)
;; Proportionately spaced typeface
(set-face-attribute 'variable-pitch nil :family "DefaVu Serif" :height 1.0)
;; Monospaced typeface
(set-face-attribute 'fixed-pitch nil :family "DejaVu Sans Mono" :height 1.0))
The :height
value for the default
face is the font size multiplied by 10, e.g. 11 x 10 = 110
. The :height
values for the variable-pitch
and fixed-pitch
faces are their sizes relative to the default face. This is because they use a floating point number. An integer may be used here, but then fonts will not scale gracefully.
These light and dark themes are WCAG compliant, have support for variable-pitch-mode
in org-mode
, and are highly customizable.
Light theme
(use-package modus-themes
:straight t
:init
(setq modus-themes-italic-constructs t
modus-themes-bold-constructs t
modus-themes-region '(bg-only no-extend))
(modus-themes-load-themes)
:config
(modus-themes-load-operandi))
(provide 'basemacs-ui)
;;; basemacs-ui.el ends here
One of the biggest changes that we can make to the usability of Emacs are these “narrowing” or “completion” frameworks. For example, using M-x
is rather unhelpful by default as you have to know what the command is or press <TAB>
for options. These packages make things a bit easier because they show a list of commands to choose from, as you type the choices in the list will narrow down. This is useful for lots of things in Emacs, like finding files, switching buffers, using the help, and more.
There are 4 options to choose from:
- ido - built in, with a few extra packages it is pretty nice
- helm - the most features, been around for the longest (after
ido
), most different from others - ivy - uses minibuffer (like
ido
does), includesswiper
as a replacement forisearch
- selectrum - similar to ivy, newer, simpler code, includes
ctrlf
as a replacement forisearch
NOTE Only one of these modules should be used at a time - all of these modules all change M-x
, and basemacs-ivy
and basemacs-selectrum
change C-s
. The packages themselves can all be installed at once without issue.
The built-in ido-mode
is pretty good with some good default settings and extra packages.
(use-package ido
:straight nil
:custom
(ido-enable-flex-matching t)
(ido-everywhere t)
:config
(ido-mode +1))
(use-package ido-vertical-mode
:straight t
:custom
(ido-vertical-define-keys 'C-n-and-C-p-only)
:config
(ido-vertical-mode +1))
(use-package ido-completing-read+
:straight t
:config
(ido-ubiquitous-mode +1))
(use-package amx
:straight t
:config
(amx-mode +1))
(provide 'basemacs-ido)
;;; basemacs-ido.el ends here
Helm is an Emacs framework for incremental completions and narrowing selections.
helm
is the most feature packed out of all the other options here. It is also the most different as it does not use the minibuffer, rather it opens up its own window.
(use-package helm
:straight t
:demand t
:ghook
'after-init-hook
:general
("M-x" 'helm-M-x)
("C-x r b" 'helm-filtered-bookmarks)
("C-x C-f" 'helm-find-files))
(provide 'basemacs-helm)
;;; basemacs-helm.el ends here
Ivy is a generic completion mechanism for Emacs
(use-package ivy
:straight t
:demand t
:ghook
'after-init-hook
:general
("<f6>" 'ivy-resume)
:custom
(ivy-use-virtual-buffers t)
(enable-recursive-minibuffers t)
(ivy-count-format "(%d/%d) ")
(ivy-height 20))
Counsel, a collection of Ivy-enhanced versions of common Emacs commands.
(use-package counsel
:straight t
:after ivy
:demand t
:general
("M-x" 'counsel-M-x)
("C-x C-f" 'counsel-find-file)
("<f1> f" 'counsel-describe-function)
("<f1> v" 'counsel-describe-variable)
("<f1> l" 'counsel-find-library)
("<f2> i" 'counsel-info-lookup-symbol)
("<f2> u" 'counsel-unicode-char)
("C-c g" 'counsel-git)
("C-c j" 'counsel-git-grep)
("C-c k" 'counsel-rg)
("C-x l" 'counsel-locate)
("C-S-r" 'counsel-expression-history)
:config
;; use ripgrep for counsel-git-grep
(setq counsel-git-cmd "rg --files")
(setq counsel-rg-base-command
"rg -i -M 120 --no-heading --line-number --color never %s ."))
(use-package counsel-etags
:straight t
:after counsel)
Make ivy
look a bit nicer
(use-package ivy-rich
:straight t
:after (ivy counsel)
:config
(ivy-rich-mode +1)
(setcdr (assq t ivy-format-functions-alist) #'ivy-format-function-line))
Replace keybindings for emacs search with swiper.
(use-package swiper
:straight t
:after ivy
:general
("C-s" 'swiper))
(provide 'basemacs-ivy)
;;; basemacs-ivy.el ends here
selectrum
is the newest out of all the options, it is similar to ivy but with simpler code, and it was created by the author of straight.el
.
(use-package selectrum
:straight t
:demand t
:ghook
'after-init-hook)
(use-package prescient
:straight t
:after selectrum
:config
(prescient-persist-mode +1))
(use-package selectrum-prescient
:straight t
:after (selectrum prescient)
:config
(selectrum-prescient-mode +1))
(use-package ctrlf
:straight t
:config
(ctrlf-mode +1))
(provide 'basemacs-selectrum)
;;; basemacs-selectrum.el ends here
Go to the dark side with evil
and get near perfect vim
emulation.
Evil mode is vim in emacs! Using undo-fu
here instead of undo-tree
as I have found that undo-fu
seems to be quicker and less buggy than undo-tree
.
(use-package evil
:straight t
:init
(use-package undo-fu :straight t)
:custom
(evil-want-keybinding nil) ;; evil-collection assumes this
(evil-undo-system 'undo-fu)
:config
(evil-mode +1))
Use evil bindings in various modes.
(use-package evil-collection
:straight t
:after evil
:config
(evil-collection-init))
surround.vim emulation.
(use-package evil-surround
:straight t
:after evil
:config
(global-evil-surround-mode 1))
vim-commentary emulation
(use-package evil-commentary
:straight t
:config
(evil-commentary-mode 1))
(provide 'basemacs-evil)
;;; basemacs-evil.el ends here
Use SPC
as the leader key.
Config in basemacs-core
for now…