From 30587406dd9cf980dda733fa32ae9a91e50ff84e Mon Sep 17 00:00:00 2001 From: Jeremie Fraeys Date: Sun, 8 Feb 2026 15:50:24 -0500 Subject: [PATCH] feat: open oil.nvim instead of netrw when starting nvim from a directory --- lua/config/options.lua | 15 ++++++++++++--- lua/custom/plugins/oil.lua | 1 - 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lua/config/options.lua b/lua/config/options.lua index 54e1f78..bd3105d 100755 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -91,12 +91,12 @@ local disabled_built_ins = { 'gzip', 'logipat', 'matchit', - -- "netrw", + 'netrw', 'netrwFileHandlers', 'loaded_remote_plugins', 'loaded_tutor_mode_plugin', - -- "netrwPlugin", - -- "netrwSettings", + 'netrwPlugin', + 'netrwSettings', 'rrhelper', 'spellfile_plugin', 'tar', @@ -139,3 +139,12 @@ opt.formatoptions = opt.formatoptions + 'j' -- Auto-remove comments if possible. - '2' -- I'm not in gradeschool anymore opt.iskeyword:append('_') + +-- Open oil.nvim when opening a directory +vim.api.nvim_create_autocmd('VimEnter', { + callback = function() + if vim.fn.isdirectory(vim.fn.expand('%:p')) == 1 then + require('oil').open(vim.fn.expand('%:p')) + end + end, +}) diff --git a/lua/custom/plugins/oil.lua b/lua/custom/plugins/oil.lua index 9995386..4b6057c 100755 --- a/lua/custom/plugins/oil.lua +++ b/lua/custom/plugins/oil.lua @@ -1,6 +1,5 @@ return { 'stevearc/oil.nvim', - lazy = true, keys = { { 'e', 'Oil', desc = 'Open parent directory' }, {