From 96f0f9791c2e4fceb04c1413081e9b47aee69033 Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Thu, 23 Oct 2025 22:29:01 -0400 Subject: [PATCH] docs(templates): update README with new template usage and variables --- templates/README.md | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/templates/README.md b/templates/README.md index 7a2857a..8eee7e7 100644 --- a/templates/README.md +++ b/templates/README.md @@ -5,13 +5,18 @@ Essential templates for modern development with Cosmos SDK, Protobuf, and Vite+C ## 🚀 Usage ### Quick Access -- Press `` to open the template picker -- Or use `:TemplateSnacks` command +- **``** - Open Snacks template picker (primary) +- **`t`** - Create a new template file +- **`T`** - Open Telescope template picker (alternative) +- `:TemplateSnacks` - Command for Snacks picker +- `:TemplateCreate [filetype]` - Create new template +- `:TemplateTelescope` - Command for Telescope picker ### Template Variables Templates support the following placeholders: +#### Built-in Variables - `{{_date_}}` - Current date and time - `{{_cursor_}}` - Cursor position after insertion - `{{_file_name_}}` - Current file name (without extension) @@ -22,6 +27,12 @@ Templates support the following placeholders: - `{{_variable_}}` - Prompts for custom variable name - `{{_lua:_}}` - Execute Lua expression +#### Custom Registered Variables +- `{{_path_}}` - Full path to current file +- `{{_relative_path_}}` - Relative path to current file +- `{{_dir_}}` - Directory of current file +- `{{_project_}}` - Current project/directory name + ## 📁 Available Templates ### Cosmos SDK (Go) - `/cosmos` @@ -139,6 +150,18 @@ Creates a TanStack Query API client with CRUD operations. ### Adding Your Own Templates +#### Quick Method (Recommended) +1. Press `t` to start the TemplateCreate command +2. Type category and filename (e.g., `vite/form.tsx`) +3. Optional: specify filetype (defaults to current buffer's filetype) +4. Template file is created automatically and opens for editing + +Example command: +```vim +:TemplateCreate vite/form.tsx typescriptreact +``` + +#### Manual Method 1. Create a new `.tpl` file in the templates directory 2. Add filetype marker as first line: `;; ` 3. Use template variables as needed @@ -150,6 +173,8 @@ Example: /** * {{_file_name_}} * @author {{_author_}} + * @project {{_project_}} + * @path {{_relative_path_}} */ export const {{_camel_case_file_}} = {{_cursor_}}