Skip to content

FEATURE: Paste the files, images, folders from the system clipboard #1911

@rauf322

Description

@rauf322

Did you check the docs?

  • I have read all the docs.

Is your feature request related to a problem? Please describe.

I had a really big painful time by realizing that i can't simple take image from clipboard which i copied on some random web sides and paste it to my nvim working environment

DISCLAIMER: FULLY VIBE CODED SOLUTION BUT IT WORKS WITH IMAGES

				["P"] = function(state)
					local inputs = require("neo-tree.ui.inputs")
					local node = state.tree:get_node()
					local dir_path = node.type == "directory" and node.path or vim.fn.fnamemodify(node.path, ":h")

					inputs.input("Image filename: ", "", function(filename)
						if not filename or filename == "" then
							return
						end

						if not filename:match("%.png$") then
							filename = filename .. ".png"
						end

						local target_path = dir_path .. "/" .. filename
						local cmd = string.format("osascript -e 'set png_data to the clipboard as «class PNGf»' -e 'set the_file to open for access POSIX file \"%s\" with write permission' -e 'write png_data to the_file' -e 'close access the_file'", target_path)

						local result = os.execute(cmd)
						if result == 0 then
							print("Pasted image: " .. filename)
							require("neo-tree.sources.manager").refresh("filesystem")
						else
							print("Failed to paste image from clipboard")
						end
					end)

Im creating this thread in order to maybe enhance this functionality with pasting files or full directories to your independent nvim environment would be awesome!

Describe the solution you'd like.

Enhancing functionality to make nvim more independent from environment and help people who stuck with the pasting images from clipboard

Describe alternatives you've considered.

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions