docs: add paste-file-from-clipboard recipe (stevearc/oil.nvim#156)
Problem: users on macOS want to copy a file in Finder and paste it into an oil directory. The parser rejects absolute paths, but a recipe-level solution avoids touching the mutation pipeline entirely. Solution: add `oil-recipe-paste-file-from-clipboard` recipe that reads the system clipboard, resolves it as a file path, and copies it into the current oil directory via `vim.uv.fs_copyfile`.
This commit is contained in:
parent
aba99ecac6
commit
b5d500b382
2 changed files with 34 additions and 1 deletions
33
doc/oil.txt
33
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*
|
||||
|
||||
|
|
|
|||
|
|
@ -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 |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue