zed-hosts
Syntax highlighting for /etc/hosts files in the Zed editor.
Highlights:
- Full-line and inline
#comments - IPv4 and IPv6 addresses (as numbers)
- Hostnames (as variables)
The grammar lives in a sibling repository: tree-sitter-hosts.
Installation
From the Zed extensions panel
Once published: open the command palette → zed: extensions → search for Hosts → Install.
As a dev extension
- Clone this repository.
- In Zed, open the command palette →
zed: install dev extension. - Select the cloned
zed-hosts/directory.
Zed will fetch the grammar from tree-sitter-hosts at the pinned revision and compile it.
File matching
path_suffixes = ["hosts"] (defined in languages/hosts/config.toml) already matches any path ending in hosts, including /etc/hosts and /private/etc/hosts. No extra configuration is needed for the standard case.
If you want to apply the language to other filenames (e.g. Hostfile, hosts.bak, custom paths), add a file_types override to ~/.config/zed/settings.json:
{
"file_types": {
"Hosts": ["Hostfile", "**/custom/path/hosts.*"]
}
}License
MIT — see LICENSE.