return { 'stevearc/oil.nvim', lazy = true, keys = { { 'e', 'Oil', desc = 'Open parent directory' }, { 'E', function() require('oil').toggle_float() end, desc = 'Toggle oil floating window', }, }, dependencies = { 'nvim-tree/nvim-web-devicons' }, config = function() local oil = require('oil') oil.setup({ columns = { 'icon', -- 'permissions', }, keymaps = { ['C-h'] = false, ['M-h'] = 'actions.select_split', }, view_options = { show_hidden = true, }, float = { padding = 2, max_width = 80, max_height = 30, border = 'rounded', win_options = { winblend = 0, }, relative = 'editor', }, }) -- Theme-aware highlights for oil local function set_oil_highlights() if vim.o.background == 'dark' then -- Monokai colors vim.api.nvim_set_hl(0, 'OilDir', { fg = '#A6E22E' }) vim.api.nvim_set_hl(0, 'OilFile', { fg = '#D3D0C8' }) vim.api.nvim_set_hl(0, 'OilHiddenFile', { fg = '#75715E' }) vim.api.nvim_set_hl(0, 'OilProgress', { fg = '#66D9EF' }) vim.api.nvim_set_hl(0, 'OilSymlink', { fg = '#F92672' }) else -- Solarized light colors vim.api.nvim_set_hl(0, 'OilDir', { fg = '#859900' }) vim.api.nvim_set_hl(0, 'OilFile', { fg = '#657B83' }) vim.api.nvim_set_hl(0, 'OilHiddenFile', { fg = '#93A1A1' }) vim.api.nvim_set_hl(0, 'OilProgress', { fg = '#268BD2' }) vim.api.nvim_set_hl(0, 'OilSymlink', { fg = '#D30102' }) end end set_oil_highlights() vim.api.nvim_create_autocmd('OptionSet', { pattern = 'background', callback = set_oil_highlights, }) -- Add selected file in oil.nvim to Harpoon (only when in oil buffer) vim.keymap.set('n', 'a', function() local ok_harpoon, harpoon = pcall(require, 'harpoon') if not ok_harpoon then vim.notify('Harpoon not found', vim.log.levels.WARN) return end local entry = oil.get_cursor_entry() if not entry or not entry.name then vim.notify('No valid entry selected in Oil', vim.log.levels.INFO) return end local full_path = oil.get_current_dir() .. entry.name local stat = vim.loop.fs_stat(full_path) if not stat or stat.type ~= 'file' then vim.notify('Selected entry is not a file: ' .. full_path, vim.log.levels.INFO) return end harpoon:list():add({ value = entry.name, context = { filename = entry.name, cwd = oil.get_current_dir() or 'global' }, }) end, { desc = 'Add selected file in oil.nvim to Harpoon' }) end, }