diff --git a/book/src/languages.md b/book/src/languages.md index 73c812131..9b90a2112 100644 --- a/book/src/languages.md +++ b/book/src/languages.md @@ -50,7 +50,7 @@ ## Language configuration | `name` | The name of the language | | `scope` | A string like `source.js` that identifies the language. Currently, we strive to match the scope names used by popular TextMate grammars and by the Linguist library. Usually `source.` or `text.` in case of markup languages | | `injection-regex` | regex pattern that will be tested against a language name in order to determine whether this language should be used for a potential [language injection][treesitter-language-injection] site. | -| `file-types` | The filetypes of the language, for example `["yml", "yaml"]`. Extensions and full file names are supported. | +| `file-types` | The filetypes of the language, for example `["yml", "yaml"]`. This attempts to match by exact file name (`.zshrc`), then by file extension (`toml`), then by path suffix (`.git/config`). | | `shebangs` | The interpreters from the shebang line, for example `["sh", "bash"]` | | `roots` | A set of marker files to look for when trying to find the workspace root. For example `Cargo.lock`, `yarn.lock` | | `auto-format` | Whether to autoformat this language when saving | diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index a08e50841..f9a2ea5f7 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -471,9 +471,10 @@ pub fn new(config: Configuration) -> Self { for file_type in &config.file_types { // entry().or_insert(Vec::new).push(language_id); + let file_type = file_type.replace('/', &std::path::MAIN_SEPARATOR.to_string()); loader .language_config_ids_by_file_type - .insert(file_type.clone(), language_id); + .insert(file_type, language_id); } for shebang in &config.shebangs { loader @@ -498,6 +499,17 @@ pub fn language_config_for_file_name(&self, path: &Path) -> Option