Skip to content

use a .env file in your nvim config, and have your environment variables available within nvim.

License

Notifications You must be signed in to change notification settings

jesses-code-adventures/dotenv.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

jesse's super simple .env file handler

if you don't like setting your env variables in your rc files, you can use this.

in the root of your nvim config, create a .env file and add your environment variables.

if no .env file is found, this plugin will throw early.

lazy config

return {
    {
        "jesses-code-adventures/dotenv.nvim",
        config = function()
            require("dotenv").setup()
        end,
        lazy=false
    }
}

you may wish to provide a custom .env file path - you can use the env_path option to do this.

return {
    {
        "jesses-code-adventures/dotenv.nvim",
        config = function()
            require("dotenv").setup({
                env_path="~/.config/nvim/.custom_env_file" -- this could be any file path
            })
        end,
        lazy=false
    }
}

you can verify your variables are now available by echoing them as a neovim cmd.

:echo $MY_ENV_VAR

formatting

if your .env file is incorrectly formatted, this plugin will throw early.

for example, this file will not work.

OPENAI_API_KEY=asdf=asdflj;

nor will this file.

OPENAI_API_KEY

contributing

please feel free to make any pull requests you'd like to. this currently works how i need it to work but i'm open to any ideas.

About

use a .env file in your nvim config, and have your environment variables available within nvim.

Resources

License

Stars

Watchers

Forks

Languages