Skip to content

Sonicfury/scretch.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Introduction

Scretch.nvim is a plugin to easily create and manage scratch files πŸ™‚.

Features

New scretch

scretch_new.mov

New named scretch

scretch_new_named.mov

Search, grep, and explore scretches !

scretch_search_grep_explore.mov

Templates

You can save any buffer as a Scretch template. It'll be saved in the default directory if none is explicitely provided in the config. You can also search and edit templates with Telescope or Fzf-Lua, and create a new Scretch from a template. See suggested mappings.

Installation

This plugin requires Telescope or fzf-lua and ripgrep to function.

If you don't have ripgrep installed, I recommend you go check the installation procedure here. If you don't want to install it, it should fall back to find.

You can paste the following code using Packer, or adapt to your favorite package manager:

use {
  "Sonicfury/scretch.nvim",
  requires = 'nvim-telescope/telescope.nvim',
  -- or
  -- requires = 'ibhagwan/fzf-lua' ,
  config = function()
    require("scretch").setup {
      -- your configuration comes here
      -- or leave it empty to use the default settings
      -- refer to the configuration section below
    }
  end
}

Configuration

Here are the default settings used in Scretch:

local config = {
    scretch_dir = vim.fn.stdpath('config') .. '/scretch/', -- will be created if it doesn't exist
    templte_dir = vim.fn.stdpath('data') .. '/scretch/templates', -- will be created if it doesn't exist
    default_name = "scretch_",
    default_type = "txt", -- default unnamed Scretches are named "scretch_*.txt"
    split_cmd = "vsplit", -- vim split command used when creating a new Scretch
    backend = "telescope.builtin" -- also accpets "fzf-lua"
}

You can copy those settings, update them with your preferences and put them into the setup function to load them.

Suggested mappings

local scretch = require("scretch")
vim.keymap.set('n', '<leader>sn', scretch.new)
vim.keymap.set('n', '<leader>snn', scretch.new_named)
vim.keymap.set('n', '<leader>sft', scretch.new_from_template)
vim.keymap.set('n', '<leader>sl', scretch.last)
vim.keymap.set('n', '<leader>ss', scretch.search)
vim.keymap.set('n', '<leader>st', scretch.edit_template)
vim.keymap.set('n', '<leader>sg', scretch.grep)
vim.keymap.set('n', '<leader>sv', scretch.explore)
vim.keymap.set('n', '<leader>sat', scretch.save_as_template)

Issues

Feel free to open issues if you have a suggestion or encounter a bug. Be kind !

License

AGPL-3.0, see license file

Contributing

Feel free to open up PRs, they should respect the contribution guidelines. Be kind !