From 3d736dca8afa108e78ed72369a44ff38df1e0e24 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Sun, 14 Sep 2025 20:32:28 +0100 Subject: [PATCH] Switch to oil.nvim and drop netrw --- lua/plugins/oil.lua | 29 +++++++++++++++++++++++++++++ plugin/netrw.lua | 40 ---------------------------------------- 2 files changed, 29 insertions(+), 40 deletions(-) create mode 100644 lua/plugins/oil.lua delete mode 100644 plugin/netrw.lua diff --git a/lua/plugins/oil.lua b/lua/plugins/oil.lua new file mode 100644 index 0000000..5294537 --- /dev/null +++ b/lua/plugins/oil.lua @@ -0,0 +1,29 @@ +return { + 'stevearc/oil.nvim', + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + lazy = false, + config = function() + require('oil').setup({ + keymaps = { + ["g?"] = { "actions.show_help", mode = "n" }, + [""] = "actions.select", + ["l"] = "actions.refresh", + ["-"] = { "actions.parent", mode = "n" }, + ["_"] = { "actions.open_cwd", mode = "n" }, + ["`"] = { "actions.cd", mode = "n" }, + ["~"] = { "actions.cd", opts = { scope = "tab" }, mode = "n" }, + ["gs"] = { "actions.change_sort", mode = "n" }, + ["gx"] = "actions.open_external", + ["g."] = { "actions.toggle_hidden", mode = "n" }, + ["g\\"] = { "actions.toggle_trash", mode = "n" }, + }, + use_default_keymaps = false, + }) + vim.keymap.set("n", "-", function() + local dir = vim.fn.expand("%:h") + vim.cmd.Oil(dir ~= "" and dir or ".") + end, {}) + end +} diff --git a/plugin/netrw.lua b/plugin/netrw.lua deleted file mode 100644 index b624111..0000000 --- a/plugin/netrw.lua +++ /dev/null @@ -1,40 +0,0 @@ --- Disable banner -vim.g.netrw_banner = 0 - --- Fix gx when running inside WSL -if vim.env.WSLENV then - vim.g.netrw_browsex_viewer = 'cmd.exe /C start' -end - --- Sort files in a sensible sequence -vim.g.netrw_sort_sequence = '[\\/]$,*' - --- Map - key to open netrw in current files parent directory -vim.keymap.set('n', '-', function() - -- Get the filename before invoking netrw - local filename = vim.fn.expand('%:t') - local directory = vim.fn.expand('%:hp') - - if directory == '' then - directory = vim.fn.getcwd() - end - - -- Invoke netrw on the directory containing the current file - vim.fn.execute(string.format("edit %s", directory)) - if filename ~= '' then - -- In the netrw buffer, move the cursor to the first character of filename - vim.fn.search('\\<' .. filename .. '\\>') - end -end) - --- Unmap in netrw buffers so it can be used for natigation -vim.api.nvim_create_autocmd('FileType', { - pattern = 'netrw', - group = vim.api.nvim_create_augroup('netrw_unmap', {}), - callback = function() - local buffer = vim.api.nvim_get_current_buf() - if vim.fn.hasmapto('NetrwRefresh') == 1 then - vim.keymap.del('n', '', { buffer = buffer }) - end - end -})