https://github.com/reybits/scratch.nvim
WARNING: This plugin is still in development and may not be stable!
https://github.com/reybits/scratch.nvim
neovim nvim nvim-plugin plugin
Last synced: about 1 month ago
JSON representation
WARNING: This plugin is still in development and may not be stable!
- Host: GitHub
- URL: https://github.com/reybits/scratch.nvim
- Owner: reybits
- License: mit
- Created: 2025-03-16T03:18:49.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-03-16T18:52:01.000Z (over 1 year ago)
- Last Synced: 2025-03-16T19:47:12.286Z (over 1 year ago)
- Topics: neovim, nvim, nvim-plugin, plugin
- Language: Lua
- Homepage:
- Size: 2.93 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Neovim Scratch Buffer
A Neovim plugin for quick scratch notes in a floating window. Supports
three note types: temporary (in-memory), local (per-project, saved to disk),
and global (shared across projects, saved to disk). Switch between them with
`Tab`/`S-Tab`.

## Features
- Floating scratch window with markdown and Treesitter highlighting.
- **Temporary notes** — in-memory, never written to disk.
- **Local notes** — persisted per-project (`.scratch.md` at the git root).
- **Global notes** — persisted across projects (`stdpath("data")/scratch.nvim/global.md`).
- Cycle between note types with `Tab` / `S-Tab`.
- Notes auto-save on close, type switch, and `VimLeavePre`.
- Configurable window size, border, title, and behavior.
## Installation
### [Lazy](https://github.com/folke/lazy.nvim)
```lua
{
"reybits/scratch.nvim",
lazy = true,
keys = {
{ "ts", "ScratchToggle", desc = "Toggle Scratch Buffer" },
},
cmd = {
"ScratchToggle",
},
opts = {},
}
```
## Configuration
Default options:
```lua
opts = {
title = "Scratch",
border = "rounded",
width = 0.6,
height = 0.6,
-- enable per-project notes
local_notes = true,
-- enable global notes
global_notes = true,
-- filename for local notes
local_notes_file = ".scratch.md",
-- close window when leaving the buffer
close_on_leave = true,
-- window-local options (vim.wo)
win_opts = {
wrap = true,
linebreak = true,
},
}
```
Set `local_notes = false` or `global_notes = false` to disable a note type.
When only one type is enabled, the type label and switch keymaps are hidden.
`win_opts` accepts any `vim.wo` option. For example:
```lua
opts = {
win_opts = {
wrap = true,
linebreak = true,
number = true,
},
}
```
## Usage
### Commands
- `:ScratchToggle` — Open or close the scratch window.
### Keymaps (inside the scratch window)
| Key | Action |
|-----------|-------------------------------|
| `q` | Close the scratch window |
| `R` | Reset (clear) the current note|
| `Tab` | Switch to next note type |
| `S-Tab` | Switch to previous note type |
### Lua API
- `require('scratch').toggle()` — Toggle the scratch window.
- `require('scratch').close()` — Close the scratch window.
- `require('scratch').reset()` — Clear the current note buffer.
- `require('scratch').next_type()` — Switch to the next note type.
- `require('scratch').prev_type()` — Switch to the previous note type.
## License
[MIT License](LICENSE)
## Contributing
Contributions are welcome! Feel free to open issues or submit pull requests.