From 70861e5896068dbf8fbb1877b7a33b29781c5c18 Mon Sep 17 00:00:00 2001 From: Barrett Ruth <62671086+barrettruth@users.noreply.github.com> Date: Sat, 21 Feb 2026 02:22:49 -0500 Subject: [PATCH] fix: hijack all directory buffers at setup, not just current (#11) Problem: when neovim is opened with multiple directory arguments (e.g. nvim dir1/ dir2/), only the first directory gets handled by oil. The BufAdd autocmd that renames directory buffers to oil:// URLs is registered inside setup(), but neovim creates all argument buffers before setup() runs. The initial hijack block only processes nvim_get_current_buf(), so additional directory buffers are never renamed and remain as plain empty buffers. Solution: iterate all existing buffers at setup time instead of only the current one. Each directory buffer gets renamed to an oil:// URL so that BufReadCmd fires when the user switches to it. Closes: stevearc/oil.nvim#670 --- lua/oil/init.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lua/oil/init.lua b/lua/oil/init.lua index 00e6b14..7a70c15 100644 --- a/lua/oil/init.lua +++ b/lua/oil/init.lua @@ -1447,9 +1447,10 @@ M.setup = function(opts) end, }) - local bufnr = vim.api.nvim_get_current_buf() - if maybe_hijack_directory_buffer(bufnr) and vim.v.vim_did_enter == 1 then - M.load_oil_buffer(bufnr) + for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do + if maybe_hijack_directory_buffer(bufnr) and vim.v.vim_did_enter == 1 then + M.load_oil_buffer(bufnr) + end end end end