ellisonleao / dotenv.nvim Goto Github PK
View Code? Open in Web Editor NEWA minimalist .env support for Neovim
License: MIT License
A minimalist .env support for Neovim
License: MIT License
Hello!
Thanks for this plugin! I primarily use this to load some secrets for Github integration into Neovim.
However, can you please expose the load
function to the end users? I need to load a .env
file that's outside the cwd (and parents) and I had to dig into the source to find a Lua solution (using Lazy package manager):
return {
{
'ellisonleao/dotenv.nvim',
opts = {
enable_on_load = true,
},
config = function(_, opts)
require('dotenv').setup(opts)
local dotfiles = vim.uv.fs_realpath(vim.fn.expand('~/.config/nvim/init.lua'))
assert(dotfiles, 'Could not find dotfiles')
require('dotenv').command({fargs = {
vim.fs.dirname(dotfiles) .. '/../.env',
}})
end,
},
}
The last command could be simplified if I could just access load
directly:
require('dotenv').load(vim.fs.dirname(dotfiles) .. '/../.env')
Thanks!!
First of all, thanks for developing this plugin.
I ran into an issue with this plugin when combined with project.nvim. Project.nvim uses the "BufEnter" event, which runs after the "BufReadPost" event, which is what dotenv.nvim currently uses. Because of this, dotenv.nvim is not able to know about a directory change that project.nvim performs with the "BufEnter" event.
I got around this by telling dotenv.nvim to not automatically load the .env
file (which just disables the registering of the builtin autocmd) and instead defined my own autocmd but used the "BufEnter" event. This seems to allow dotenv.nvim to be aware of project.nvim's directory switching.
Because I have a workaround, I don't necessarily need the plugin to change. However, I wanted to bring this to your attention as others may encounter this.
Error detected while processing BufReadPost Autocommands for "*":
Error executing lua callback: ...e/nvim/site/pack/packer/start/dotenv.nvim/lua/dotenv.lua:103: attempt to get length of field 'fargs' (a nil value)
stack traceback:
...e/nvim/site/pack/packer/start/dotenv.nvim/lua/dotenv.lua:103: in func
tion <...e/nvim/site/pack/packer/start/dotenv.nvim/lua/dotenv.lua:99>
This happens every time I open a file in nvim.
Any idea what could be the problem here?
commit 813542a348473ae53d7e6e3b02a55095b29d9385 (grafted, HEAD -> main, origin/main, origin/HEAD)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.