diff --git a/doc/oil.txt b/doc/oil.txt index 2397207..999e1a8 100644 --- a/doc/oil.txt +++ b/doc/oil.txt @@ -1288,6 +1288,39 @@ the buffer renders. }) < + *oil-recipe-paste-file-from-clipboard* + +Copy a file into the current oil directory by pasting its absolute path from +the system clipboard. Useful on macOS where copying a file in Finder places its +path in the clipboard. +>lua + vim.keymap.set("n", "gp", function() + local oil = require("oil") + local dir = oil.get_current_dir() + if not dir then + return + end + local path = vim.fn.getreg("+"):gsub("\n$", "") + if path == "" or not vim.uv.fs_stat(path) then + vim.notify("Clipboard does not contain a valid file path", vim.log.levels.WARN) + return + end + local name = vim.fn.fnamemodify(path, ":t") + local dest = dir .. name + vim.uv.fs_copyfile(path, dest, function(err) + vim.schedule(function() + if err then + vim.notify("Copy failed: " .. err, vim.log.levels.ERROR) + else + local bufname = vim.api.nvim_buf_get_name(0) + require("oil.view").set_last_cursor(bufname, name) + require("oil.actions").refresh.callback() + end + end) + end) + end, { desc = "Paste file from clipboard path into oil directory" }) +< + -------------------------------------------------------------------------------- EVENTS *oil-events* diff --git a/doc/upstream.md b/doc/upstream.md index 24e7dc5..8c0cd47 100644 --- a/doc/upstream.md +++ b/doc/upstream.md @@ -37,7 +37,7 @@ issues against this fork. | [#85](https://github.com/stevearc/oil.nvim/issues/85) | Git status column | consolidated into [#121](https://github.com/barrettruth/canola.nvim/issues/121) | | [#95](https://github.com/stevearc/oil.nvim/issues/95) | Undo after renaming files | open | | [#117](https://github.com/stevearc/oil.nvim/issues/117) | Move file into new dir via slash in name | consolidated into [#32](https://github.com/barrettruth/canola.nvim/issues/32) | -| [#156](https://github.com/stevearc/oil.nvim/issues/156) | Paste path of files into oil buffer | open | +| [#156](https://github.com/stevearc/oil.nvim/issues/156) | Paste path of files into oil buffer | fixed — added `oil-recipe-paste-file-from-clipboard` | | [#200](https://github.com/stevearc/oil.nvim/issues/200) | Highlights not working when opening a file | not actionable — cannot reproduce, nvim 0.9.4 | | [#207](https://github.com/stevearc/oil.nvim/issues/207) | Suppress "no longer available" message | fixed — `cleanup_buffers_on_delete` option | | [#210](https://github.com/stevearc/oil.nvim/issues/210) | FTP support | open |