nvim/lua/plugins/oil.lua
2024-11-09 00:27:51 +01:00

41 lines
1 KiB
Lua

return {
{
"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",
["<CR>"] = "actions.select",
["<C-p>"] = false,
["<C-c>"] = "actions.close",
["<C-l>"] = "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", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" })
-- Open parent directory in floating window
vim.keymap.set("n", "<space>-", require("oil").toggle_float)
end,
},
}