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

Highlight .env / .envrc files #8092

Closed
yoav-lavi opened this issue Aug 28, 2023 · 6 comments
Closed

Highlight .env / .envrc files #8092

yoav-lavi opened this issue Aug 28, 2023 · 6 comments
Labels
A-language-support Area: Support for programming/text languages C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much

Comments

@yoav-lavi
Copy link
Contributor

yoav-lavi commented Aug 28, 2023

Both are currently treated as plain text.

For .env it would probably be best to include \.env(\.(\w)+)?, .envrc could do the same or just .envrc.example as a single addition to .envrc

@yoav-lavi yoav-lavi added the C-enhancement Category: Improvements label Aug 28, 2023
@yoav-lavi
Copy link
Contributor Author

yoav-lavi commented Aug 28, 2023

(I think .env shares the same syntax as .ini and .envrc the same as .sh but TBD)

@pascalkuthe pascalkuthe added E-easy Call for participation: Experience needed to fix: Easy / not much A-language-support Area: Support for programming/text languages labels Sep 8, 2023
@dob9601
Copy link
Contributor

dob9601 commented Sep 11, 2023

I did some searching around and it seems vim, amongst other editors, treat .envs as a shell file too: https://github.com/vim/vim/blob/e5f7cd0a60d0eeab84f7aeb35c13d3af7e50072e/runtime/filetype.vim#L1974

I've been looking for an issue to get me started contributing to helix and will happily pick it up later today if it hasn't been done

@dob9601
Copy link
Contributor

dob9601 commented Sep 15, 2023

Hmm, env highlighting already seems to exist for .env and .envrc via the bash grammar:

helix/languages.toml

Lines 2262 to 2270 in 13d4463

[[language]]
name = "env"
scope = "source.env"
file-types = [".env", ".env.local", ".env.development", ".env.production", ".env.dist", ".envrc"]
injection-regex = "env"
comment-token = "#"
indent = { tab-width = 4, unit = "\t" }
roots = []
grammar = "bash"

I've opened up an editor and can also confirm that the highlighting is being applied.

@yoav-lavi is there any chance your local languages.toml is overriding the configuration of the default one?

Might be that the file-types to be relaxed a bit if your env file has a .local extension or similar

@yoav-lavi
Copy link
Contributor Author

yoav-lavi commented Sep 17, 2023

You're likely right, I must have looked at a .env(rc)?.example file, as I have .env(rc)? files ignored. I don't think the current mechanism supports wildcards though, maybe we could add the common variants manually

@dob9601
Copy link
Contributor

dob9601 commented Sep 17, 2023

I could see wildcard filename support being useful anytime you've got a file with a local override. It might be better to do the extra work to add wildcard support but open to opinions on that one

@pascalkuthe
Copy link
Member

closed by #4536

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 E-easy Call for participation: Experience needed to fix: Easy / not much
Projects
None yet
Development

No branches or pull requests

3 participants