folke / lazy.nvim

💤 A modern plugin manager for Neovim
https://lazy.folke.io/
Apache License 2.0
15.07k stars 365 forks source link

feature: pass environment variables to git #326

Closed stevearc closed 1 year ago

stevearc commented 1 year ago

Did you check the docs?

Is your feature request related to a problem? Please describe.

I'm using Neovim on a cloud instance at work. This instance does some funky things with git mirrors, so by default the git commands only work for our private repos and will fail for anything on public github (like Neovim plugins, for instance). I can work around this by setting the GIT_CONFIG_NOSYSTEM=1 environment variable. I don't want to do that globally (using vim.env), because then git commands in other plugins will fail when interacting with my work repos. I only want those environment variables set for fetching/updating Neovim plugins.

Describe the solution you'd like

I would like to have a config option for passing environment variables to the git commands. For example:

git = {
  -- Existing options
  log = { "--since=3 days ago" },
  timeout = 120,
  -- The new option
  env = {
    GIT_CONFIG_NOSYSTEM = "1",
  }
}

Describe alternatives you've considered

I previously submitted a PR to packer.nvim for this feature: https://github.com/wbthomason/packer.nvim/pull/1057 As it was pointed out, I could instead create a wrapper script that sets the environment variable and then invokes git. I would prefer not to do this because I'm using this in a kickstart-like single-file init.lua example that I'm putting up as a reference for others at the company, and don't want to add the clutter that would entail.

Additional context

I'm happy to create the PR! I just want to check with you first that this is something you would consider merging.

folke commented 1 year ago

This is too specific. I don't want to add everyone's random features (even not through a PR). You'll have to work-around it in another way.