Skip to content

PremBharwani/scratchpad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

scratchpad.nvim

A floating window "scratchpad" plugin for Neovim, inspired by i3wm. Quickly stash buffers in a floating window with LIFO stack behavior.

scratchpad-demo.mp4

Motivation

  1. When working on my laptop - the screen real estate is limited for me to have multiple splits open. Much easier to have a "scratchpad" popup and disappear as needed. Be it note-taking, referencing code, or temporary edits.
  2. I use one claude code instance inside of my nvim as well that I frequently interact with/guide - having a floating window popup the moment its done processing & sends a notification via the terminal is super useful.

The following plugins come close to what I wanted, so you might as well take a look at these:

Features

  • Floating window scratchpad: Move buffers to a floating window for quick access
  • LIFO stack behavior: Most recently added buffers appear first
  • Cycle through buffers: Navigate between stashed buffers
  • Persistent visibility: Hide and show the scratchpad without losing state
  • Configurable: Customize size, position, border, and keybindings

Requirements

  • Neovim 0.7+

Installation

vim-plug

Plug 'PremBharwani/scratchpad.nvim'

packer.nvim

use 'PremBharwani/scratchpad.nvim'

lazy.nvim

{
    'PremBharwani/scratchpad.nvim',
    config = function()
        require('scratchpad').setup()
    end
}

Setup

require("scratchpad").setup({
    width = 0.8,              -- 80% of editor width (or absolute number)
    height = 0.8,             -- 80% of editor height (or absolute number)
    position = "center",      -- Window position
    border = "rounded",       -- Border style
    title = true,             -- Show title with buffer name and position
    mappings = {
        toggle_buffer = "<leader>sa",
        toggle_visibility = "<leader>ss",
        cycle_next = "<leader>sn",
        cycle_prev = "<leader>sp",
    },
    local_mappings = {
        close = "q",
        cycle_next = "<Tab>",
        cycle_prev = "<S-Tab>",
    },
})

Commands

Command Description
:ScratchpadToggle Toggle current buffer in scratchpad
:ScratchpadShow Toggle scratchpad visibility
:ScratchpadNext Cycle to next buffer
:ScratchpadPrev Cycle to previous buffer
:ScratchpadList List buffers in scratchpad (debug)
:ScratchpadHide Hide scratchpad window

Default Keybindings

Global

Mapping Action
<leader>sa Toggle buffer in scratchpad
<leader>ss Toggle scratchpad visibility
<leader>sn Cycle to next buffer
<leader>sp Cycle to previous buffer

Inside Scratchpad

Mapping Action
q Hide scratchpad
<Tab> Cycle next
<S-Tab> Cycle previous

Usage

  1. Open some files in Neovim
  2. Press <leader>sa to add the current buffer to the scratchpad
  3. The buffer moves to the floating window; your main window shows the alternate buffer
  4. Add more buffers with <leader>sa
  5. Cycle through buffers with <leader>sn and <leader>sp
  6. Hide the scratchpad with <leader>ss or q
  7. Show it again with <leader>ss - same buffer will be visible
  8. Toggle a buffer again to remove it from the scratchpad

Stack Behavior

The scratchpad uses LIFO (Last In, First Out) ordering:

  • Add buffers A, B, C in order -> stack is [C, B, A]
  • C (most recent) is displayed first
  • Cycle forward: current goes to bottom -> [B, A, C], showing B
  • Cycle backward: bottom comes to current position

API

local scratchpad = require("scratchpad")

scratchpad.setup(opts)                    -- Initialize with options
scratchpad.toggleFloatingBuffer()         -- Toggle buffer in scratchpad
scratchpad.toggleScratchpadVisibility()   -- Show/hide scratchpad
scratchpad.cycleScratchpadBuffers(1)      -- Cycle next
scratchpad.cycleScratchpadBuffers(-1)     -- Cycle previous
scratchpad.show()                         -- Show scratchpad
scratchpad.hide()                         -- Hide scratchpad
scratchpad.list()                         -- Print buffer list

License

All yours :)

Acknowledgements

  • Cheers to the chad developers who've handwritten stuff so that claude code could train on them & one-shot this.
  • i3wm GOAT window manager for the inspiration!

About

scratchpad.vim: i3wm "scratchpad" inspired vim plugin

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages