1
0

home/develop/emacs: add yasnippet snippets and make snippet dirs configurable

This commit makes two significant changes to the Emacs configuration:

1. Refactors emacs.nix to use proper NixOS module structure:
   - Converts from simple configuration to a module with options/config
   - Adds `tb.emacs.extraSnippetDirs` option to allow per-machine snippet
     directories (defaults to ~/.emacs.d/snippets/)
   - Moves yasnippet configuration from custom.el to nix-generated elisp,
     enabling dynamic snippet directory configuration via Nix

2. Adds a comprehensive collection of yasnippet snippets for multiple modes:
   - C++ mode: 50 snippets for common patterns (class, namespace, operators,
     copy/move semantics, debug helpers, documentation, threading primitives)
   - CC mode (shared C/C++): for, switch, main, include guards, etc.
   - CMake mode: if/else, foreach, function, macro, project boilerplate
   - LaTeX mode: document structure, beamer frames, figures, lists
   - Perl mode: package boilerplate, shebang
   - Python/Shell/Nix/Protobuf/Java/CSS/Dockerfile modes: horizontal rules
     and common patterns
   - Text mode: modeline snippets for locale settings

The snippets use yasnippet's inheritance system via .yas-parents files,
so c++-mode inherits from cc-mode and text-mode, reducing duplication.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-08 22:38:18 -08:00
parent 3d098013a9
commit af6c1ba4e9
111 changed files with 951 additions and 130 deletions

View File

@@ -0,0 +1,73 @@
# -*- mode: snippet; require-final-newline: nil -*-
# name: template
# key: template
# binding: direct-keybinding
# --
% -*- mode: latex; mode: flyspell; ispell-local-dictionary: "en_US"; coding: utf-8 -*-
\documentclass[a4paper,12pt,twoside]{scrartcl}
\setlength\overfullrule{14pt} % this enables big black bars on overlong lines.
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[english]{babel}
\title{${1:title}}
\author{${2:Timo Bingmann}}
% small margin
\usepackage[tmargin=20mm,bmargin=20mm,lmargin=20mm,rmargin=20mm]{geometry}
% set default paragraph skip and indention
\setlength\parskip{\smallskipamount}
\setlength\parindent{0pt}
% math support
\usepackage{amsmath,amssymb,array,mathtools}
% smaller enumerations
\usepackage{enumitem}
\setlist[enumerate]{topsep=\smallskipamount,parsep=0pt}
\setlist[itemize]{topsep=\smallskipamount,parsep=0pt}
\setlist[enumerate,1]{topsep=\smallskipamount,parsep=0pt,label=(\roman*)}
% for graphics
\usepackage{graphicx}
% for nice graphics
\usepackage{tikz}
\usetikzlibrary{calc}
% Hyperref
\usepackage{xcolor,hyperref}
\hypersetup{
colorlinks=true,
pdfborder={0 0 0},
bookmarksopen=true,
bookmarksopenlevel=1,
bookmarksnumbered=true,
linkcolor=blue!60!black,
%linkcolor=black,
urlcolor=blue!60!black,
filecolor=green!60!black,
citecolor=blue!60!black,
pdfpagemode=UseNone,
unicode=true,
setpagesize=false,
bookmarksdepth=subsection,
pdftitle={$1},
pdfauthor={$2},
pdfsubject={},
}
\begin{document}
\maketitle
$0
\end{document}