My public Emacs configuration, in order to synchronize them to computers I work with. The configuration for selected command line tools is in my dotfiles repository.
I have copied or adapted some contents from others. For small chunks of code, I have embedded the source URL in a comment inside the file. When copying has been extensive, I have retained the original copyright in the file. Thank you all!
A screenshot, featuring syntax coloring of a shell script file (the left
buffer), magit (the right buffer), and Consult's consult-ripgrep
(the bottom buffer, with Vertico used as the completion UI and
Orderless for completion matching), in the base16-gruvbox-dark-pale
color theme of base16-theme:
The font in use is Input (customization).
I've tuned the mode-line to show only information that I think is
relevant. For instance, only a selection of enabled minor modes is
shown. See etc/tk-looks.el, grep for mode-line-format
.
I have customized js-mode
(for .js
and .jsx
sources) and
typescript-mode (.ts
, .tsx
) major modes to work together with
lsp-mode, Prettier (via prettier.el), company-mode, and
Flycheck. For instance, when I save a .ts
buffer, Flycheck validates
the file and Prettier reformats it. See etc/tk-dev.el.
There are a bunch of small improvements to editing in etc/tk-editing.el, such as:
- Key binding
C-a
(tk-editing/back-to-indentation-or-move-beginning-of-line
) switches the point between the start of line content or the beginning of the line. - Key binding
M-/
(tk-editing/comment-or-uncomment-region-or-line
) comments or uncomments either the current line the point is on (if no region is active) or active region. And if the point was on the beginning of the line, automatically move point to the next line. - By default, highlight trailing whitespace with high-key color and show
tabs with low-key color (easy to see, but not to disturb you). Toggle
showing trailing whitespace with
C-x W
(tk-editing/toggle-show-trailing-whitespace
). - Copy the path of the current buffer to the OS clipboard with
C-c P
(tk-editing/file-path-to-clipboard
), helping you to pass the path to other programs quickly. - Use Smartparens globally, so that it's easy to copy strings within quotes, for example.
- Save the history of recent files periodically, in order to avoid losing the information if Emacs crashes.
Installing Mitsuharu Yamamoto's Emacs Mac port, using Homebrew on macOS:
brew tap railwaycat/emacsmacport
brew install railwaycat/emacsmacport/emacs-mac --with-modern-icon
You'll need Node.js and npm for some of the 3rd party tools (see below). For managing Node.js versions, I recommend using chnode together with the latest LTS version of Node.js:
brew tap tkareine/chnode
brew install tkareine/chnode/chnode
brew install node@20
mkdir -p ~/.nodes
ln -s /usr/local/opt/node@20 ~/.nodes/node-20
Then, put the following into your shell's (Bash or Zsh) init script:
source chnode.sh
chnode node-20
GNU Global is used by the ggtags minor mode to generate and find
source code symbols. It's configured in etc/tk-dev.el. Ggtags mode
gets enabled in selected major modes, such as sh-mode
, scss-mode
,
and yaml-mode, automatically. It's especially useful for navigating
vars in Ansible playbooks.
Configure Global to use Exuberant Ctags for finding symbol definitions and Pygments for symbol references.
Installation, with Homebrew on macOS:
brew install global
I use configuration files for Ctags and Global.
I use two frontends for ripgrep, the fast search tool:
- deadgrep for situations when I want to persist the search results
(
C-c a
fordeadgrep
), and - Consult's
consult-ripgrep
(C-c s
) when I want to discard search results right away.
Installation with Homebrew:
brew install ripgrep
jq is used by Flycheck in json-mode to check JSON syntax. It's configured in etc/tk-dev.el.
Installation with Homebrew:
brew install jq
Marked generates the HTML output from Markdown sources, used by markdown-mode. It's configured in etc/tk-dev.el.
Installation with npm:
npm install -g marked
Prettier is a popular code formatter, used by prettier.el to
reformat the buffer upon save. It's configured in etc/tk-dev.el and
enabled for js-mode
, typescript-mode, html-mode
, json-mode, and
yaml-mode automatically.
Installation with npm:
npm install -g prettier
I use the tsserver
CLI tool of of TypeScript and
typescript-language-server as the server for lsp-mode, configured in
etc/tk-dev.el.
Installation with npm:
npm install -g typescript typescript-language-server