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Β§
- Language
Iter πAn iterator over the variants of Language
EnumsΒ§
- Language πLanguages supported by difftastic. Each language here has a corresponding tree-sitter parser.
- Language
Override πUsers can explicitly request to treat a certain file glob pattern as a specific languages, rather than using the normal language detection logic.
FunctionsΒ§
- Try to guess the language based on an Emacs mode comment at the beginning of the file.
- from_
glob π - from_
shebang πTry to guess the language based on a shebang present in the source. - guess π
- language_
globs πFile globs that identify languages based on the file path. - language_
name π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. - looks_
like_ πhacklang - looks_
like_ πobjc 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. - looks_
like_ πxml