11 releases
| 0.3.8 | Feb 3, 2026 |
|---|---|
| 0.3.7 | Feb 3, 2026 |
| 0.3.6 | Jan 31, 2026 |
| 0.2.0 | Jan 11, 2026 |
| 0.1.2 | Jan 28, 2026 |
#1730 in Parser implementations
Used in niblits
21MB
471K
SLoC
Contains (obscure autoconf code, 5KB) samples/M4Sugar/filenames/configure.ac
Palate
File type detection combining the best of tft and hyperpolyglot.
Acknowledgments
This project is a reassembly of code from several excellent projects:
- tft - Tree-sitter File Type, providing fast file type detection using tree-sitter grammars
- Neovim - The original source of filetype detection heuristics and patterns
- hyperpolyglot - Language detection library with comprehensive language patterns
This crate essentially combines and curates the detection logic from these sources into a unified, ergonomic API.
License
GPL-3.0-or-later
This project is derived from tft (GPL-3.0-or-later), which itself incorporates code from Neovim (Apache-2.0/Vim license). As a derivative of GPL-3.0 work, this project is licensed under GPL-3.0-or-later.
Features
- Comprehensive file type detection
- Fast PHF-based lookups
- Content-based detection with heuristics
- Naive Bayes classifier fallback (with
classifierfeature)
Usage
use palate::{detect, FileType};
// Detect file type with fallback to Text
let ft = detect("main.rs", "");
assert_eq!(FileType::Rust, ft);
// Try detection without fallback
let ft = palate::try_detect("unknown.xyz", "");
assert_eq!(None, ft);
Detection Pipeline
- Path suffix matching
- Filename matching
- Pattern matching (with priorities)
- File extension matching (PHF map)
- Negative priority patterns
- Content-based detection (dynamic resolvers)
Features
detect(default): Enable file type detectionclassifier: Enable naive Bayes classifierserde: Enable serde serialization for FileType
Dependencies
~4.5–10MB
~175K SLoC