vim.api.nvim_set_keymap('v', 'p', ':PastifyAfter', { noremap = true, silent = true }) vim.api.nvim_set_keymap('n', 'mp', ':PastifyAfter', { noremap = true, silent = true, desc = 'Paste image from clipboard after' }) vim.api.nvim_set_keymap('n', 'mP', ':Pastify', { noremap = true, silent = true, desc = 'Paste image from clipboard' }) local function get_assets_dir() -- Get the absolute path of the current buffer local buf_path = vim.api.nvim_buf_get_name(0) if buf_path == '' then -- Fallback to current working directory if buffer has no file buf_path = vim.loop.cwd() end -- Extract directory name local dir = vim.fn.fnamemodify(buf_path, ':p:h') -- Append "assets" local assets_dir = dir .. '/assets' return assets_dir end return { 'TobinPalmer/pastify.nvim', cmd = { 'Pastify', 'PastifyAfter' }, config = function() require('pastify').setup { opts = { apikey = '', -- Needed if you want to save online. local_path = get_assets_dir, }, } end, }