diff --git a/lua/plugins/oil.lua b/lua/plugins/oil.lua index 9533d48..669cd4b 100644 --- a/lua/plugins/oil.lua +++ b/lua/plugins/oil.lua @@ -1,25 +1,41 @@ return { - 'stevearc/oil.nvim', - opts = { - keymaps = { - ["g?"] = "actions.show_help", - [""] = "actions.select", - [""] = "actions.select_vsplit", - [""] = "actions.select_split", - [""] = "actions.select_tab", - [""] = false, - [""] = "actions.close", - [""] = "actions.refresh", - ["-"] = "actions.parent", - ["_"] = "actions.open_cwd", - ["`"] = "actions.cd", - ["~"] = "actions.tcd", - ["gs"] = "actions.change_sort", - ["gx"] = "actions.open_external", - ["g."] = "actions.toggle_hidden", - ["g\\"] = "actions.toggle_trash", - }, + { + "stevearc/oil.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + CustomOilBar = function() + local path = vim.fn.expand "%" + path = path:gsub("oil://", "") + + return " " .. vim.fn.fnamemodify(path, ":.") + end + + require("oil").setup { + columns = { "icon" }, + keymaps = { + ["g?"] = "actions.show_help", + [""] = "actions.select", + [""] = false, + [""] = "actions.close", + [""] = "actions.refresh", + ["-"] = "actions.parent", + ["_"] = "actions.open_cwd", + ["`"] = "actions.cd", + ["~"] = "actions.tcd", + ["gs"] = "actions.change_sort", + ["gx"] = "actions.open_external", + ["g."] = "actions.toggle_hidden", + }, + win_options = { + winbar = "%{v:lua.CustomOilBar()}", + }, + } + + -- Open parent directory in current window + vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory" }) + + -- Open parent directory in floating window + vim.keymap.set("n", "-", require("oil").toggle_float) + end, }, - -- Optional dependencies - dependencies = { "nvim-tree/nvim-web-devicons" }, }