From 6ae5456317564134fdb90342fd59daa44e9862b6 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 27 Jan 2026 10:00:44 +0300 Subject: [PATCH 1/3] chore: tell luacheck that vim is a defined global Signed-off-by: NotAShelf Change-Id: I9bb0435fc423784411d9493b46078fe36a6a6964 --- .luarc.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .luarc.json diff --git a/.luarc.json b/.luarc.json new file mode 100644 index 0000000..1e1765c --- /dev/null +++ b/.luarc.json @@ -0,0 +1,5 @@ +{ + "diagnostics.globals": [ + "vim" + ] +} \ No newline at end of file From b07302cc27f869c66f5cbd8f6aa0b5dcebe70e6c Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 27 Jan 2026 10:02:14 +0300 Subject: [PATCH 2/3] handle empty exports gracefully; log in DEBUG level Signed-off-by: NotAShelf Change-Id: I9c9914b380cb3fd7f7b7a73cba1e19a76a6a6964 --- lua/direnv.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lua/direnv.lua b/lua/direnv.lua index 927932b..12fc214 100644 --- a/lua/direnv.lua +++ b/lua/direnv.lua @@ -237,7 +237,18 @@ M._init = function(path) end vim.schedule(function() - local ok, env = pcall(vim.json.decode, obj.stdout) + local stdout = obj.stdout or "" + + 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 notify("Failed to parse direnv JSON output", vim.log.levels.ERROR) From 9e58bb5e8db19d8bf2626de8e94a85fc305a8c1e Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 27 Jan 2026 10:12:37 +0300 Subject: [PATCH 3/3] docs: minor tweaks to README Signed-off-by: NotAShelf Change-Id: Ie81bda69615b3ee0fcf98f1125dcd0d46a6a6964 --- README.md | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 71ce895..aa25271 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,17 @@ # direnv.nvim -[direnv]: https://direnv.net/ +[Direnv]: https://direnv.net/ -Dead simple Neovim plugin to add automatic Direnv loading, inspired by -`direnv.vim` and written in Lua for better performance and maintainability. +Dead simple Neovim plugin to add automatic [Direnv] environment loading, +inspired by `direnv.vim` and written in Lua for better performance and +maintainability. ## ✨ 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 - Proper handling of allowed, pending, and denied states + - Keybinds for various Direnv commands - Built-in `.envrc` editor with file creation wizard - Statusline component showing real-time direnv status - Event hooks for integration with other plugins @@ -34,7 +36,7 @@ You will need to call the setup function to load the plugin. ### Prerequisites - 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 @@ -49,7 +51,7 @@ You will need to call the setup function to load the plugin. ## 🚀 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 automatically detect and prompt for allowing `.envrc` files in your current directory. @@ -135,7 +137,7 @@ The statusline function will show: ## 🔍 API Reference -**Public Functions** +### Public Functions - `direnv.setup(config)` - Initialize the plugin with optional configuration - `direnv.allow_direnv()` - Allow the current directory's `.envrc` file @@ -144,7 +146,7 @@ The statusline function will show: - `direnv.edit_envrc()` - Edit the `.envrc` file - `direnv.statusline()` - Get a string for statusline integration -### Example +#### Example ```lua local direnv = require("direnv") @@ -165,7 +167,7 @@ vim.keymap.set('n', 'er', function() end, { desc = "Reload direnv" }) ``` -### Events +#### Events The plugin triggers a User autocmd event that you can hook into: @@ -190,5 +192,10 @@ work. ## 📜 License -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/). + +