From 1c6a7da06ae8329c88ca45e24ec92f7bbc024ac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hend=C3=A9n?= Date: Mon, 9 Dec 2024 12:03:33 -0400 Subject: [PATCH] change layout of fuzzy buffer --- init.lua | 84 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 72 insertions(+), 12 deletions(-) diff --git a/init.lua b/init.lua index ecf7e898..c52556b4 100644 --- a/init.lua +++ b/init.lua @@ -284,23 +284,76 @@ require('lazy').setup({ -- You can put your default mappings / updates / etc. in here -- All the info you're looking for is in `:help telescope.setup()` -- - -- defaults = { - -- mappings = { - -- i = { [''] = 'to_fuzzy_refine' }, - -- }, - -- }, - -- pickers = {} - - --[[ layout_config = { defaults = { + -- mappings = { + -- i = { [''] = 'to_fuzzy_refine' }, + -- }, + -- }, layout_strategy = 'vertical', + pickers = { + current_buffer_fuzzy_find = { + theme = 'ivy', + previewer = false, + }, + buffers = { + sort_lastused = true, + -- theme = "dropdown", + theme = 'ivy', + layout_config = { height = 10 }, + previewer = false, + mappings = { + i = { [''] = require('telescope.actions').delete_buffer }, + n = { [''] = require('telescope.actions').delete_buffer }, + }, + }, + find_files = { + theme = 'ivy', + layout_config = { height = 10 }, + previewer = false, + }, + oldfiles = { + sort_lastused = true, + theme = 'ivy', + layout_config = { height = 10 }, + previewer = false, + }, + command_history = { + sort_lastused = true, + theme = 'ivy', + layout_config = { height = 10 }, + previewer = false, + }, + }, + + --[[ + layout_config = { + + width = function(_, max_columns) + local percentage = 0.7 + local max = 70 + return math.min(math.floor(percentage * max_columns), max) + end, + + height = function(_, _, max_lines) + local percentage = 0.7 + local min = 70 + return math.max(math.floor(percentage * max_lines), min) + end, + + -- preview_cutoff = 120, + }, + --]] + --[[ + layout_config = { + -- defaults = { + layout_strategy = 'vertical', height = vim.o.lines, -- maximally available lines width = vim.o.columns, -- maximally available columns prompt_position = 'top', -- preview_height = 0.6, -- 60% of available lines }, + --]] }, - --]] extensions = { ['ui-select'] = { require('telescope.themes').get_dropdown(), @@ -324,20 +377,27 @@ require('lazy').setup({ vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) - vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) -- Slightly advanced example of overriding default behavior and theme + -- vim.keymap.set('n', '/', builtin.current_buffer_fuzzy_find, { desc = '[/] Fuzzily search in current buffer' }) + vim.keymap.set('n', '/', function() + builtin.current_buffer_fuzzy_find { + previewer = false, + } + end, { desc = '[/] Fuzzily search in current buffer' }) + --[[ vim.keymap.set('n', '/', function() -- You can pass additional configuration to Telescope to change the theme, layout, etc. builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, + winblend = 20, previewer = false, }) end, { desc = '[/] Fuzzily search in current buffer' }) + --]] -- It's also possible to pass additional configuration options. -- See `:help telescope.builtin.live_grep()` for information about particular keys - vim.keymap.set('n', 's/', function() + vim.keymap.set('n', '', function() builtin.live_grep { grep_open_files = true, prompt_title = 'Live Grep in Open Files',