Skip to content

local_file save type doesn't paste any contents #11

@atomdmac

Description

@atomdmac

Overview

Using the save = "local_file" setting doesn't appear to work. Invoking the Pastify command causes a message to appear in the minibuffer that says local_file but nothing else happens. Using local does work, however.

Specs

  • MacOS Sonoma 14.5
  • Apple M1
  • Python 3.9.10
  • pynvim 0.4.3

Lazy Config

return {
	"TobinPalmer/pastify.nvim",
	cmd = { "Pastify", "PastifyAfter" },
	event = { "BufReadPost" }, -- Load after the buffer is read, I like to be able to paste right away
	keys = {
		{ noremap = true, mode = "x", "<leader>P", "<cmd>PastifyAfter<CR>" },
		{ noremap = true, mode = "n", "<leader>P", "<cmd>PastifyAfter<CR>" },
		{ noremap = true, mode = "n", "p", "<cmd>Pastify<CR>" },
	},
	config = function()
		require("pastify").setup({
			opts = {
				absolute_path = false, -- use absolute or relative path to the working directory
				apikey = "", -- Api key, required for online saving
				local_path = "./", -- The path to put local files in, ex ~/Projects/<name>/assets/images/<imgname>.png
				save = "local_file", -- Either 'local' or 'online' or 'local_file'
				filename = function()
					return vim.fn.expand("%:t:r") .. "_" .. os.date("%Y-%m-%d_%H-%M-%S")
				end,
				default_ft = "markdown", -- Default filetype to use
			},
			ft = { -- Custom snippets for different filetypes, will replace $IMG$ with the image url
				html = '<img src="$IMG$" alt="">',
				markdown = "![]($IMG$)",
				tex = [[\includegraphics[width=\linewidth]{$IMG$}]],
				css = 'background-image: url("$IMG$");',
				js = 'const img = new Image(); img.src = "$IMG$";',
				xml = '<image src="$IMG$" />',
				php = '<?php echo "<img src="$IMG$" alt="">"; ?>',
				python = "# $IMG$",
				java = "// $IMG$",
				c = "// $IMG$",
				cpp = "// $IMG$",
				swift = "// $IMG$",
				kotlin = "// $IMG$",
				go = "// $IMG$",
				typescript = "// $IMG$",
				ruby = "# $IMG$",
				vhdl = "-- $IMG$",
				verilog = "// $IMG$",
				systemverilog = "// $IMG$",
				lua = "-- $IMG$",
			},
		})
	end,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions