add filetypes source for snacks

This commit is contained in:
xfy
2025-05-18 00:58:01 +08:00
parent 5a880d2768
commit 08fa8261dc
4 changed files with 51 additions and 6 deletions

View File

@ -179,6 +179,7 @@ return {
-- https://github.com/folke/snacks.nvim/discussions/860#discussioncomment-12027395
picker = {
sources = {
-- change explorer to right
explorer = {
include = { "ignored", "hidden" },
layout = {
@ -187,6 +188,34 @@ return {
},
},
},
-- add filetypes source
filetypes = {
name = "filetypes",
format = "text",
preview = "none",
layout = {
preview = "main",
preset = "ivy",
},
confirm = function(picker, item)
picker:close()
if item then
vim.schedule(function()
vim.cmd("setfiletype " .. item.text)
end)
end
end,
finder = function()
local items = {}
local filetypes = vim.fn.getcompletion("", "filetype")
for _, type in ipairs(filetypes) do
items[#items + 1] = {
text = type,
}
end
return items
end,
},
},
},
},