Skip to content

plugin to auto-centre neovim buffers with a useful persistent scratchpad on the side

License

Notifications You must be signed in to change notification settings

FraserLee/ScratchPad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ScratchPad

A snazzy neovim plugin to centre your buffer by creating a persistent scratchpad off to the left.

scratchpad-vid



Installation

If you're reading this you've probably already got a plugin manager. If not, I recommend Vim-Plug, but they're essentially interchangeable. Add the appropriate line in the appropriate spot in your .vimrc file.

" vim-plug
Plug 'FraserLee/ScratchPad'

" vundle
Plugin 'FraserLee/ScratchPad'

" packer.nvim
use 'FraserLee/ScratchPad'

" etc...

Run your version of :PlugInstall and things should be good to go.





Usage

nnoremap <leader>cc <cmd>ScratchPad<cr>

By default, all scratchpad windows point to one underlying file (~/.scratchpad unless changed). They'll auto-save when modified, reload if the file is changed, and automatically close when all other windows are gone.

I tend to use them as the digital equivalent of the sticky notes that coat all objects vaguely proximate to my desk, but that's not a requirement.

  • :ScratchPad to toggle the scratchpad
  • :ScratchPad open opens a new scratchpad
  • :ScratchPad close closes all scratchpads in the current tab





Configuration

By default, the scratchpad will auto-open when you open vim, and automatically open / close / resize itself as the window size (and spilt) changes.

Disable scratchpad on startup:

let g:scratchpad_autostart = 0

Disable automatic resizing:

let g:scratchpad_autosize = 0

Automatic Size Junk

The assumed width of code, as per what will be centred on screen. Set this to the same thing as any sort of colour column.

let g:scratchpad_textwidth = 80 " (80 is the default)

The minimum width of a ScratchPad before it will - if autosize is enabled - close itself.

let g:scratchpad_minwidth = 12

File Locations

Change the scratchpad file by

let g:scratchpad_location = '~/.scratchpad'

Auto-focus when opening a scratchpad window:

let g:scratchpad_autofocus = 1

Daily ScratchPad

Instead of having one ScratchPad have a fresh one for each day. The old ScratchPads are saved as well. Disabled by default.

Enable daily scratchpad

let g:scratchpad_daily = 1

Change the daily scratchpad directory

let g:scratchpad_daily_location = '~/.daily_scratchpad'

Change the daily scratchpad file name format using lua os date

let g:scratchpad_daily_format = '%Y-%m-%d'

Edit colour with

hi ScratchPad ctermfg=X ctermbg=Y





Making Stuff Look (somewhat) Decent

I've added a line to disable the virtual-text colour column in scratchpad buffers if that plugin's found, since I think these two pair pretty well together. If you want to get something looking similar to the screenshots, here's a start.

call plug#begin('~/.vim/plugged')
Plug 'morhetz/gruvbox'
Plug 'fraserlee/ScratchPad'
Plug 'lukas-reineke/virt-column.nvim'
call plug#end()

" ------------------------------ SETUP ---------------------------------------

se nu             " Turn on line numbers
se colorcolumn=80 " Set the colour-column to 80

noremap <SPACE> <Nop>
let mapleader=" "

" <space>cc to toggle ScratchPad
nnoremap <leader>cc <cmd>ScratchPad<cr>

lua << EOF
    require('virt-column').setup{ char = '|' }
EOF

" -------------------------- COLOUR SCHEME -----------------------------------

colorscheme gruvbox
let g:gruvbox_contrast_dark = 'hard'
se background=dark

" Set the colourcolumn background to the background colour,
" foreground to the same as the window split colour

execute "hi ColorColumn ctermbg=" .
            \matchstr(execute('hi Normal'), 'ctermbg=\zs\S*')
hi! link VirtColumn VertSplit

1 2 3

About

plugin to auto-centre neovim buffers with a useful persistent scratchpad on the side

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •