Module difft::parse::guess_language
source · Expand description
Guess which programming language a file is written in.
This is heavily based on GitHub’s linguist, particularly its languages.yml.
Difftastic does not reuse languages.yml directly. Linguist has a larger set of language detection strategies.
Structs
- An iterator over the variants of Language
Enums
- Language 🔒Languages supported by difftastic. Each language here has a corresponding tree-sitter parser.
Functions
- Try to guess the language based on an Emacs mode comment at the beginning of the file.
- Try to guess the language based on a shebang present in the source.
- guess 🔒
- File globs that identify languages based on the file path.
- The language name shown to the user.
- If there is a language called
name
(comparing case insensitively), return it. Treat"text"
as an additional option. - Use a heuristic to determine if a ‘.h’ file looks like Objective-C. We look for a line starting with ‘#import’, ‘@interface’ or ‘@protocol’ near the top of the file. These keywords are not valid C or C++, so this should not produce false positives.