### Install oil.nvim with lazy.nvim Source: https://context7.com/stevearc/oil.nvim/llms.txt Minimal setup using lazy.nvim. Sets oil as the default file explorer and maps '-' to open the parent directory. Lazy loading is not recommended. ```lua -- lazy.nvim plugin spec { "stevearc/oil.nvim", --@module 'oil' --@type oil.SetupOpts opts = {}, dependencies = { { "nvim-mini/mini.icons", opts = {} } }, -- Lazy loading is NOT recommended lazy = false, config = function() require("oil").setup() -- vim-vinegar style: open parent directory of current file vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory" }) end, } ``` -------------------------------- ### setup(opts) Source: https://github.com/stevearc/oil.nvim/blob/master/doc/api.md Initialize oil.nvim with the provided options. ```APIDOC ## setup(opts) ### Description Initialize oil. ### Parameters #### opts - **opts** (oil.setupOpts|nil) - Optional - Setup options for oil.nvim. ``` -------------------------------- ### setup Source: https://github.com/stevearc/oil.nvim/blob/master/README.md Sets up the oil.nvim plugin with custom options. ```APIDOC ## setup(opts) ### Description Sets up the oil.nvim plugin with custom options. ### Parameters #### Path Parameters - **opts** (table) - Optional - A table of configuration options. ``` -------------------------------- ### Install oil.nvim with Paq Source: https://github.com/stevearc/oil.nvim/blob/master/README.md Installation snippet for oil.nvim using the Paq plugin manager. ```lua require("paq")({ { "stevearc/oil.nvim" }, }) ``` -------------------------------- ### Install oil.nvim with vim-plug Source: https://github.com/stevearc/oil.nvim/blob/master/README.md Add this line to your vim-plug configuration to install oil.nvim. ```vim Plug 'stevearc/oil.nvim' ``` -------------------------------- ### Install oil.nvim with Packer Source: https://github.com/stevearc/oil.nvim/blob/master/README.md Configuration for installing oil.nvim using the Packer plugin manager. It includes a call to require('oil').setup(). ```lua require("packer").startup(function() use({ "stevearc/oil.nvim", config = function() require("oil").setup() end, }) end) ``` -------------------------------- ### Setup Oil.nvim Configuration Source: https://github.com/stevearc/oil.nvim/blob/master/doc/oil.txt Configure oil.nvim by setting up default file explorer behavior, columns to display, buffer and window local options, trash integration, and confirmation skip settings. This setup is essential for enabling oil as the default directory buffer handler. ```lua require("oil").setup({ -- Oil will take over directory buffers (e.g. `vim .` or `:e src/`) -- Set to false if you want some other plugin (e.g. netrw) to open when you edit directories. default_file_explorer = true, -- Id is automatically added at the beginning, and name at the end -- See :help oil-columns columns = { "icon", -- "permissions", -- "size", -- "mtime", }, -- Buffer-local options to use for oil buffers buf_options = { buflisted = false, bufhidden = "hide", }, -- Window-local options to use for oil buffers win_options = { wrap = false, signcolumn = "no", cursorcolumn = false, foldcolumn = "0", spell = false, list = false, conceallevel = 3, concealcursor = "nvic", }, -- Send deleted files to the trash instead of permanently deleting them (:help oil-trash) delete_to_trash = false, -- Skip the confirmation popup for simple operations (:help oil.skip_confirm_for_simple_edits) skip_confirm_for_simple_edits = false, -- Selecting a new/moved/renamed file or directory will prompt you to save changes first -- (:help prompt_save_on_select_new_entry) prompt_save_on_select_new_entry = true, -- Oil will automatically delete hidden buffers after this delay -- You can set the delay to false to disable cleanup entirely -- Note that the cleanup process only starts when none of the oil buffers are currently displayed cleanup_delay_ms = 2000, lsp_file_methods = { -- Enable or disable LSP file operations enabled = true, -- Time to wait for LSP file operations to complete before skipping timeout_ms = 1000, -- Set to true to autosave buffers that are updated with LSP willRenameFiles -- Set to "unmodified" to only save unmodified buffers autosave_changes = false, }, -- Constrain the cursor to the editable parts of the oil buffer -- Set to `false` to disable, or "name" to keep it on the file names constrain_cursor = "editable", -- Set to true to watch the filesystem for changes and reload oil watch_for_changes = false, -- Keymaps in oil buffer. Can be any value that `vim.keymap.set` accepts OR a table of keymap -- options with a `callback` (e.g. { callback = function() ... end, desc = "", mode = "n" }) -- Additionally, if it is a string that matches "actions.", -- it will use the mapping at require("oil.actions"). -- Set to `false` to remove a keymap -- See :help oil-actions for a list of all available actions keymaps = { ["g?"] = { "actions.show_help", mode = "n" }, [""] = "actions.select", [""] = { "actions.select", opts = { vertical = true } }, [""] = { "actions.select", opts = { horizontal = true } }, [""] = { "actions.select", opts = { tab = true } }, [""] = "actions.preview", [""] = { "actions.close", mode = "n" }, [""] = "actions.refresh", ["-"] = { "actions.parent", mode = "n" }, ["_"] = { "actions.open_cwd", mode = "n" }, ["`"] = { "actions.cd", mode = "n" }, ["g~"] = { "actions.cd", opts = { scope = "tab" }, mode = "n" }, ["gs"] = { "actions.change_sort", mode = "n" }, ["gx"] = "actions.open_external", ["g."] = { "actions.toggle_hidden", mode = "n" }, ["g\\"] = { "actions.toggle_trash", mode = "n" }, }, -- Set to false to disable all of the above keymaps use_default_keymaps = true, view_options = { -- Show files and directories that start with "." show_hidden = false, -- This function defines what is considered a "hidden" file is_hidden_file = function(name, bufnr) local m = name:match("^%.%") return m ~= nil end, }, }) ``` -------------------------------- ### Install oil.nvim with lazy.nvim Source: https://github.com/stevearc/oil.nvim/blob/master/README.md Use this configuration for installing oil.nvim with the lazy.nvim plugin manager. It includes optional dependencies for icons. ```lua { 'stevearc/oil.nvim', ---@module 'oil' ---@type oil.SetupOpts opts = {}, -- Optional dependencies dependencies = { { "nvim-mini/mini.icons", opts = {} } }, -- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if you prefer nvim-web-devicons -- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations. lazy = false, } ``` -------------------------------- ### Initialize oil.nvim with Configuration Source: https://context7.com/stevearc/oil.nvim/llms.txt Call `setup()` with a table of options to configure oil.nvim. This must be done before using any other oil API. Options control aspects like columns, keymaps, and file handling. ```lua require("oil").setup({ -- Replace netrw as the default directory browser default_file_explorer = true, -- Columns shown in the buffer (id is always prepended, name always appended) columns = { "icon", "permissions", "size", "mtime" }, -- Send deleted files to trash instead of permanently deleting delete_to_trash = true, -- Skip confirmation popup for simple single-file edits skip_confirm_for_simple_edits = false, -- LSP willRenameFiles / didRenameFiles integration lsp_file_methods = { enabled = true, timeout_ms = 1000, autosave_changes = "unmodified", -- or true / false }, -- Watch filesystem for external changes and auto-reload watch_for_changes = true, -- EXPERIMENTAL: auto-use git mv / rm / add git = { add = function(path) return true end, mv = function(src, dest) return true end, rm = function(path) return true end, }, -- Customize sort: directories first, then by size descending view_options = { show_hidden = false, natural_order = "fast", case_insensitive = false, sort = { { "type", "asc" }, { "size", "desc" }, }, is_hidden_file = function(name, bufnr) return vim.startswith(name, ".") end, is_always_hidden = function(name, bufnr) return name == ".DS_Store" end, -- Custom filename highlight highlight_filename = function(entry, is_hidden, is_link_target, is_link_orphan) if is_link_orphan then return "DiagnosticError" end end, }, -- Floating window configuration float = { padding = 2, max_width = 0.6, -- 60% of screen width max_height = 0.8, border = "rounded", win_options = { winblend = 10 }, preview_split = "right", override = function(conf) -- Fine-tune nvim_open_win config conf.anchor = "NW" return conf end, }, -- Preview window behavior preview_win = { update_on_cursor_moved = true, preview_method = "fast_scratch", disable_preview = function(filename) -- Disable preview for very large files or binaries return filename:match("%.sqlite3$") ~= nil end, }, -- Default keymaps (subset shown) keymaps = { ["g?"] = { "actions.show_help", mode = "n" }, [""] = "actions.select", [""] = { "actions.select", opts = { vertical = true } }, [""] = { "actions.select", opts = { horizontal = true } }, [""] = { "actions.select", opts = { tab = true } }, [""] = "actions.preview", [""] = { "actions.close", mode = "n" }, [""] = "actions.refresh", ["-"] = { "actions.parent", mode = "n" }, ["_"] = { "actions.open_cwd", mode = "n" }, ["`"] = { "actions.cd", mode = "n" }, ["g~"] = { "actions.cd", opts = { scope = "tab" }, mode = "n" }, ["gs"] = { "actions.change_sort", mode = "n" }, ["gx"] = "actions.open_external", ["g."] = { "actions.toggle_hidden", mode = "n" }, ["g\\"] = { "actions.toggle_trash", mode = "n" }, }, }) ``` -------------------------------- ### Basic oil.nvim setup Source: https://github.com/stevearc/oil.nvim/blob/master/README.md Add this line to your init.lua to set up oil.nvim with default options. This enables the file explorer functionality. ```lua require("oil").setup() ``` -------------------------------- ### Install oil.nvim with Pathogen Source: https://github.com/stevearc/oil.nvim/blob/master/README.md Clone the oil.nvim repository into your bundle directory for Pathogen installation. ```sh git clone --depth=1 https://github.com/stevearc/oil.nvim.git ~/.vim/bundle/ ``` -------------------------------- ### Install oil.nvim with dein Source: https://github.com/stevearc/oil.nvim/blob/master/README.md Command to add oil.nvim using the dein plugin manager. ```vim call dein#add('stevearc/oil.nvim') ``` -------------------------------- ### Install oil.nvim with Neovim native package Source: https://github.com/stevearc/oil.nvim/blob/master/README.md Install oil.nvim using Neovim's built-in package manager. This command clones the repository to the standard Neovim site-pack directory. ```sh git clone --depth=1 https://github.com/stevearc/oil.nvim.git \ "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/pack/oil/start/oil.nvim ``` -------------------------------- ### Setup Resession Extension Source: https://context7.com/stevearc/oil.nvim/llms.txt Integrate oil.nvim with resession.nvim to save and restore oil buffer state across sessions. No extra configuration is typically needed for the oil extension. ```lua require("resession").setup({ extensions = { oil = { -- no extra config needed }, }, }) ``` -------------------------------- ### Open oil.nvim in a Floating Window Source: https://context7.com/stevearc/oil.nvim/llms.txt Use `oil.open_float()` to open the file browser in a floating window. The layout is controlled by `setup()`'s `float` options, but can be overridden per-call. A callback can be provided. ```lua local oil = require("oil") -- Float over the current file's directory oil.open_float() -- Float for a specific path with a preview split oil.open_float("/var/log", { preview = { horizontal = true } }, function() print("Floating oil opened at: " .. (oil.get_current_dir() or "unknown")) end) ``` -------------------------------- ### open_float(dir, opts, cb) Source: https://context7.com/stevearc/oil.nvim/llms.txt Opens the oil file browser in a floating window. The layout and behavior of the floating window can be configured via setup options or overridden on a per-call basis. ```APIDOC ## `open_float(dir, opts, cb)` ### Description Opens the oil file browser in a floating window. The floating window layout is controlled by the `float` section of the setup config and can be further overridden per-call. ### Parameters - `dir` (string, optional): The directory to open in the floating window. Defaults to the parent directory or cwd. - `opts` (table, optional): Options to configure the floating window, including preview splits. - `cb` (function, optional): A callback function executed when the floating oil buffer is ready. ### Request Example ```lua local oil = require("oil") -- Float over the current file's directory oil.open_float() -- Float for a specific path with a preview split oil.open_float("/var/log", { preview = { horizontal = true } }, function() print("Floating oil opened at: " .. (oil.get_current_dir() or "unknown")) end) ``` ``` -------------------------------- ### Get Cursor Entry Information Source: https://context7.com/stevearc/oil.nvim/llms.txt Returns the oil.Entry table for the file or directory under the cursor. Useful for conditional actions based on entry type. ```lua local oil = require("oil") -- Inspect the entry under the cursor local entry = oil.get_cursor_entry() if entry then print(string.format( "name=%s type=%s id=%d", entry.name, entry.type, entry.id )) -- Example output: name=README.md type=file id=42 end -- Conditionally act only on directories local entry = oil.get_cursor_entry() if entry and entry.type == "directory" then oil.select() -- navigate into it end ``` -------------------------------- ### oil.setup Source: https://github.com/stevearc/oil.nvim/blob/master/doc/oil.txt Initializes the oil plugin with provided options. ```APIDOC ## oil.setup ### Description Initializes the oil plugin with configuration options. ### Parameters - **opts** (`oil.setupOpts|nil`): Table of options for configuring oil. ``` -------------------------------- ### actions.show_help Source: https://github.com/stevearc/oil.nvim/blob/master/doc/oil.txt Shows the default keymaps for oil.nvim. ```APIDOC ## actions.show_help ### Description Show default keymaps. ``` -------------------------------- ### Configure Preview Window Method Source: https://github.com/stevearc/oil.nvim/blob/master/doc/oil.txt Specify the method used to open the preview window. Options are "load", "scratch", or "fast_scratch". ```lua -- How to open the preview window "load"|"scratch"|"fast_scratch" preview_method = "fast_scratch", ``` -------------------------------- ### Configure Preview Window Local Options Source: https://github.com/stevearc/oil.nvim/blob/master/doc/oil.txt Set window-local options that will be applied to preview window buffers. ```lua -- Window-local options to use for preview window buffers win_options = {}, } ``` -------------------------------- ### get_current_dir Source: https://github.com/stevearc/oil.nvim/blob/master/README.md Gets the current working directory of the oil buffer. ```APIDOC ## get_current_dir(bufnr) ### Description Gets the current working directory of the oil buffer. ### Parameters #### Path Parameters - **bufnr** (number) - Required - The buffer number. ### Returns - (string) - The current working directory. ``` -------------------------------- ### Configure Keymaps in oil.nvim Source: https://github.com/stevearc/oil.nvim/blob/master/doc/oil.txt The `keymaps` option in `oil.setup` allows defining custom mappings. Mappings can be simple strings, functions, or tables with additional options like `mode` and `desc`. Actions can be referenced by string or called directly. ```lua keymaps = { -- Mappings can be a string ["~"] = "edit $HOME", -- Mappings can be a function ["gd"] = function() require("oil").set_columns({ "icon", "permissions", "size", "mtime" }) end, -- You can pass additional opts to vim.keymap.set by using -- a table with the mapping as the first element. ["ff"] = { function() require("telescope.builtin").find_files({ cwd = require("oil").get_current_dir() }) end, mode = "n", nowait = true, desc = "Find files in the current directory" }, -- Mappings that are a string starting with "actions." will be -- one of the built-in actions, documented below. ["`"] = "actions.tcd", -- Some actions have parameters. These are passed in via the `opts` key. [":"] = { "actions.open_cmdline", opts = { shorten_path = true, modify = ":h", }, desc = "Open the command line with the current directory as an argument", }, } ``` -------------------------------- ### get_cursor_entry Source: https://github.com/stevearc/oil.nvim/blob/master/README.md Gets the file entry information for the line the cursor is currently on. ```APIDOC ## get_cursor_entry() ### Description Gets the file entry information for the line the cursor is currently on. ### Returns - (table) - The file entry information. ``` -------------------------------- ### Configure Oil File Preview Window Source: https://github.com/stevearc/oil.nvim/blob/master/README.md Set up the file preview window behavior, including automatic updates on cursor movement, the method for previewing files, and options to disable preview for specific files or configure window-local options. ```lua preview_win = { -- Whether the preview window is automatically updated when the cursor is moved update_on_cursor_moved = true, -- How to open the preview window "load"|"scratch"|"fast_scratch" preview_method = "fast_scratch", -- A function that returns true to disable preview on a file e.g. to avoid lag disable_preview = function(filename) return false end, -- Window-local options to use for preview window buffers win_options = {}, } ``` -------------------------------- ### Get Entry on Specific Line Source: https://context7.com/stevearc/oil.nvim/llms.txt Returns the oil.Entry for a specific line number in an oil buffer. Useful for scripting operations on multiple entries. ```lua local oil = require("oil") -- Iterate all entries in the current oil buffer local bufnr = vim.api.nvim_get_current_buf() local line_count = vim.api.nvim_buf_line_count(bufnr) for lnum = 1, line_count do local entry = oil.get_entry_on_line(bufnr, lnum) if entry then print(lnum .. ": " .. entry.name .. " (" .. entry.type .. ")") end end -- Example output: -- 1: .gitignore (file) -- 2: lua/ (directory) -- 3: README.md (file) ``` -------------------------------- ### open_preview(opts, callback) Source: https://context7.com/stevearc/oil.nvim/llms.txt Opens a preview split for the entry under the cursor, with options to control split direction and receive a callback when the preview is ready. ```APIDOC ## `open_preview(opts, callback)` Opens a preview split for the entry under the cursor. The split direction can be controlled, and a callback is invoked once the preview window is ready. ### Parameters #### Options (`opts`) - `vertical` (boolean) - Optional - If true, opens the preview in a vertical split. - `split` (string) - Optional - Specifies the split direction (e.g., "belowright", "rightbelow"). #### Callback (`callback`) - `err` (string) - An error message if an error occurred during preview opening. ### Request Example ```lua local oil = require("oil") -- Preview in an automatic split oil.open_preview() -- Preview in a right-side vertical split oil.open_preview({ vertical = true, split = "belowright" }, function(err) if err then vim.notify("Preview error: " .. err, vim.log.levels.WARN) end end) ``` ``` -------------------------------- ### Get Current Oil Buffer Directory Source: https://context7.com/stevearc/oil.nvim/llms.txt Returns the current directory path for an oil buffer. Returns nil for non-local buffers. Can be used in winbar configuration. ```lua local oil = require("oil") -- Get directory of the current window's oil buffer local dir = oil.get_current_dir() if dir then print("Currently browsing: " .. dir) end -- Get directory of a specific buffer local dir2 = oil.get_current_dir(5) -- Use in winbar to show current path function _G.get_oil_winbar() local bufnr = vim.api.nvim_win_get_buf(vim.g.statusline_winid) local dir = require("oil").get_current_dir(bufnr) if dir then return vim.fn.fnamemodify(dir, ":~ ") else return vim.api.nvim_buf_get_name(0) end end require("oil").setup({ win_options = { winbar = "%!v:lua.get_oil_winbar()" }, }) ``` -------------------------------- ### Configure Oil Keymaps Help Window Source: https://github.com/stevearc/oil.nvim/blob/master/README.md Define the border style for the floating window that displays keymap help. ```lua keymaps_help = { border = nil, } ``` -------------------------------- ### actions.send_to_qflist Source: https://github.com/stevearc/oil.nvim/blob/master/doc/oil.txt Sends files in the current oil directory to the quickfix list, replacing or adding to existing entries. Can optionally only add files matching the last search. ```APIDOC ## actions.send_to_qflist ### Description Sends files in the current oil directory to the quickfix list, replacing the previous entries. ### Parameters #### Path Parameters - **{action}** (string) - Optional - Replace or add to current quickfix list (`"r"|"a"`) - **{only_matching_search}** (boolean) - Optional - Whether to only add the files that matches the last search. This option only applies when search highlighting is active - **{target}** (string) - Optional - The target list to send files to (`"qflist"|"loclist"`) ``` -------------------------------- ### Configure Oil.nvim Plugin Source: https://github.com/stevearc/oil.nvim/blob/master/README.md Use this snippet to set up oil.nvim with custom options. It controls how directory buffers are handled, which columns are displayed, buffer-local and window-local options, trash integration, and LSP file operation settings. ```lua require("oil").setup({ -- Oil will take over directory buffers (e.g. `vim .` or `:e src/`) -- Set to false if you want some other plugin (e.g. netrw) to open when you edit directories. default_file_explorer = true, -- Id is automatically added at the beginning, and name at the end -- See :help oil-columns columns = { "icon", -- "permissions", -- "size", -- "mtime", }, -- Buffer-local options to use for oil buffers buf_options = { buflisted = false, bufhidden = "hide", }, -- Window-local options to use for oil buffers win_options = { wrap = false, signcolumn = "no", cursorcolumn = false, foldcolumn = "0", spell = false, list = false, conceallevel = 3, concealcursor = "nvic", }, -- Send deleted files to the trash instead of permanently deleting them (:help oil-trash) delete_to_trash = false, -- Skip the confirmation popup for simple operations (:help oil.skip_confirm_for_simple_edits) skip_confirm_for_simple_edits = false, -- Selecting a new/moved/renamed file or directory will prompt you to save changes first -- (:help prompt_save_on_select_new_entry) prompt_save_on_select_new_entry = true, -- Oil will automatically delete hidden buffers after this delay -- You can set the delay to false to disable cleanup entirely -- Note that the cleanup process only starts when none of the oil buffers are currently displayed cleanup_delay_ms = 2000, lsp_file_methods = { -- Enable or disable LSP file operations enabled = true, -- Time to wait for LSP file operations to complete before skipping timeout_ms = 1000, -- Set to true to autosave buffers that are updated with LSP willRenameFiles -- Set to "unmodified" to only save unmodified buffers autosave_changes = false, }, -- Constrain the cursor to the editable parts of the oil buffer -- Set to `false` to disable, or "name" to keep it on the file names constrain_cursor = "editable", -- Set to true to watch the filesystem for changes and reload oil watch_for_changes = false, -- Keymaps in oil buffer. Can be any value that `vim.keymap.set` accepts OR a table of keymap -- options with a `callback` (e.g. { callback = function() ... end, desc = "", mode = "n" }) -- Additionally, if it is a string that matches "actions.", -- it will use the mapping at require("oil.actions"). -- Set to `false` to remove a keymap -- See :help oil-actions for a list of all available actions keymaps = { ["g?"] = { "actions.show_help", mode = "n" }, [""] = "actions.select", [""] = { "actions.select", opts = { vertical = true } }, [""] = { "actions.select", opts = { horizontal = true } }, [""] = { "actions.select", opts = { tab = true } }, [""] = "actions.preview", [""] = { "actions.close", mode = "n" }, [""] = "actions.refresh", ["-"] = { "actions.parent", mode = "n" }, ["_"] = { "actions.open_cwd", mode = "n" }, ["`"] = { "actions.cd", mode = "n" }, ["g~"] = { "actions.cd", opts = { scope = "tab" }, mode = "n" }, ["gs"] = { "actions.change_sort", mode = "n" }, ["gx"] = "actions.open_external", ["g."] = { "actions.toggle_hidden", mode = "n" }, ["g\\"] = { "actions.toggle_trash", mode = "n" }, }, -- Set to false to disable all of the above keymaps use_default_keymaps = true, view_options = { -- Show files and directories that start with "." show_hidden = false, -- This function defines what is considered a "hidden" file is_hidden_file = function(name, bufnr) local m = name:match("^%.") return m ~= nil end, -- This function defines what will never be shown, even when `show_hidden` is set is_always_hidden = function(name, bufnr) return false end, -- Sort file names with numbers in a more intuitive order for humans. -- Can be "fast", true, or false. "fast" will turn it off for large directories. natural_order = "fast", -- Sort file and directory names case insensitive case_insensitive = false, sort = { -- sort order can be "asc" or "desc" -- see :help oil-columns to see which columns are sortable { "type", "asc" }, { "name", "asc" }, }, -- Customize the highlight group for the file name highlight_filename = function(entry, is_hidden, is_link_target, is_link_orphan) return nil end, }, -- Extra arguments to pass to SCP when moving/copying files over SSH extra_scp_args = {}, -- Extra arguments to pass to aws s3 when creating/deleting/moving/copying files using aws s3 extra_s3_args = {}, -- EXPERIMENTAL support for performing file operations with git git = { -- Return true to automatically git add/mv/rm files add = function(path) return false end, mv = function(src_path, dest_path) return false end, rm = function(path) return false end, }, }) ``` -------------------------------- ### Configure Trash Adapter Source: https://context7.com/stevearc/oil.nvim/llms.txt Enable the trash adapter to move deleted files to the system trash instead of permanently removing them. Use the `toggle_trash` action to switch between normal and trash views. ```lua require("oil").setup({ delete_to_trash = true, keymaps = { -- Toggle between normal and trash view ["g\"] = { "actions.toggle_trash", mode = "n" }, }, }) -- Restore a trashed file: open trash view, rename it to move it back -- :Oil oil-trash:///home/user/projects ``` -------------------------------- ### oil.open_preview Source: https://github.com/stevearc/oil.nvim/blob/master/doc/oil.txt Previews the entry under the cursor in a split window. ```APIDOC ## oil.open_preview ### Description Opens a preview window for the entry under the cursor. ### Parameters - **opts** (`nil|oil.OpenPreviewOpts`): Options for the preview window. - **vertical** (`nil|boolean`): Open the preview buffer in a vertical split. - **horizontal** (`nil|boolean`): Open the preview buffer in a horizontal split. - **split** (`nil|'aboveleft'|'belowright'|'topleft'|'botright'`): Split modifier for the preview window. - **callback** (`nil|fun(err: nil|string)`): Called once the preview window has been opened. ``` -------------------------------- ### Configure Keymaps Help Floating Window Border Source: https://github.com/stevearc/oil.nvim/blob/master/doc/oil.txt Set the border style for the keymaps help floating window. ```lua keymaps_help = { border = nil, }, ``` -------------------------------- ### Configure Floating Window Options Source: https://github.com/stevearc/oil.nvim/blob/master/doc/oil.txt Set window-local options for the floating window, such as `winblend`. ```lua win_options = { winblend = 0, }, ``` -------------------------------- ### select Source: https://github.com/stevearc/oil.nvim/blob/master/README.md Selects a file or directory. ```APIDOC ## select(opts, callback) ### Description Selects a file or directory. ### Parameters #### Path Parameters - **opts** (table) - Optional - Options for the selection. - **callback** (function) - Optional - A callback function to execute after selection. ``` -------------------------------- ### open_preview Source: https://github.com/stevearc/oil.nvim/blob/master/doc/api.md Previews the entry under the cursor in a split window. ```APIDOC ## open_preview(opts, callback) ### Description Preview the entry under the cursor in a split. ### Parameters #### Path Parameters - **opts** (nil|oil.OpenPreviewOpts) - Optional - **vertical** (nil|boolean) - Optional - Open the buffer in a vertical split. - **horizontal** (nil|boolean) - Optional - Open the buffer in a horizontal split. - **split** (nil|'aboveleft'|'belowright'|'topleft'|'botright') - Optional - Split modifier. - **callback** (nil|fun(err: nil|string)) - Optional - Called once the preview window has been opened. ``` -------------------------------- ### open_preview Source: https://github.com/stevearc/oil.nvim/blob/master/README.md Opens a preview window for the selected file. ```APIDOC ## open_preview(opts, callback) ### Description Opens a preview window for the selected file. ### Parameters #### Path Parameters - **opts** (table) - Optional - Options for the preview window. - **callback** (function) - Optional - A callback function to execute after opening the preview. ``` -------------------------------- ### open(dir, opts, cb) Source: https://context7.com/stevearc/oil.nvim/llms.txt Opens the oil file browser for a specified directory in the current window. If no directory is provided, it opens the parent directory of the current buffer or the current working directory. ```APIDOC ## `open(dir, opts, cb)` ### Description Opens the oil file browser for the specified directory in the current window. When `dir` is `nil`, opens the parent of the current buffer (or `cwd` if the buffer is not a file). Accepts optional `opts` to open a preview split alongside the browser. ### Parameters - `dir` (string, optional): The directory to open. If nil, the parent directory or cwd is used. - `opts` (table, optional): Options to configure the opening behavior, such as preview split. - `cb` (function, optional): A callback function to be executed when the oil buffer is ready. ### Request Example ```lua local oil = require("oil") -- Open current file's parent directory oil.open() -- Open a specific directory oil.open("/home/user/projects") -- Open with a vertical preview pane, callback when ready oil.open("~/src", { preview = { vertical = true } }, function() vim.notify("oil buffer ready: " .. oil.get_current_dir()) end) -- Open oil in a horizontal split positioned at the top oil.open(nil, { preview = { split = "aboveleft" } }) ``` ``` -------------------------------- ### open Source: https://github.com/stevearc/oil.nvim/blob/master/README.md Opens an oil file explorer. ```APIDOC ## open(dir, opts, cb) ### Description Opens an oil file explorer. ### Parameters #### Path Parameters - **dir** (string) - Optional - The directory to open. - **opts** (table) - Optional - Options for the file explorer. - **cb** (function) - Optional - A callback function to execute after opening. ``` -------------------------------- ### open Source: https://github.com/stevearc/oil.nvim/blob/master/doc/api.md Opens the oil browser for a specified directory. ```APIDOC ## open(dir, opts, cb) ### Description Open oil browser for a directory. ### Parameters #### Path Parameters - **dir** (nil|string) - Optional - When nil, open the parent of the current buffer, or the cwd if current buffer is not a file. - **opts** (nil|oil.OpenOpts) - Optional - **preview** (nil|oil.OpenPreviewOpts) - Optional - When present, open the preview window after opening oil. - **vertical** (nil|boolean) - Optional - Open the buffer in a vertical split. - **horizontal** (nil|boolean) - Optional - Open the buffer in a horizontal split. - **split** (nil|'aboveleft'|'belowright'|'topleft'|'botright') - Optional - Split modifier. - **cb** (nil|fun()) - Optional - Called after the oil buffer is ready. ``` -------------------------------- ### actions.select Source: https://github.com/stevearc/oil.nvim/blob/master/doc/oil.txt Opens the entry under the cursor. Supports closing the original buffer, opening in splits, new tabs, and using split modifiers. ```APIDOC ## actions.select ### Description Open the entry under the cursor. ### Parameters #### Path Parameters - **{close}** (boolean) - Optional - Close the original oil buffer once selection is made - **{horizontal}** (boolean) - Optional - Open the buffer in a horizontal split - **{split}** (string) - Optional - Split modifier (`"aboveleft"|"belowright"|"topleft"|"botright"`) - **{tab}** (boolean) - Optional - Open the buffer in a new tab - **{vertical}** (boolean) - Optional - Open the buffer in a vertical split ``` -------------------------------- ### Configure Skipping Confirmation for Simple Edits Source: https://github.com/stevearc/oil.nvim/blob/master/doc/oil.txt Set to `true` to automatically skip confirmation prompts for simple file edits. ```lua skip_confirm_for_simple_edits = false, ``` -------------------------------- ### Configure Oil Floating Window Options Source: https://github.com/stevearc/oil.nvim/blob/master/README.md Customize the appearance and behavior of the floating window used by `oil.open_float`. Options include padding, maximum dimensions, border styles, and window-specific options. ```lua float = { -- Padding around the floating window padding = 2, -- max_width and max_height can be integers or a float between 0 and 1 (e.g. 0.4 for 40%) max_width = 0, max_height = 0, border = nil, win_options = { winblend = 0, }, -- optionally override the oil buffers window title with custom function: fun(winid: integer): string get_win_title = nil, -- preview_split: Split direction: "auto", "left", "right", "above", "below". preview_split = "auto", -- This is the config that will be passed to nvim_open_win. -- Change values here to customize the layout override = function(conf) return conf end, } ``` -------------------------------- ### oil.open Source: https://context7.com/stevearc/oil.nvim/llms.txt Opens a specified path, supporting various adapters like SSH and S3. ```APIDOC ## `open(path)` Opens a specified path, supporting various adapters like SSH and S3. ### Parameters * **path** (string) - The path to open. Can be a local path or a URL for adapters like `oil-ssh://` or `oil-s3://`. ### Request Example ```lua local oil = require("oil") -- Open oil over SSH oil.open("oil-ssh://deploy@prod.example.com:2222/var/www/html") -- Open oil in an S3 bucket oil.open("oil-s3://my-bucket/data/2024/") ``` ``` -------------------------------- ### actions.parent Source: https://github.com/stevearc/oil.nvim/blob/master/doc/oil.txt Navigates to the parent path. ```APIDOC ## actions.parent ### Description Navigate to the parent path. ``` -------------------------------- ### Open oil.nvim File Browser Source: https://context7.com/stevearc/oil.nvim/llms.txt Use `oil.open()` to open the file browser in the current window. It can open the parent directory of the current buffer or a specified directory. Optional `opts` can configure a preview split. ```lua local oil = require("oil") -- Open current file's parent directory oil.open() -- Open a specific directory oil.open("/home/user/projects") -- Open with a vertical preview pane, callback when ready oil.open("~/src", { preview = { vertical = true } }, function() vim.notify("oil buffer ready: " .. oil.get_current_dir()) end) -- Open oil in a horizontal split positioned at the top oil.open(nil, { preview = { split = "aboveleft" } }) ``` -------------------------------- ### Open Preview Split Source: https://context7.com/stevearc/oil.nvim/llms.txt Opens a preview split for the entry under the cursor. The split direction can be controlled, and a callback is invoked when the preview window is ready. ```lua local oil = require("oil") -- Preview in an automatic split oil.open_preview() -- Preview in a right-side vertical split oil.open_preview({ vertical = true, split = "belowright" }, function(err) if err then vim.notify("Preview error: " .. err, vim.log.levels.WARN) end end) ``` -------------------------------- ### actions.preview Source: https://github.com/stevearc/oil.nvim/blob/master/doc/oil.txt Opens the entry under the cursor in a preview window, or closes the preview window if already open. Supports horizontal and vertical splits. ```APIDOC ## actions.preview ### Description Open the entry under the cursor in a preview window, or close the preview window if already open. ### Parameters #### Path Parameters - **{horizontal}** (boolean) - Optional - Open the buffer in a horizontal split - **{split}** (string) - Optional - Split modifier (`"aboveleft"|"belowright"|"topleft"|"botright"`) - **{vertical}** (boolean) - Optional - Open the buffer in a vertical split ``` -------------------------------- ### actions.open_cmdline Source: https://github.com/stevearc/oil.nvim/blob/master/doc/oil.txt Opens the Vim command line with the current entry as an argument. Allows modification of the path using fnamemodify and shortening paths. ```APIDOC ## actions.open_cmdline ### Description Open vim cmdline with current entry as an argument. ### Parameters #### Path Parameters - **{modify}** (string) - Optional - Modify the path with |fnamemodify()| using this as the mods argument - **{shorten_path}** (boolean) - Optional - Use relative paths when possible ``` -------------------------------- ### actions.open_cwd Source: https://github.com/stevearc/oil.nvim/blob/master/doc/oil.txt Opens oil in Neovim's current working directory. ```APIDOC ## actions.open_cwd ### Description Open oil in Neovim's current working directory. ``` -------------------------------- ### actions.paste_from_system_clipboard Source: https://github.com/stevearc/oil.nvim/blob/master/doc/oil.txt Pastes the system clipboard into the current oil directory. Optionally deletes the original file after copying. ```APIDOC ## actions.paste_from_system_clipboard ### Description Paste the system clipboard into the current oil directory. ### Parameters #### Path Parameters - **{delete_original}** (boolean) - Optional - Delete the original file after copying ``` -------------------------------- ### open_float Source: https://github.com/stevearc/oil.nvim/blob/master/README.md Opens an oil file explorer in a floating window. ```APIDOC ## open_float(dir, opts, cb) ### Description Opens an oil file explorer in a floating window. ### Parameters #### Path Parameters - **dir** (string) - Optional - The directory to open. - **opts** (table) - Optional - Options for the floating window. - **cb** (function) - Optional - A callback function to execute after opening. ``` -------------------------------- ### Configure Confirmation Window Min Width Source: https://github.com/stevearc/oil.nvim/blob/master/doc/oil.txt Set the minimum width for the confirmation floating window. Supports a list of mixed integer/float types to define a range. ```lua -- min_width = {40, 0.4} means "the greater of 40 columns or 40% of total" min_width = { 40, 0.4 }, -- optionally define an integer/float for the exact width of the preview window width = nil, ``` -------------------------------- ### select(opts, callback) Source: https://github.com/stevearc/oil.nvim/blob/master/doc/api.md Select the entry under the cursor. This function allows for various options to control how the selected entry is opened, such as in a split, new tab, or with a custom buffer handling callback. ```APIDOC ## select(opts, callback) ### Description Select the entry under the cursor. ### Parameters #### opts - **vertical** (nil|boolean) - Optional - Open the buffer in a vertical split. - **horizontal** (nil|boolean) - Optional - Open the buffer in a horizontal split. - **split** (nil|'aboveleft'|'belowright'|'topleft'|'botright') - Optional - Split modifier. - **tab** (nil|boolean) - Optional - Open the buffer in a new tab. - **close** (nil|boolean) - Optional - Close the original oil buffer once selection is made. - **handle_buffer_callback** (nil|fun(buf_id: integer)) - Optional - If defined, all other buffer related options here would be ignored. This callback allows you to take over the process of opening the buffer yourself. #### callback - **callback** (nil|fun(err: nil|string)) - Optional - Called once all entries have been opened. ``` -------------------------------- ### Configure Oil SSH Window Source: https://github.com/stevearc/oil.nvim/blob/master/README.md Set the border style for the floating SSH connection window. ```lua ssh = { border = nil, } ``` -------------------------------- ### Select Entry Source: https://context7.com/stevearc/oil.nvim/llms.txt Opens the entry under the cursor in a split, new tab, or closes the oil buffer after selection. Supports custom buffer handling. ```lua local oil = require("oil") -- Open in a vertical split oil.select({ vertical = true }) -- Open in a new tab and close oil afterwards oil.select({ tab = true, close = true }, function(err) if err then vim.notify("select error: " .. err, vim.log.levels.ERROR) end end) -- Custom buffer handler — open in a new split below at 20% height oil.select({ handle_buffer_callback = function(buf_id) vim.cmd("belowright 20split") vim.api.nvim_set_current_buf(buf_id) end, }) ``` -------------------------------- ### oil.open_float Source: https://github.com/stevearc/oil.nvim/blob/master/doc/oil.txt Opens the oil file explorer in a floating window. ```APIDOC ## oil.open_float ### Description Open oil browser in a floating window ### Parameters #### Path Parameters - **dir** (nil|string) - Optional - When nil, open the parent of the current buffer, or the cwd if current buffer is not a file. - **opts** (nil|oil.OpenOpts) - Optional - Options for opening the float window. - **preview** (nil|oil.OpenPreviewOpts) - When present, open the preview window after opening oil. - **vertical** (nil|boolean) - Open the buffer in a vertical split. - **horizontal** (nil|boolean) - Open the buffer in a horizontal split. - **split** (nil|`"aboveleft"`|`"belowright"`|`"topleft"`|`"botright"`) - Split modifier. - **cb** (nil|fun()) - Optional - Called after the oil buffer is ready. ``` -------------------------------- ### oil.open Source: https://github.com/stevearc/oil.nvim/blob/master/doc/oil.txt Opens the oil file explorer for a specified directory. ```APIDOC ## oil.open ### Description Open oil browser for a directory ### Parameters #### Path Parameters - **dir** (nil|string) - Optional - When nil, open the parent of the current buffer, or the cwd if current buffer is not a file. - **opts** (nil|oil.OpenOpts) - Optional - Options for opening the oil browser. - **cb** (nil|fun()) - Optional - Called after the oil buffer is ready. ``` -------------------------------- ### Open Files Over SSH with oil.nvim Source: https://github.com/stevearc/oil.nvim/blob/master/README.md Use this format to open a buffer and browse files over SSH. Requires a server with standard Unix commands. ```vim nvim oil-ssh://[username@]hostname[:port]/[path] ```