fix(scratch): always set filetype on the buffer. Fixes #179

This commit is contained in:
Folke Lemaitre 2024-12-01 20:06:02 +01:00
parent 4f90e638af
commit 6db50cfe2d
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -24,7 +24,7 @@ local M = setmetatable({}, {
---@field file? string scratch file path. You probably don't need to set this.
local defaults = {
name = "Scratch",
ft = "lua",
ft = "lua", -- the filetype of the scratch buffer
---@type string|string[]?
icon = nil, -- `icon|{icon, icon_hl}`. defaults to the filetype icon
root = vim.fn.stdpath("data") .. "/scratch",
@ -146,6 +146,8 @@ end
function M.open(opts)
opts = Snacks.config.get("scratch", defaults, opts)
opts.win = Snacks.win.resolve("scratch", opts.win_by_ft[opts.ft], opts.win, { show = false })
opts.win.bo = opts.win.bo or {}
opts.win.bo.filetype = opts.ft
local file = opts.file
if not file then