mirror of
https://github.com/NotAShelf/direnv.nvim.git
synced 2026-03-07 09:26:08 +00:00
Compare commits
No commits in common. "9e58bb5e8db19d8bf2626de8e94a85fc305a8c1e" and "96d0f73eedc8dfd302dfb75220ac02a3dc29d007" have entirely different histories.
9e58bb5e8d
...
96d0f73eed
3 changed files with 12 additions and 35 deletions
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"diagnostics.globals": [
|
|
||||||
"vim"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
29
README.md
29
README.md
|
|
@ -1,17 +1,15 @@
|
||||||
# direnv.nvim
|
# direnv.nvim
|
||||||
|
|
||||||
[Direnv]: https://direnv.net/
|
[direnv]: https://direnv.net/
|
||||||
|
|
||||||
Dead simple Neovim plugin to add automatic [Direnv] environment loading,
|
Dead simple Neovim plugin to add automatic Direnv loading, inspired by
|
||||||
inspired by `direnv.vim` and written in Lua for better performance and
|
`direnv.vim` and written in Lua for better performance and maintainability.
|
||||||
maintainability.
|
|
||||||
|
|
||||||
## ✨ Features
|
## ✨ Features
|
||||||
|
|
||||||
- Seamless integration with Direnv for managing project environment variables
|
- Seamless integration with direnv for managing project environment variables
|
||||||
- Automatic detection of `.envrc` files in your workspace
|
- Automatic detection of `.envrc` files in your workspace
|
||||||
- Proper handling of allowed, pending, and denied states
|
- Proper handling of allowed, pending, and denied states
|
||||||
- Keybinds for various Direnv commands
|
|
||||||
- Built-in `.envrc` editor with file creation wizard
|
- Built-in `.envrc` editor with file creation wizard
|
||||||
- Statusline component showing real-time direnv status
|
- Statusline component showing real-time direnv status
|
||||||
- Event hooks for integration with other plugins
|
- Event hooks for integration with other plugins
|
||||||
|
|
@ -36,7 +34,7 @@ You will need to call the setup function to load the plugin.
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
- Neovim 0.8.0 or higher
|
- Neovim 0.8.0 or higher
|
||||||
- [Direnv] v2.33.0 or later installed and available in your `PATH`
|
- [direnv] v2.33.0 or later installed and available in your PATH
|
||||||
|
|
||||||
### Using lazy.nvim
|
### Using lazy.nvim
|
||||||
|
|
||||||
|
|
@ -51,7 +49,7 @@ You will need to call the setup function to load the plugin.
|
||||||
|
|
||||||
## 🚀 Usage
|
## 🚀 Usage
|
||||||
|
|
||||||
direnv.nvim will manage your `.envrc` files in Neovim by providing commands to
|
direnv.nvim will manage your .envrc files in Neovim by providing commands to
|
||||||
allow, deny, reload and edit them. When auto-loading is enabled, the plugin will
|
allow, deny, reload and edit them. When auto-loading is enabled, the plugin will
|
||||||
automatically detect and prompt for allowing `.envrc` files in your current
|
automatically detect and prompt for allowing `.envrc` files in your current
|
||||||
directory.
|
directory.
|
||||||
|
|
@ -137,7 +135,7 @@ The statusline function will show:
|
||||||
|
|
||||||
## 🔍 API Reference
|
## 🔍 API Reference
|
||||||
|
|
||||||
### Public Functions
|
**Public Functions**
|
||||||
|
|
||||||
- `direnv.setup(config)` - Initialize the plugin with optional configuration
|
- `direnv.setup(config)` - Initialize the plugin with optional configuration
|
||||||
- `direnv.allow_direnv()` - Allow the current directory's `.envrc` file
|
- `direnv.allow_direnv()` - Allow the current directory's `.envrc` file
|
||||||
|
|
@ -146,7 +144,7 @@ The statusline function will show:
|
||||||
- `direnv.edit_envrc()` - Edit the `.envrc` file
|
- `direnv.edit_envrc()` - Edit the `.envrc` file
|
||||||
- `direnv.statusline()` - Get a string for statusline integration
|
- `direnv.statusline()` - Get a string for statusline integration
|
||||||
|
|
||||||
#### Example
|
### Example
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local direnv = require("direnv")
|
local direnv = require("direnv")
|
||||||
|
|
@ -167,7 +165,7 @@ vim.keymap.set('n', '<Leader>er', function()
|
||||||
end, { desc = "Reload direnv" })
|
end, { desc = "Reload direnv" })
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Events
|
### Events
|
||||||
|
|
||||||
The plugin triggers a User autocmd event that you can hook into:
|
The plugin triggers a User autocmd event that you can hook into:
|
||||||
|
|
||||||
|
|
@ -192,10 +190,5 @@ work.
|
||||||
|
|
||||||
## 📜 License
|
## 📜 License
|
||||||
|
|
||||||
<!-- markdownlint-disable MD059 -->
|
direnv.nvim is licensed under the [MPL v2.0](./LICENSE). Please see the license
|
||||||
|
file for more details.
|
||||||
direnv.nvim is made available under Mozilla Public License (MPL) version 2.0.
|
|
||||||
See [LICENSE](LICENSE) for more details on the exact conditions. An online copy
|
|
||||||
is provided [here](https://www.mozilla.org/en-US/MPL/2.0/).
|
|
||||||
|
|
||||||
<!-- markdownlint-enable MD059 -->
|
|
||||||
|
|
|
||||||
|
|
@ -237,18 +237,7 @@ M._init = function(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
local stdout = obj.stdout or ""
|
local ok, env = pcall(vim.json.decode, obj.stdout)
|
||||||
|
|
||||||
if stdout == "" then
|
|
||||||
-- direnv exported no changes; nothing to do
|
|
||||||
notify(
|
|
||||||
"direnv export produced no output (no changes)",
|
|
||||||
vim.log.levels.DEBUG
|
|
||||||
)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local ok, env = pcall(vim.json.decode, stdout)
|
|
||||||
|
|
||||||
if not ok or type(env) ~= "table" then
|
if not ok or type(env) ~= "table" then
|
||||||
notify("Failed to parse direnv JSON output", vim.log.levels.ERROR)
|
notify("Failed to parse direnv JSON output", vim.log.levels.ERROR)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue