Help you to create tmp playground files, which can be found later, with one stroke and without worrying about what's the filename and where to put it.
- With other nvim's goodies.
- with
treesitter
to have syntax highlighting - with
lsp
andcmp
to have auto-cmp, auto-format and other lsp goodies - with
michaelb/sniprun
ormetakirby5/codi.vim
to run scratch file
- with
using your favorate plugin manager, for example packer
use {
"LintaoAmons/scratch.nvim",
-- tag = "v0.3.2" -- use tag for stability, or without this to have latest fixed and functions
}
I will continue add some changes to main branch, so if you meet some issue due to new changes, you can just downgrade to your former version.
require("scratch").setup {
scratch_file_dir = vim.fn.stdpath("cache") .. "/scratch.nvim", -- Where the scratch files will be saved
filetypes = { "json", "xml", "go", "lua", "js", "py", "sh" }, -- filetypes to select from
}
:lua require("scratch").checkConfig()
No default keymappings, here's functions you can mapping to.
This can create a new scratch file in your config's scratch_file_dir
vim.keymap.set("n", "<M-C-n>", "<cmd>Scratch<cr>")
-- or
vim.keymap.set("n", "<M-C-n>", function() require("scratch").scratch() end)
since
v0.3.0
This can create a new scratch file with user provided filename (But actually you can use scratch
to create a file then rename the file)
vim.keymap.set("n", "<M-C-n>", "<cmd>ScratchWithName<cr>")
-- or
vim.keymap.set("n", "<M-C-m>", function() require("scratch").scratchWithName() end)
since
v0.2.0
This can open an old scratch file in your config's scratch_file_dir
vim.keymap.set("n", "<M-C-o>", "<cmd>ScratchOpen<cr>")
-- or
vim.keymap.set("n", "<M-C-o>", function() require("scratch").openScratch() end)
This function can print out your current configuration.
I don't think you want to bind this to a shortcut, just use it in command mode to check the config
Finally be able to do something
- fzf scratch file content and open
- Template codes when create specific filetype(configurable)
- create user command
- Add user command and did some refactor
- Remove hardcoded path and set default dir to
cache
, thus I think windows can use this, thanks to #2 - Add
scratchWithName
function, though I may not use it but I think somebody may find it useful