22--- @alias Command { [1] : string , [2] : string | fun () }
33
44--- @class CommandPalette
5+ --- @field snacks_opts snacks.picker.Config
56--- @field groups CommandGroup[]
6- --- @field select_command fun ( self : CommandPalette , commands : Command[] , on_back : fun ())
7+ --- @field select_command fun ( self : CommandPalette , commands : Command[] , on_back ? : fun ())
78--- @field show fun ( self : CommandPalette )
89local CommandPalette = {
10+ snacks_opts = {
11+ layout = { preset = " vscode" },
12+ focus = " list" ,
13+ },
914 groups = {
1015 {
1116 name = " LSP" ,
@@ -68,9 +73,8 @@ function CommandPalette:select_command(commands, on_back)
6873 if on_back then vim .schedule (on_back ) end
6974 end
7075
71- local snacks_opts = {
72- layout = { preset = " vscode" },
73- focus = " list" ,
76+ --- @type snacks.picker.Config
77+ local select_actions = {
7478 actions = {
7579 back_or_delete = function (picker )
7680 if picker .input :get () ~= " " then return " <BS>" end
@@ -96,7 +100,7 @@ function CommandPalette:select_command(commands, on_back)
96100
97101 vim .ui .select (commands , {
98102 prompt = " Select command:" ,
99- snacks = snacks_opts ,
103+ snacks = vim . tbl_extend ( " force " , self . snacks_opts , select_actions ) ,
100104 format_item = function (item ) return item [1 ] end ,
101105 }, function (command )
102106 if not command then return end
112116function CommandPalette :show ()
113117 vim .ui .select (self .groups , {
114118 prompt = " Select category:" ,
115- snacks = { layout = { preset = " vscode " }, focus = " list " } ,
119+ snacks = self . snacks_opts ,
116120 format_item = function (item ) return item .name end ,
117121 }, function (group )
118122 if not group then return end
0 commit comments