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

Autocomplete doesn't include contents from .env.local and .env.*other files #90

Open
jmevel opened this issue May 25, 2023 · 7 comments

Comments

@jmevel
Copy link

jmevel commented May 25, 2023

I have a file called .env.local with some variables inside.

In a TypeScript file when I type process.env. the variables from the .env.local file don't show up.

Would that be possible to add some settings to be able to add some file extensions that the Dotenv extension should parse as well?

Note: and I of course configured all the .env.* files to use the dotenv language

"files.associations": {
  ".env.*": "dotenv"
},
@motdotla
Copy link
Member

That is currently by design - to only look at a .env file.

Code is here: https://github.com/dotenv-org/dotenv-vscode/blob/master/lib/helpers.js#L17

Reasoning is we've always recommended against having multiple .env files for development, BUT we do acknowledge how many find it useful.

Furthermore, we've seen the pattern adopted by major frameworks like Next.js.

Are you using this with Next.js?

@motdotla motdotla changed the title Autocomplete doesn't work with .env.* files Autocomplete doesn't include contents from .env.local and .env.*other files Jun 19, 2023
@jmevel
Copy link
Author

jmevel commented Jun 21, 2023

Hi @motdotla, Thanks for your answer.

No, I'm not using Next.js, I simply started learning React with Learn React with TypeScript - Second Edition in which the author is using multiple .env files.

Though, this is something .NET developers are very used to. We're used to having files such as appsettings.json, appsettings.Development.json, appsettings.Staging.json and so on...

See the Microsoft documentation

appsettings.Environment.json using the JSON configuration provider. For example, appsettings.Production.json and appsettings.Development.json.

@motdotla
Copy link
Member

Ok, we'll try and get this added as a feature soon - probably configurable in settings.

@jmevel
Copy link
Author

jmevel commented Jun 22, 2023

Ok, we'll try and get this added as a feature soon - probably configurable in settings.

Wow thanks a lot 🙏

@Plumbiu
Copy link

Plumbiu commented Nov 19, 2023

Hi, may be you can try my repo https://github.com/Plumbiu/vscode-env-ally, only keep autocompletion and peeking.

@jormaechea
Copy link

Hi @motdotla! I'm trying to introduce dotenv at work, with a .env.local file for development environments. VS Code extension was a nice feature to have, but if it doesn't support .env.* files for autocompletion and peeking (but it works fine for cloaking).

Is this something you are still planning to do? Or that you would merge from a PR?
Thanks!

@BoscoDomingo
Copy link

This is also an issue for monorepos where each app/package/module may have its own .env file.

Only the root folder one is being loaded at the moment, and supporting multiple levels would be far better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants