local puk = require 'std.puk' local map = require 'std.map' local icon = require 'std.icon' local oil = puk 'oil' -- Declare a global function to retrieve the current directory function _G.get_oil_winbar() local dir = require("oil").get_current_dir() if dir then return vim.fn.fnamemodify(dir, ":~") else -- If there is no current directory (e.g. over ssh), just show the buffer name return vim.api.nvim_buf_get_name(0) end end oil.setup { default_file_explorer = true, -- Set to true to watch the filesystem for changes and reload oil watch_for_changes = true, skip_confirm_for_simple_edits = true, prompt_save_on_select_new_entry = false, delete_to_trash = true, columns = { 'icon' }, win_options = { wrap = true, cursorline = true, -- show CWD in winbar. needs global function, see above winbar = "%!v:lua.get_oil_winbar()", }, keymaps = { ['q'] = 'actions.close', [''] = 'actions.select_vsplit', [''] = 'actions.select_split', ['`'] = 'actions.tcd', ['~'] = 'edit $HOME', }, float = { max_width = 69, min_width = 69, border = vim.g.border_style, padding = 2, }, -- Configuration for the floating action confirmation window confirmation = { border = vim.g.border_style, }, -- Configuration for the floating progress window progress = { border = vim.g.border_style, }, -- Configuration for the floating SSH window ssh = { border = vim.g.border_style, }, -- Configuration for the floating keymaps help window keymaps_help = { border = vim.g.border_style, }, view_options = { show_hidden = true, natural_order = true, is_always_hidden = function(name) return name == '..' end, }, } map.normal { description = 'Open parent directory in buffer.', category = 'files', keys = '-', command = oil.open, }