A zero-dependency Zed extension that automatically inserts customizable file headers when you create new, empty files.
Author: MrAMS 2421653893@qq.com
Repository: https://github.com/MrAMS/zed-auto-file-header
Platforms: Linux (x86_64/ARM64) β’ macOS (Intel/Apple Silicon) β’ Windows (x86_64)
- π Zero Dependencies: No Rust or build tools required - downloads pre-built binaries automatically
- π Cross-Platform: Supports all major platforms and architectures
- β‘ Auto-Detection: Recognizes 30+ programming languages with appropriate comment styles
- π¨ Fully Customizable: Define global or per-language templates
- π Dynamic Configuration: Changes take effect immediately without restarting
- π Flexible Config Location: Project-specific or user-global configuration
- Open Zed β Extensions panel (
Ctrl+Shift+Pβ "zed: extensions") - Search for "Auto File Header"
- Click Install
- Create configuration file (required - see Configuration section below)
- Restart Zed
On first use, the extension automatically downloads the appropriate pre-built binary for your platform. You'll see "auto-header: Downloading..." in the status bar - this only happens once.
The extension automatically recognizes and applies appropriate comment styles for 50+ languages:
- C-Style: C, C++, C#, Java, JavaScript, TypeScript, Rust, Go, Swift, Kotlin, Scala, Dart, Zig, D
- Scripts: Python, Bash, Zsh, Fish, Ruby, Perl, R, Julia, Tcl, Nim, Crystal
- Hardware: Verilog, SystemVerilog
- Markup: HTML, XML, SVG
- Styles: CSS, SCSS, SASS, LESS
- Database: SQL
- Config: YAML, TOML, INI
- Functional: Lua, Haskell, Lisp, Scheme, Clojure, Erlang, Elixir, OCaml, F#, Racket, Gleam
- Document: Typst, LaTeX, TeX, BibTeX
- Systems: Odin
- Editor: Vim script
π See LANGUAGES.md for complete details and examples.
The extension only activates when a .auto-header.toml file exists. This file defines your author information, project details, and header templates.
The extension searches for .auto-header.toml in the following order and uses the first one found:
-
Project Root (highest priority)
- Path:
./.auto-header.toml(in your project's root directory) - Use case: Project-specific headers with custom copyright, team info, etc.
- Path:
-
Zed Config Directory
- Linux/macOS:
~/.config/zed/auto-header.toml - Windows:
%APPDATA%\Zed\auto-header.toml - Use case: User-wide default settings for all projects
- Linux/macOS:
-
Home Directory (lowest priority)
- Path:
~/.auto-header.toml - Use case: Fallback location, traditional dotfile approach
- Path:
Recommendation:
- Use project root for team projects with specific copyright/license requirements
- Use Zed config directory for personal default settings across all projects
Create one of the above files with your information:
[author]
name = "Your Name"
email = "your.email@example.com"
[project]
name = "My Project"
copyright_holder = "Your Company" # Optional, defaults to author name
[header]
# The [header] section is OPTIONAL - if omitted, a default template will be used
# Write your template content WITHOUT comment markers!
# The extension automatically wraps it with the correct format for each language.
template = """
File: {filename}
Project: {project}
Author: {author} <{email}>
Created: {date} {time}
Copyright (c) {year} {copyright_holder}
All rights reserved.
"""β¨ Automatic Comment Wrapping: Simply write your template content once without any comment syntax. The extension intelligently wraps it with the correct format for each language:
- C/Rust/Java/JavaScript:
/* ... */ - Python:
""" ... """(with UTF-8 encoding header) - Shell scripts:
#(with automatic shebang like#!/usr/bin/env bash) - HTML:
<!-- ... --> - SQL:
-- - Lua:
--[[ ... ]] - Verilog/SystemVerilog:
// - Tcl:
# - And 35+ more languages!
π‘ This makes your config portable and clean - write once, works everywhere!
| Variable | Description | Example |
|---|---|---|
{filename} |
File name only | example.rs |
{filepath} |
Full file path | /home/user/project/example.rs |
{date} |
Current date | 2025-11-24 |
{time} |
Current time | 19:30:00 |
{year} |
Current year | 2025 |
{author} |
Author name from config | Your Name |
{email} |
Author email from config | your.email@example.com |
{project} |
Project name from config | My Project |
{copyright_holder} |
Copyright holder (defaults to author) | Your Company |
{interpreter} |
Script interpreter (for shebang) | python3, bash, etc. |
You can easily customize the template to include open source licenses:
MIT License Example:
[header]
template = """
File: {filename}
Author: {author} <{email}>
Date: {date}
Copyright (c) {year} {copyright_holder}
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
"""Mozilla Public License (MPL-2.0) Example:
[header]
template = """
File: {filename}
Author: {author}
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at https://mozilla.org/MPL/2.0/.
"""Apache License 2.0 Example:
[header]
template = """
File: {filename}
Copyright {year} {copyright_holder}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""You can override the default template for specific file extensions:
[header.by_extension.py]
template = """
File: {filename}
Project: {project}
Author: {author} <{email}>
Created: {date} {time}
Copyright (c) {year} {copyright_holder}
"""
[header.by_extension.sh]
template = """
#!/usr/bin/env bash
#
# File: {filename}
# Author: {author}
# Date: {date}
#
"""
[header.by_extension.html]
template = """
<!--
File: {filename}
Author: {author}
Date: {date}
-->
"""See the included .auto-header.toml file in this repository for a complete example with multiple language overrides.
- Create a
.auto-header.tomlfile in one of the locations mentioned above - Restart Zed (only needed after creating config for the first time)
- Create a new file in Zed
- Header is automatically inserted when you open an empty file
Note: Headers are only inserted into completely empty files. If a file already has content, no header will be added.
With the basic configuration above, creating a new example.rs file will automatically insert:
/*
* File: example.rs
* Project: My Project
* Author: Your Name <your.email@example.com>
* Created: 2025-11-24 19:30:00
*
* Copyright (c) 2025 Your Company
* All rights reserved.
*/Problem: Creating new files doesn't insert headers
Solutions:
-
Check config file exists:
# Check project root ls -la .auto-header.toml # Check Zed config directory (Linux/macOS) ls -la ~/.config/zed/auto-header.toml # Check home directory ls -la ~/.auto-header.toml
-
Restart Zed after creating the config file for the first time
-
Ensure file is empty: Headers are only inserted into new, completely empty files
-
Check Zed logs:
Ctrl+Shift+Pβ "zed: open log"- Look for "Auto File Header" messages
Problem: Extension shows errors like "Failed to fetch release from GitHub"
Solutions:
-
Check internet connection: Ensure you can access github.com
-
Wait and retry: GitHub API may have rate limits
-
Manual download (as fallback):
- Download binary from Releases
- Place in your project directory with name:
- Linux/macOS:
auto-header-server - Windows:
auto-header-server.exe
- Linux/macOS:
Expected behavior: On first use, you'll see "auto-header: Downloading..." in Zed's status bar for a few seconds. This only happens once as the binary (~2-3 MB) is downloaded and cached.
Problem: Error message "Unsupported platform"
Supported platforms:
- Linux: x86_64, ARM64 (aarch64)
- macOS: x86_64 (Intel), ARM64 (Apple Silicon)
- Windows: x86_64
If your platform isn't supported, please open an issue.
Problem: Headers work for some files but not others
Solutions:
-
Check file extension: Ensure your file extension is in the supported languages list
-
Check built-in templates: Not all extensions have built-in templates, but you can add custom ones in
.auto-header.toml:[header.by_extension.xyz] template = """ # Your custom template for .xyz files """
For extension developers who want to modify or test the extension:
-
Clone the repository:
git clone https://github.com/MrAMS/zed-auto-file-header.git cd zed-auto-file-header -
Install as a dev extension in Zed:
- Open Zed
Ctrl+Shift+Pβzed: install dev extension- Select the
extensiondirectory
-
Create a config file:
cp .auto-header.toml ~/.auto-header.toml nano ~/.auto-header.toml # Edit with your details
-
Restart Zed and test
Configuration changes take effect immediately (no rebuild needed).
βββ Cargo.toml # Extension Rust code config
βββ .github/workflows/
β βββ release.yml # Automated cross-platform builds
βββ extension.toml # Extension manifest
βββ src/lib.rs # Binary download & LSP launcher
βββ server/ # Language server (native)
βββ Cargo.toml
βββ src/main.rs # LSP server logic
Server binary:
cargo build --release --package auto-header-server
# Output: target/release/auto-header-serverExtension Wasm:
rustup target add wasm32-wasip1
cargo build --release --package auto-header-extension --target wasm32-wasip1
# Output: target/wasm32-wasip1/release/auto_header_extension.wasmTags matching v* automatically trigger GitHub Actions to build binaries for all platforms and publish a release. See PUBLISHING.md for details.
This extension uses an LSP Wrapper design:
-
Zed Extension (Wasm):
- Checks for cached/local
auto-header-serverbinary - Downloads from GitHub Releases if not found (with status indicator)
- Launches the LSP server
- Checks for cached/local
-
LSP Server (Native):
- Listens for
didOpenevents - Checks if file is empty and config exists
- Injects appropriate header template based on language
- Listens for
This architecture enables zero-dependency installation while maintaining full LSP capabilities.
MIT License Β© 2025 MrAMS
Issues and pull requests are welcome!
Repository: https://github.com/MrAMS/zed-auto-file-header
Quick Setup Checklist:
- β Install extension from Zed marketplace
- β
Create
.auto-header.toml(project root or~/.config/zed/) - β Add your author info and customize template
- β Restart Zed
- β Create a new file and see the magic! β¨