GithubHelp home page GithubHelp logo

ellisonleao / dotenv.nvim Goto Github PK

View Code? Open in Web Editor NEW
35.0 35.0 3.0 14 KB

A minimalist .env support for Neovim

License: MIT License

Makefile 6.28% Lua 93.72%
dotenv hacktoberfest lua neovim neovim-plugin neovim-plugins plugin vim

dotenv.nvim's Introduction

dotenv.nvim's People

Contributors

ellisonleao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

dotenv.nvim's Issues

Please expose `load` as a public function

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!!

Conflict with project.nvim

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 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?

  • NVIM v0.8.1
  • I am installed using Packer, with version:
  • dotenv commit 813542a348473ae53d7e6e3b02a55095b29d9385 (grafted, HEAD -> main, origin/main, origin/HEAD)
  • Running OSX 12.6

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.