Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to specify file type prefixes for language detection #7422

Closed
klardotsh opened this issue Jun 21, 2023 · 2 comments · Fixed by #8006
Closed

Ability to specify file type prefixes for language detection #7422

klardotsh opened this issue Jun 21, 2023 · 2 comments · Fixed by #8006
Labels
A-language-support Area: Support for programming/text languages C-enhancement Category: Improvements

Comments

@klardotsh
Copy link

A pattern I've seen or implemented in many repos is to have Containerfile alongside a Containerfile.base - the former bundles up the app code (which changes frequently), the latter installs "system level dependencies" which generally changes far less frequently (this would be where, say, libfoo-devel gets installed for foo-gem to build against).

My Neovim config appears to auto-detect Containerfile.base as a Dockerfile (not sure if that's by way of file name or by way of the FROM blah line at the top), but I can't so far figure out how to emulate this in Helix, and further, Vim modelines don't flip Helix into Dockerfile mode, so I can't even hint at "hey, here's what you should use to highlight this!".

I'd propose something like the following, though it's probably imperfect and open to all sorts of discussion:

file-types = ["Dockerfile", "dockerfile", "Containerfile", "containerfile", { prefix = "Containerfile." }]

or maybe Containerfile.*?

@klardotsh klardotsh added the C-enhancement Category: Improvements label Jun 21, 2023
@the-mikedavis the-mikedavis added the A-language-support Area: Support for programming/text languages label Jun 22, 2023
@the-mikedavis
Copy link
Member

This would also be useful for Bazel which can have filenames like BUILD.dep1, BUILD.dep2. We already support path suffixes so I think prefixes or file stems could make sense to add as well https://docs.helix-editor.com/master/languages.html#file-type-detection-and-the-file-types-key

@klardotsh
Copy link
Author

This is gonna be one of those "famous last words" things, but: I wonder if regex matching is a useful addition to the file-types matcher. I currently can't think of anything it would add that prefix = "foo" can't do, but (1) it's a more generalized solution for any weird filetypes that come up later, and (2) maybe someone has run into cases where it would be useful already, I dunno.

I agree though that prefix = "foo" is the simpler thing to implement for now, and almost certainly more performant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-support Area: Support for programming/text languages C-enhancement Category: Improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants