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

Env vars not utilized properly unless loaded from the start #59

Closed
katmfoo opened this issue Sep 4, 2020 · 2 comments
Closed

Env vars not utilized properly unless loaded from the start #59

katmfoo opened this issue Sep 4, 2020 · 2 comments

Comments

@katmfoo
Copy link

katmfoo commented Sep 4, 2020

I am using vim-dotenv to load database connection strings from a .env file that exists directly in my home directory (~/.env). The problem I am having is that it seems like this plugin only recognizes the env vars sourced by vim-dotenv if they are sourced automatically (when vim starts). If I source more env vars interactively with :Dotenv {dir} (from vim-dotenv), the connections don't show up when I do :DBUI.

The reason I need to do this is because vim-dotenv seems to only source the first .env file that it finds up the directory tree. So if I am in a project with its own directory (that exists in my home directory) that has its own .env file, the ~/.env file does not get sourced (and doesn't show up when I do :DBUI).

Is there anyway to make this work? My goal is to call something in my .vimrc that manually sources ~/.env directly on vim startup, that way I can always call :DBUI and see all my connections (even if I didn't open a file directly -- side note, why do the env vars for connections not work properly if you don't actually open a file with vim?)

Thanks for any help, great plugin by the way -- surprised it is not more popular.

@kristijanhusak
Copy link
Owner

Should be fixed now. Just make sure to redraw the drawer once you load the env.

Problem was that I was solely relying on DotenvGet(), which doesn't always work as expected.
Now I check all available env variables.

@katmfoo
Copy link
Author

katmfoo commented Sep 5, 2020

Should be fixed now. Just make sure to redraw the drawer once you load the env.

Problem was that I was solely relying on DotenvGet(), which doesn't always work as expected.
Now I check all available env variables.

You rock!

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

2 participants