An extension for stevearc/oil.nvim that provides a persistent sidebar toggle and context-aware navigation.
oil-bar-demo.mp4
-
Persistent Sidebar Toggle: A simple command (e by default) to open and close oil.nvim in a persistent vertical split on the far left.
-
Context-Aware Navigation: The keymap is enhanced to be "sidebar-aware":
-
In the sidebar: Opens directories within the sidebar, and opens files in the main content window (to the right).
-
In a normal oil buffer: retains its default oil.nvim behavior.
-
Intelligent File Opening: Files opened from the sidebar are automatically opened in a window to the right, creating a new vertical split if one doesn't already exist.
-
Focus Retention: When opening a file from the sidebar, focus immediately returns to the sidebar, allowing you to continue browsing without interruption.
-
Decoupled Configuration: This plugin does not manage or override your personal oil.nvim configuration. It simply adds the toggle functionality and the smart keymap.
-
neovim/nvim-lsp (v0.8+)
-
stevearc/oil.nvim
Here is an example using lazy.nvim.
return {
"maelwalser/oil-bar.nvim",
dependencies = { "stevearc/oil.nvim" },
opts = {
-- keymap = "<leader>p" -- Uncomment and change to your preferred key
},
}Once installed, the plugin provides new behaviors.
Global
- Press <leader>e (or your custom keymap) to toggle the oil.nvim sidebar on and off.
In the Oil Sidebar
-
Place your cursor on a directory and press to navigate into that directory within the sidebar.
-
Place your cursor on a file and press to open that file in a window to the right. Focus will remain on the sidebar.
In a Normal oil Buffer
- Press on any entry to use the default oil.nvim "select" action (e.g., opening the file or directory in the current window).