ZIm/crates/language/src
claytonrcarter f4b361f04d
language: Select language based on longest matching path extension (#29716)
Closes #8408  
Closes #10997

This is a reboot of [my original
PR](https://github.com/zed-industries/zed/pull/11697) from last year. I
believe that I've addressed all the comments raised in that original
review, but Zed has changed a lot in the past year, so I'm sure there
will be some new stuff to consider too.

- updates the language matching and lookup to consider not just "does
the suffix/glob match" but also "... and is it the longest such match"
- adds a new `LanguageCustomFileTypes` struct to pass user globs from
settings to the registry
- _minor/unrelated:_ updates a test for the JS extension that wasn't
actually testing what is intended to
- _minor/unrelated:_ removed 2 redundant path extensions from the JS
lang extension

**Languages that may use this**

- Laravel Blade templates use the `blade.php` compound extension
-
[apparently](https://github.com/zed-industries/zed/issues/10765#issuecomment-2091293304)
Angular uses `component.html`
  - see also https://github.com/zed-industries/extensions/issues/169
- _hypothetically_ someone could publish a "JS test" extension w/ custom
highlights and/or snippets; many JS tests use `test.js` or `spec.js`

**Verifying these changes**

I added a number of assertions for this new behavior, and I also
confirmed that the (recently patched) [Laravel Blade
extension](https://github.com/bajrangCoder/zed-laravel-blade) opens as
expected for `blade.php` files, whereas on `main` it does not.

cc @maxbrunsfeld (reviewed my original PR last year), @osiewicz and
@MrSubidubi (have recently been in this part of the code)

Release Notes:

- Added support for "compound" file extensions in language extensions,
such `blade.php` and `component.html`. Closes #8408 and #10997.
2025-05-26 11:00:05 -07:00
..
syntax_map chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
buffer.rs language: Improve auto-indentation when using round brackets in Python (#31260) 2025-05-25 02:25:15 +05:30
buffer_tests.rs language: Select language based on longest matching path extension (#29716) 2025-05-26 11:00:05 -07:00
diagnostic_set.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
highlight_map.rs Docs for indent_size_for_line and co 2024-01-09 20:50:34 +01:00
language.rs Fix text wrapping in commit message editors (#31030) 2025-05-26 13:11:56 +00:00
language_registry.rs language: Select language based on longest matching path extension (#29716) 2025-05-26 11:00:05 -07:00
language_settings.rs debugger: Fix nits (#30632) 2025-05-13 23:13:02 +02:00
manifest.rs project: Track manifest locations per unique manifest locator (#27194) 2025-03-21 15:22:36 +01:00
outline.rs Fix panic when outline items have no name (#24574) 2025-02-10 18:50:26 +00:00
proto.rs Use anyhow more idiomatically (#31052) 2025-05-20 23:06:07 +00:00
syntax_map.rs Use anyhow more idiomatically (#31052) 2025-05-20 23:06:07 +00:00
task_context.rs debugger: Rework language association with the debuggers (#29945) 2025-05-06 20:16:41 +02:00
text_diff.rs agent: Improve Gemini support in the edit_file tool (#31116) 2025-05-22 12:01:43 +03:00
toolchain.rs extension: Add debug_adapters to extension manifest (#30676) 2025-05-20 11:01:33 +02:00