aboutsummaryrefslogtreecommitdiffstats
path: root/plugin/50-oil.lua
blob: 142a65bc6dc61a058dcb80d1d557ec8fb3862812 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
--[[ 50-oil.lua — file explorer that edits the filesystem like a buffer (oil.nvim).

Replaces netrw's local directory browsing (`default_file_explorer`); netrw's remote handlers
(ftp://, scp://, …) live in a separate autocmd group and keep working. Deletions go to the
freedesktop trash rather than being removed permanently.

Global keymaps:
`-`      open the parent directory in the current window
`<M-e>`  toggle oil in a floating window

Keymaps inside an oil buffer (merged with oil's defaults):
`<M-n>`        open the entry under the cursor in a horizontal split
`<M-v>`        open the entry under the cursor in a vertical split
`<C-w><C-p>`,
`<C-w>p`       preview the entry under the cursor in a horizontal split
]]

local oil = require("oil")

oil.setup({
	default_file_explorer = true,
	delete_to_trash = true,
	columns = { "icon", "permissions", "size", "mtime" },
	view_options = { show_hidden = true },
	keymaps = {
		["<C-s>"] = false,
		["<M-n>"] = { "actions.select", opts = { horizontal = true } },
		["<M-v>"] = { "actions.select", opts = { vertical = true } },
		["<C-w><C-p>"] = { "actions.preview", opts = { horizontal = true } },
		["<C-w>p"] = { "actions.preview", opts = { horizontal = true } },
	},
})

vim.keymap.set("n", "-", "<Cmd>Oil<CR>", { desc = "Open parent directory (oil)" })
vim.keymap.set("n", "<M-e>", oil.toggle_float, { desc = "Toggle oil (floating)" })