scratchpad.nvim
is a customizable and feature-rich Neovim plugin for managing and synchronizing scratchpad data. It provides a flexible configuration system, intuitive UI, and reliable data storage to streamline your development workflow.
What makes scratchpad.nvim
stand out?
https://github.com/user-attachments/assets/eddde5de-0fe7-42c2-b868-a682229f2c67
lazy
in this case){
"athar-qadri/scratchpad.nvim",
event = "VeryLazy",
dependencies = { "nvim-lua/plenary.nvim" }, -- don't forget to add this one if you don't have it yet!
config = function()
require("scratchpad"):setup()
end,
}
use {
"athar-qadri/scratchpad.nvim",
requires = { "nvim-lua/plenary.nvim" },
config = function()
require("scratchpad"):setup()
end,
}
Initialize scratchpad.nvim
with default settings or provide a custom configuration.
local scratchpad = require("scratchpad")
-- Default setup
scratchpad:setup()
--or
-- Custom setup
scratchpad:setup({
settings = {
sync_on_ui_close = true,
title = "My Scratch Pad"
},
default = {
--here you specify project root identifiers (Cargo.toml, package.json, blah-blah-blah)
--or let your man do the job
root_patterns = { ".git", "package.json", "README.md" },
},
})
You can set up custom key mappings for enhanced functionality. Below is an example keymap configuration:
{
keys = {
{
"<Leader>es",
function()
local scratchpad = require("scratchpad")
scratchpad.ui:new_scratchpad()
end,
desc = "open scratchpad",
},
},
}
return {
"athar-qadri/scratchpad.nvim",
event = "VeryLazy",
opts = {},
dependencies = {
"nvim-lua/plenary.nvim",
},
config = function()
local scratchpad = require("scratchpad")
scratchpad:setup({ settings = { sync_on_ui_close = true } })
end,
keys = {
{
"<Leader>es",
function()
local scratchpad = require("scratchpad")
scratchpad.ui:new_scratchpad()
end,
desc = "show scratch pad",
vim.keymap.set({ "n", "v" }, "<leader>ps", function()
local scratchpad = require("scratchpad")
scratchpad.ui:sync()
end, { desc = "Push selection / current line to scratchpad" }),
},
},
}
Run the command :Scratch
to open Scratchpad for your current project.
You can also directly push the data - text selection
(visual mode) or current line
(normal mode) to your scratchpad by pressing <leader>ps
using above configuration.
Initialize a Scratchpad: The plugin detects your project root and initializes a scratchpad associated with the directory. If no project root is found, your current working directory will be consider for a unique scratchpad.
Synchronize Data: Changes to the scratchpad are saved automatically based on your configuration. Your cursor position in scratchpad is saved even after the closing the ui.
Customize Behavior:
Modify setting sync_on_ui_close
to control how data is managed.
Below is a detailed breakdown of the configuration options available:
ScratchpadConfig
Key | Description |
---|---|
sync_on_ui_close |
any time the ui menu is closed then the state of the scratchpad will be sync'd back to the fs. |
root_patterns |
Specify project root identifiers (e.g., .git, package.json). |
Refer to config.lua
for more detailed options and comments.
We welcome contributions! Feel free to submit issues or pull requests to improve the plugin.
This project is licensed under the MIT License. See the LICENSE
file for more details.