Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/diniamo/direnv.nvim
Simple Neovim plugin that provides a lua interface to interact with direnv, and a way to automatically load .envrc files
https://github.com/diniamo/direnv.nvim
Last synced: 23 days ago
JSON representation
Simple Neovim plugin that provides a lua interface to interact with direnv, and a way to automatically load .envrc files
- Host: GitHub
- URL: https://github.com/diniamo/direnv.nvim
- Owner: diniamo
- License: eupl-1.2
- Created: 2024-12-22T15:15:39.000Z (29 days ago)
- Default Branch: main
- Last Pushed: 2024-12-22T16:40:23.000Z (29 days ago)
- Last Synced: 2024-12-22T17:30:54.025Z (29 days ago)
- Language: Lua
- Size: 6.84 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# direnv.nvim
Simple Neovim plugin that provides a lua interface to interact with direnv, and a way to automatically load .envrc files.
## Setup / Configuration
Install the plugin with your favorite plugin manager, and call the setup function in your configuration (the values below are the defaults):
```lua
require("direnv").setup({
-- The direnv command/executable to run
direnv = "direnv",
-- Automatically load .envrc files on startup and when changing directories
auto_load = false,
-- Automatically reload .envrc files when they are changed
-- Note that this only works if specifically .envrc is changed, and doesn't
-- if files that .envrc uses change
watch_envrc = false
})
```## Usage
The plugin provides a `Direnv` command, with 3 subcommands: `allow`, `deny`, `reload` (also used for loading). The same functionality is also exposed through lua functions (see the API section for that below).
If you don't want to enable the `auto_load` option, then it's recommended to create mappings:
```lua
local direnv = require("direnv")vim.keymap.set('n', "da", direnv.alow)
vim.keymap.set('n', "dd", direnv.deny)
vim.keymap.set('n', "dr", direnv.reload)
```## API
The plugin exposes the following fields:
- `setup(config?)` - initialization
- `config` the config in use
- `allow(callback?)` - allow the .envrc file; the callback can be used to run a function after
- `deny()` - deny the .envrc file
- `reload()` - load or reload the .envrc file
- `check()` - check if there is a .envrc file that can be loaded, and show a prompt to allow it if it's denied