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:
1
home/develop/emacs/snippets/cmake-mode/.yas-parents
Normal file
1
home/develop/emacs/snippets/cmake-mode/.yas-parents
Normal file
@@ -0,0 +1 @@
|
||||
text-mode
|
||||
@@ -0,0 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: cmake_minimum_required
|
||||
# key: min
|
||||
# --
|
||||
cmake_minimum_required(VERSION ${1:2.6})
|
||||
7
home/develop/emacs/snippets/cmake-mode/foreach
Normal file
7
home/develop/emacs/snippets/cmake-mode/foreach
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: foreach
|
||||
# key: for
|
||||
# --
|
||||
foreach(${1:item} \${${2:array}})
|
||||
$0
|
||||
endforeach()
|
||||
7
home/develop/emacs/snippets/cmake-mode/function
Normal file
7
home/develop/emacs/snippets/cmake-mode/function
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: function
|
||||
# key: fun
|
||||
# --
|
||||
function (${1:name})
|
||||
$0
|
||||
endfunction()
|
||||
6
home/develop/emacs/snippets/cmake-mode/hr
Normal file
6
home/develop/emacs/snippets/cmake-mode/hr
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- mode: snippet; require-final-newline: nil -*-
|
||||
# name: hr
|
||||
# key: hr
|
||||
# binding: direct-keybinding
|
||||
# --
|
||||
`(make-string (- 80 (current-column)) ?#)`
|
||||
7
home/develop/emacs/snippets/cmake-mode/if
Normal file
7
home/develop/emacs/snippets/cmake-mode/if
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: if
|
||||
# key: if
|
||||
# --
|
||||
if(${1:cond})
|
||||
$0
|
||||
endif()
|
||||
9
home/develop/emacs/snippets/cmake-mode/ifelse
Normal file
9
home/develop/emacs/snippets/cmake-mode/ifelse
Normal file
@@ -0,0 +1,9 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: ifelse
|
||||
# key: if
|
||||
# --
|
||||
if(${1:cond})
|
||||
$2
|
||||
else(${3:cond})
|
||||
$0
|
||||
endif()
|
||||
5
home/develop/emacs/snippets/cmake-mode/include
Normal file
5
home/develop/emacs/snippets/cmake-mode/include
Normal file
@@ -0,0 +1,5 @@
|
||||
# type: command
|
||||
# key: inc
|
||||
# name: include
|
||||
# --
|
||||
include ($0)
|
||||
7
home/develop/emacs/snippets/cmake-mode/macro
Normal file
7
home/develop/emacs/snippets/cmake-mode/macro
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: macro
|
||||
# key: macro
|
||||
# --
|
||||
macro(${1:name}${2: args})
|
||||
|
||||
endmacro()
|
||||
5
home/develop/emacs/snippets/cmake-mode/message
Normal file
5
home/develop/emacs/snippets/cmake-mode/message
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: message
|
||||
# key: msg
|
||||
# --
|
||||
message(${1:STATUS }"$0")
|
||||
5
home/develop/emacs/snippets/cmake-mode/option
Normal file
5
home/develop/emacs/snippets/cmake-mode/option
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: option
|
||||
# key: opt
|
||||
# --
|
||||
option (${1:OPT} "${2:docstring}" ${3:value})
|
||||
5
home/develop/emacs/snippets/cmake-mode/project
Normal file
5
home/develop/emacs/snippets/cmake-mode/project
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: project
|
||||
# key: proj
|
||||
# --
|
||||
project ($0)
|
||||
5
home/develop/emacs/snippets/cmake-mode/set
Normal file
5
home/develop/emacs/snippets/cmake-mode/set
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: set
|
||||
# key: set
|
||||
# --
|
||||
set(${1:var} ${2:value})
|
||||
Reference in New Issue
Block a user