33 lines
978 B
Lua
33 lines
978 B
Lua
vim.api.nvim_set_keymap('v', '<leader>p', ':PastifyAfter<CR>', { noremap = true, silent = true })
|
|
vim.api.nvim_set_keymap('n', '<leader>p', ':PastifyAfter<CR>', { noremap = true, silent = true })
|
|
vim.api.nvim_set_keymap('n', '<leader>P', ':Pastify<CR>', { noremap = true, silent = true })
|
|
|
|
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,
|
|
}
|