From 3d3df74532eaea2b071da03079c3a4c8e4fe5aeb Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Sat, 18 Mar 2023 15:26:19 -0700 Subject: [PATCH] feat: config option to disable directory hijacking (#76) --- README.md | 2 ++ doc/oil.txt | 2 ++ lua/oil/config.lua | 2 ++ lua/oil/init.lua | 3 +++ 4 files changed, 9 insertions(+) diff --git a/README.md b/README.md index b3bf707..63b06b4 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,8 @@ require("oil").setup({ conceallevel = 3, concealcursor = "n", }, + -- Oil will take over directory buffers (e.g. `vim .` or `:e src/` + default_file_explorer = true, -- Restore window options to previous values when leaving an oil buffer restore_win_options = true, -- Skip the confirmation popup for simple operations diff --git a/doc/oil.txt b/doc/oil.txt index dc2f8e2..22c4fc0 100644 --- a/doc/oil.txt +++ b/doc/oil.txt @@ -37,6 +37,8 @@ OPTIONS *oil-option conceallevel = 3, concealcursor = "n", }, + -- Oil will take over directory buffers (e.g. `vim .` or `:e src/` + default_file_explorer = true, -- Restore window options to previous values when leaving an oil buffer restore_win_options = true, -- Skip the confirmation popup for simple operations diff --git a/lua/oil/config.lua b/lua/oil/config.lua index 8e869ee..b11c641 100644 --- a/lua/oil/config.lua +++ b/lua/oil/config.lua @@ -22,6 +22,8 @@ local default_config = { conceallevel = 3, concealcursor = "n", }, + -- Oil will take over directory buffers (e.g. `vim .` or `:e src/` + default_file_explorer = true, -- Restore window options to previous values when leaving an oil buffer restore_win_options = true, -- Skip the confirmation popup for simple operations diff --git a/lua/oil/init.lua b/lua/oil/init.lua index 4fa1ec7..c937d3d 100644 --- a/lua/oil/init.lua +++ b/lua/oil/init.lua @@ -459,6 +459,9 @@ end local function maybe_hijack_directory_buffer(bufnr) local config = require("oil.config") local util = require("oil.util") + if not config.default_file_explorer then + return + end local bufname = vim.api.nvim_buf_get_name(bufnr) if bufname == "" then return