mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-21 08:35:53 +02:00
feat(chezmoi): enhance fzf-lua chezmoi picker and add snacks.dasbhoard entry (#5275)
## Description <!-- Describe the big picture of your changes to communicate to the maintainers why we should accept this pull request. --> This PR enhances the fzf-lua picker for chezmoi by using the built-in `files` picker and by opening the selected file with `ChezmoiEdit` and `vimcmd_entry` to parse the entry. This simplifies the code and adds icons and file preview. The PR also replaces the config entry in snacks.dashboard with the chezmoi picker, similar to what was already implemented for dashboard-nvim ## Screenshots <!-- Add screenshots of the changes if applicable. --> Current picker:  New picker:  ## Checklist - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines.
This commit is contained in:
parent
f3e37a1f83
commit
759a19e785
1 changed files with 27 additions and 15 deletions
|
@ -3,22 +3,12 @@ local pick_chezmoi = function()
|
||||||
require("telescope").extensions.chezmoi.find_files()
|
require("telescope").extensions.chezmoi.find_files()
|
||||||
elseif LazyVim.pick.picker.name == "fzf" then
|
elseif LazyVim.pick.picker.name == "fzf" then
|
||||||
local fzf_lua = require("fzf-lua")
|
local fzf_lua = require("fzf-lua")
|
||||||
local results = require("chezmoi.commands").list()
|
local actions = {
|
||||||
local chezmoi = require("chezmoi.commands")
|
["enter"] = function(selected)
|
||||||
|
fzf_lua.actions.vimcmd_entry("ChezmoiEdit", selected, { cwd = os.getenv("HOME") })
|
||||||
local opts = {
|
end,
|
||||||
fzf_opts = {},
|
|
||||||
fzf_colors = true,
|
|
||||||
actions = {
|
|
||||||
["default"] = function(selected)
|
|
||||||
chezmoi.edit({
|
|
||||||
targets = { "~/" .. selected[1] },
|
|
||||||
args = { "--watch" },
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
fzf_lua.fzf_exec(results, opts)
|
fzf_lua.files({ cmd = "chezmoi managed --include=files,symlinks", actions = actions })
|
||||||
elseif LazyVim.pick.picker.name == "snacks" then
|
elseif LazyVim.pick.picker.name == "snacks" then
|
||||||
local results = require("chezmoi.commands").list({
|
local results = require("chezmoi.commands").list({
|
||||||
args = {
|
args = {
|
||||||
|
@ -65,6 +55,7 @@ return {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"xvzc/chezmoi.nvim",
|
"xvzc/chezmoi.nvim",
|
||||||
|
cmd = { "ChezmoiEdit" },
|
||||||
keys = {
|
keys = {
|
||||||
{
|
{
|
||||||
"<leader>sz",
|
"<leader>sz",
|
||||||
|
@ -120,6 +111,27 @@ return {
|
||||||
table.insert(opts.config.center, 5, projects)
|
table.insert(opts.config.center, 5, projects)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"folke/snacks.nvim",
|
||||||
|
optional = true,
|
||||||
|
opts = function(_, opts)
|
||||||
|
local chezmoi_entry = {
|
||||||
|
icon = " ",
|
||||||
|
key = "c",
|
||||||
|
desc = "Config",
|
||||||
|
action = pick_chezmoi,
|
||||||
|
}
|
||||||
|
local config_index
|
||||||
|
for i = #opts.dashboard.preset.keys, 1, -1 do
|
||||||
|
if opts.dashboard.preset.keys[i].key == "c" then
|
||||||
|
table.remove(opts.dashboard.preset.keys, i)
|
||||||
|
config_index = i
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
table.insert(opts.dashboard.preset.keys, config_index, chezmoi_entry)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
-- Filetype icons
|
-- Filetype icons
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue