I'm trying to set up a custom buffers picker so that I just open the picker with <leader>
b and then click a number that opens the desired file in the current buffer.
Code:
local actions = require("telescope.actions")local actions_set = require("telescope.actions.set")local actions_utils = require("telescope.actions.utils")local builtin = require("telescope.builtin")local function buffer_mappings(prompt_bufnr, map) -- delete a buffer map("n", "d", delete_buffer, { desc = "delete buffer" }) -- assign number to open each buffer actions_utils.map_entries(prompt_bufnr, function(_, index) print(index) map("n", tostring(index), function() -- move upwards actions_set.shift_selection(prompt_bufnr, -index) -- open file in current buffer actions.select_default(prompt_bufnr) end) end)end-- Function to call the buffers picker with custom mappingslocal function custom_buffers_picker() builtin.buffers({ attach_mappings = function(prompt_bufnr, map) buffer_mappings(prompt_bufnr, map) return true end, })end-- Keybinding to invoke buffers pickervim.keymap.set("n", "<leader>b", custom_buffers_picker, { desc = "Buffers" })
I think the problem is that the picker is not set up correctly but I'm not certain of this and I haven't managed to find away around it. I thought about environmental problems and defined these functions in different scope (i.e, in their own module) and inside config function where it resides now. I'm using lazy.nvim as a plugin manager.
The error I'm getting is:
"attempt to index field 'manager' (a boolean value)"
and the error is thrown by actions_utils.map_entries
when it tries to access picker.manager
.