nvim: Add scratchpad item to start screen

Added an item to quickly create a scratchpad to the mini.starter
template.

The difference to opening a default empty buffer is that it is seen as
ephemeral (i.e. will not complain if you close vim without saving) and
it sets the default filetype to markdown.

Closes 753ed1f.
This commit is contained in:
Marty Oehme 2024-07-20 14:01:06 +02:00
parent 01809f1ee5
commit 19c95400f7
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
2 changed files with 8 additions and 3 deletions

View file

@ -6,7 +6,7 @@ appear in the buffer list. Useful for e.g. jotting down quick notes and thoughts
If called with bang, will replace the current buffer with the scratch If called with bang, will replace the current buffer with the scratch
window, otherwise opens a new split. window, otherwise opens a new split.
The buffer, by default is set to the pandoc filetype. The buffer, by default is set to the markdown filetype.
This can be changed by setting the `g:scratchpad_ft` variable or the `b:scratchpad_ft` This can be changed by setting the `g:scratchpad_ft` variable or the `b:scratchpad_ft`
variable to the intended filetype. variable to the intended filetype.
]] ]]
@ -25,9 +25,9 @@ function M.create(split, ft)
else else
split = true split = true
end end
-- which filetype to set for the scratchpad, defaults to pandoc -- which filetype to set for the scratchpad, defaults to markdown
if isempty(ft) then if isempty(ft) then
ft = vim.b["scratchpad_ft"] or vim.g["scratchpad_ft"] or "pandoc" ft = vim.b["scratchpad_ft"] or vim.g["scratchpad_ft"] or "markdown"
end end
local buf = api.nvim_create_buf(false, true) local buf = api.nvim_create_buf(false, true)

View file

@ -173,6 +173,11 @@ return {
evaluate_single = true, evaluate_single = true,
items = { items = {
starter.sections.builtin_actions(), starter.sections.builtin_actions(),
{
name = "Scratchpad",
action = "lua require('personal.scratchpad').create()",
section = "Builtin actions",
},
starter.sections.recent_files(10, true), starter.sections.recent_files(10, true),
starter.sections.recent_files(10, false), starter.sections.recent_files(10, false),
-- Use this if you set up 'mini.sessions' -- Use this if you set up 'mini.sessions'