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>
2025-12-08 22:38:18 -08:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
let
|
|
|
|
|
snippetsPath = ./emacs/snippets;
|
|
|
|
|
extraSnippetDirs = config.tb.emacs.extraSnippetDirs;
|
|
|
|
|
allSnippetDirs = [ "${snippetsPath}" ] ++ extraSnippetDirs;
|
|
|
|
|
snippetDirsLisp = lib.concatMapStringsSep " " (d: ''"${d}"'') allSnippetDirs;
|
|
|
|
|
in
|
2025-06-23 17:44:56 -07:00
|
|
|
{
|
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>
2025-12-08 22:38:18 -08:00
|
|
|
options.tb.emacs.extraSnippetDirs = lib.mkOption {
|
|
|
|
|
type = lib.types.listOf lib.types.path;
|
|
|
|
|
default = ["~/.emacs.d/snippets/"];
|
|
|
|
|
description = "Additional snippet directories for yasnippet";
|
2025-06-23 17:44:56 -07:00
|
|
|
};
|
2025-07-08 19:43:00 -07:00
|
|
|
|
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>
2025-12-08 22:38:18 -08:00
|
|
|
config = {
|
|
|
|
|
programs.emacs = {
|
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
|
|
# Optionally provide extra packages not in the configuration file.
|
|
|
|
|
extraPackages = epkgs: with epkgs; [
|
|
|
|
|
|
|
|
|
|
# === WEB AND SERVER CONFIGURATION ===
|
|
|
|
|
apache-mode # Syntax highlighting for Apache config files
|
|
|
|
|
nginx-mode # Syntax highlighting for Nginx config files
|
|
|
|
|
|
|
|
|
|
# === HARDWARE AND EMBEDDED DEVELOPMENT ===
|
|
|
|
|
arduino-mode # Arduino sketch development support
|
|
|
|
|
|
|
|
|
|
# === DOCUMENT PREPARATION ===
|
|
|
|
|
auctex # Comprehensive LaTeX editing environment
|
|
|
|
|
pandoc-mode # Pandoc document converter integration
|
|
|
|
|
|
|
|
|
|
# === PROGRAMMING LANGUAGE SUPPORT ===
|
|
|
|
|
basic-mode # BASIC programming language support
|
|
|
|
|
bison-mode # Bison parser generator syntax
|
|
|
|
|
cmake-mode # CMake build system configuration
|
|
|
|
|
coffee-mode # CoffeeScript programming language
|
|
|
|
|
csharp-mode # C# programming language
|
|
|
|
|
groovy-mode # Groovy/Jenkins pipeline scripting
|
|
|
|
|
go-mode # Go programming language
|
|
|
|
|
haskell-mode # Haskell functional programming
|
|
|
|
|
js2-mode # Enhanced JavaScript editing mode
|
|
|
|
|
lua-mode # Lua scripting language
|
|
|
|
|
php-mode # PHP web development
|
|
|
|
|
python-mode # Python programming language
|
|
|
|
|
scala-mode # Scala programming language
|
|
|
|
|
|
|
|
|
|
# === MARKUP AND DATA FORMATS ===
|
|
|
|
|
csv-mode # Comma-separated values file editing
|
|
|
|
|
dockerfile-mode # Docker container definition files
|
|
|
|
|
jinja2-mode # Jinja2 template engine syntax
|
|
|
|
|
markdown-mode # Markdown markup language
|
|
|
|
|
nix-mode # Nix expression language (NixOS configs)
|
|
|
|
|
protobuf-mode # Protocol Buffers schema definitions
|
|
|
|
|
qml-mode # Qt QML user interface markup
|
|
|
|
|
yaml-mode # YAML configuration files
|
|
|
|
|
gnuplot-mode # Gnuplot script editing and plotting integration
|
|
|
|
|
|
|
|
|
|
# === SEARCH AND FILE UTILITIES ===
|
|
|
|
|
rg # Ripgrep searcher integration for fast text search
|
|
|
|
|
diredfl # Enhanced font-locking for dired mode
|
|
|
|
|
dired-ranger # File operations with copy/move/paste semantics
|
|
|
|
|
|
|
|
|
|
# === TEXT COMPLETION AND PRODUCTIVITY ===
|
|
|
|
|
company # Text completion framework
|
|
|
|
|
smex # Enhanced M-x command with history
|
|
|
|
|
|
|
|
|
|
# === USER INTERFACE ENHANCEMENTS ===
|
|
|
|
|
diminish # Hide minor modes from the mode line
|
|
|
|
|
smooth-scrolling # Smoother scrolling experience
|
|
|
|
|
rainbow-delimiters # Color-code nested parentheses/brackets
|
|
|
|
|
|
|
|
|
|
# === ENVIRONMENT AND PROJECT MANAGEMENT ===
|
|
|
|
|
direnv # Environment variable management per directory
|
|
|
|
|
projectile # Project interaction and navigation library
|
|
|
|
|
|
|
|
|
|
# === LANGUAGE SERVER PROTOCOL (LSP) ===
|
|
|
|
|
# Modern language support with intelligent features
|
|
|
|
|
eglot # Built-in LSP client (simpler alternative to lsp-mode)
|
|
|
|
|
lsp-mode # Comprehensive Language Server Protocol client
|
|
|
|
|
lsp-java # Java language server integration
|
|
|
|
|
lsp-metals # Scala language server (Metals) integration
|
|
|
|
|
eglot-java # Java support for eglot LSP client
|
|
|
|
|
sbt-mode # Scala Build Tool integration
|
|
|
|
|
dap-mode # Debug Adapter Protocol for debugging support
|
|
|
|
|
|
|
|
|
|
# === SYNTAX CHECKING ===
|
|
|
|
|
flycheck # On-the-fly syntax checking framework
|
|
|
|
|
|
|
|
|
|
# === VERSION CONTROL ===
|
|
|
|
|
git-link # Generate links to Git repository web interfaces
|
|
|
|
|
magit # Comprehensive Git porcelain for Emacs
|
|
|
|
|
|
|
|
|
|
# === TEXT EDITING ENHANCEMENTS ===
|
|
|
|
|
goto-last-change # Jump to the location of last edit
|
|
|
|
|
iedit # Edit multiple occurrences of text simultaneously
|
|
|
|
|
bm # Visual bookmarks for quick navigation
|
|
|
|
|
|
|
|
|
|
# === CODE FORMATTING AND CLEANUP ===
|
|
|
|
|
web-beautify # Format and beautify web code (HTML/CSS/JS)
|
|
|
|
|
ethan-wspace # Automatically clean up whitespace on save
|
|
|
|
|
|
|
|
|
|
# === PARENTHESES AND STRUCTURE EDITING ===
|
|
|
|
|
paredit # Balanced parentheses editing for Lisp-like languages
|
|
|
|
|
smartparens # Smart handling of pairs (parentheses, quotes, etc.)
|
|
|
|
|
|
|
|
|
|
# === SNIPPETS AND TEMPLATES ===
|
|
|
|
|
yasnippet # Template system for inserting code snippets
|
|
|
|
|
quelpa-use-package # Package management for packages not in MELPA
|
|
|
|
|
|
|
|
|
|
# === VISUAL THEMES ===
|
|
|
|
|
grandshell-theme # Dark theme with good contrast
|
|
|
|
|
leuven-theme # Light theme designed for readability
|
|
|
|
|
|
|
|
|
|
# === TREE-SITTER GRAMMARS ===
|
|
|
|
|
# Modern syntax highlighting and parsing using tree-sitter
|
|
|
|
|
treesit-grammars.with-all-grammars # All available tree-sitter language grammars
|
|
|
|
|
|
|
|
|
|
# === TREE-SITTER BASED MODES ===
|
|
|
|
|
# These modes use tree-sitter for better performance and accuracy
|
|
|
|
|
awk-ts-mode # AWK script editing with tree-sitter
|
|
|
|
|
dart-mode # Dart programming (Flutter development)
|
|
|
|
|
graphql-ts-mode # GraphQL query language with tree-sitter
|
|
|
|
|
jq-ts-mode # jq JSON processor with tree-sitter
|
|
|
|
|
markdown-ts-mode # Markdown with tree-sitter parsing
|
|
|
|
|
mermaid-ts-mode # Mermaid diagram syntax with tree-sitter
|
|
|
|
|
scala-ts-mode # Scala with tree-sitter (alternative to scala-mode)
|
|
|
|
|
swift-ts-mode # Swift programming with tree-sitter
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
extraConfig = builtins.readFile ./emacs/custom.el + ''
|
|
|
|
|
|
|
|
|
|
;; Yasnippet configuration (generated by nix)
|
|
|
|
|
(use-package yasnippet
|
|
|
|
|
:init
|
|
|
|
|
(setq yas-snippet-dirs '(${snippetDirsLisp}))
|
|
|
|
|
:config
|
|
|
|
|
(yas-reload-all)
|
|
|
|
|
(yas-global-mode 1))
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# System packages required by various emacs packages
|
|
|
|
|
home.packages = with pkgs; [
|
|
|
|
|
# Search and file utilities
|
|
|
|
|
ripgrep # Required for rg package
|
|
|
|
|
];
|
|
|
|
|
};
|
2025-06-23 17:44:56 -07:00
|
|
|
}
|