Skip to content

a-schaefers/spartan-emacs

Repository files navigation

Sat 16 Dec 2023 11:37:29 PM MST **BREAKING** changes.

Changing the way this works.

spartan-library has most of the layers, now.

copy ones you want in to spartan.d …

To update without breaking, move your ~/.emacs.d/spartan.el file out of the way for a moment to a safe place, and then restart emacs. Then ‘C-c i’ and copy your old stuff that you want to keep back in, or reconfigure the new one, your choice.

SPARTAN EMACS

Finally, a simple base Emacs configuration framework

FEATURES

  • KISS, clean configuration and a comprehensible layers system with minimal abstraction, (easy to hack on to make it “yours.”)
  • Uses lightweight, mostly-vanilla configured layer packages
  • Straight + use-package version version pinning for greater stability (pins are updated here approximately once a month.)
  • Popular langs come with optional layers that are preconfigured with eglot LSP and company mode
  • Project Awareness is available with Projectile, and Magit
  • Everything is deferred as much as is reasonable, for <1 second initial load times with all layers enabled
  • Choose between holy or evil mode
  • Vertico minibuffer completion
  • Tested on Linux, but should work also work fine anywhere for the most part.
  • Tuned for ultimate performance using the latest gccemacs with native json parsing with eglot language server protocol (not required, just recommended.)
  • Sat 23 Sep 2023 01:49:46 PM MDT - I have an eye towards tree-sitter, but have found setup and configuration incredibly complicated, and especially resulting in an inconsistent experience around something so basic as indentation, so we can wait a while longer for things to standardize and settle down before moving in that direction.

    Spartan Emacs is not a starter kit. It does not teach Emacs. If you are new, and please begin by checking out M-x help-with-tutorial. M-x means (Alt + x) and then help-with-tutorial Return (enter) to begin. One might follow up with An Introduction to Programming in Emacs Lisp additionally. The manuals may all be found at https://www.gnu.org/software/emacs/manual/

    spartan-theme.png

QUICK INSTALL

git clone https://github.com/a-schaefers/spartan-emacs.git ~/.emacs.d

HOW TO UPDATE

Layers use pinned packages via Straight.el and are periodically updated.

  1. git pull
  2. M-x straight-thaw-versions
  3. Restart Emacs

LAYERS

  • Edit .emacs.d/spartan.el to configure the theme, fonts, and additional language layers, then restart

HOW LAYERS WORK

  1. init.el (among other things) auto-generates a default ~/.emacs.d/spartan.el

    This configuration file is not stored in our Git, but you might want to add it in to yours.

    It may freely be modified by the user, but keep in mind it loads early, before the layers.

  2. Enabled layer packages are loaded after ~/.emacs.d/spartan.el
  3. Layer packages may be again customized in ~/.emacs.d/spartan.d/ with any additional setup or overrides

    (all lisp files in spartan.d/ auto load last, during the emacs-startup-hook)

MINIMAL LANGUAGE LAYERS PRECONFIGURED

The idea here is to provide everywhere the get up and going configuration, this means proper syntax support, auto-completion and find definition, etc. via eglot’s minimal language server protocol implementation. Some of the language modes also include repls. Debugging is provided within many of the languages themselves, e.g. Python has pdb. With C, one may use M-x gdb, etc.

With compiled languages, one might use M-x cc and set the compile-command to something instead of make if needed, etc.

To enable LSP for a language layer that supports it, note the external package you will need from below. If the LSP executable is on your PATH and the language layer is active, then eglot is going to automatically initialize it.

  • Bash (shellcheck)
  • C (clang and clangd)

Bash and C layers are provided OOTB. While many other layers live in spartan-library/ and can be copied in to spartan.d/ to enable them.

BINDS

  • Default emacs binds (unless you enable evil.)
  • Short M-x aliases
    • M-x git (magit)
    • M-x pro (projectile-commander)
    • M-x sh (better-shell)
    • M-x lint (flymake)
    • M-x cc (compile-command)
    • etc…
  • Also see spartan-eglot.el for language-server-protocol binds under the M- prefix.
  • Language mode specifc binds should be handled by the mode upstream or by the individual user.
  • Overrides go in .emacs.d/spartan.d/

Compile your own Emacs

If you’re on ubuntu or debian, this should compile Emacs 29 with native compile support, etc. I recommend this because it’s fun and educational, and it’ll keep you rolling on the recent Emacs releases, even when your distro isn’t.

# First determine your gcc version with gcc --version,
# then modify libgccjit-12-dev below to the major version number you have...
sudo apt install \
build-essential \
autoconf \
libgtk-3-dev \
libgnutls28-dev \
libtiff5-dev \
libgif-dev \
librsvg2-dev \
libjpeg-dev \
libwebp-dev \
libxml2-dev \
libpng-dev \
libxpm-dev \
libncurses-dev \
texinfo \
libjansson4 \
libjansson-dev \
libgccjit0 \
libgccjit-12-dev \
libtree-sitter-dev

# Clone repo, checkout relevant branch at time of this writing
git clone git://git.sv.gnu.org/emacs.git
git checkout emacs-29
cd emacs

# Generate makefile
./autogen.sh

# set your c compiler to again be the major version of gcc on your system
export CC=/usr/bin/gcc-12 CXX=/usr/bin/gcc-12

# configure with the flags you want to build with
./configure --with-native-compilation \
--with-json \
--with-pgtk \
--with-rsvg \
--with-gnutls \
--without-xwidgets \
--without-xaw3d \
--with-mailutils \
--with-tree-sitter

# compile it
make -j"$(nproc)"

# start emacs (test)
./src/emacs

# From here, one could add a bash alias to the compiled executable in the HOME directory, e.g.
# alias emacs=~/repos/emacs/src/emacs
# OR, one could opt to just install it...
# sudo make install   # to clobber it all over your system
# sudo make uninstall # should do a decent enough cleanup job
# to update, it might be necessary to clean it before pulling the repo and running through the entire process again
# make clean
# git clean -fdx