From 1e55d6394d964a1e931c5325fae05996186a5864 Mon Sep 17 00:00:00 2001 From: Joshua Finch Date: Mon, 4 Mar 2024 15:44:40 -0600 Subject: [PATCH] Changing the configuration of telescope a bit to add in the use of the file_browser extension, and adding a shortcut to open the file_browser where the current buffer's file is. --- nvim/lua/plugins/telescope.lua | 93 ++++++++++++++++++++++++++-------- 1 file changed, 71 insertions(+), 22 deletions(-) diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua index 7320e7d..65899e3 100644 --- a/nvim/lua/plugins/telescope.lua +++ b/nvim/lua/plugins/telescope.lua @@ -1,36 +1,64 @@ return { 'nvim-telescope/telescope.nvim', - config = function() + config = function(_, opts) + local telescope = require('telescope') local actions = require('telescope.actions') - require('telescope').setup { - defaults = { - file_ignore_patterns = { - '.png$', - '.jpg$', - '.jpeg$', - '.ico$', - '.icns$', - '.webp$', - '.uproject$', - '-workspace$', + local fb_actions = telescope.extensions.file_browser.actions + + opts.defaults = { + file_ignore_patterns = { + '.png$', + '.jpg$', + '.jpeg$', + '.ico$', + '.icns$', + '.webp$', + '.uproject$', + '-workspace$', + }, + layout_config = { prompt_position = 'top' }, + layout_strategy = 'horizontal', + mappings = { + i = { + [''] = actions.close }, - -- layout_strategy = 'vertical', - -- layout_config = { - -- height = 0.0 - -- }, - results_title = false, - prompt_prefix = '  ', - selection_caret = '➤ ', + }, + prompt_prefix = '  ', + results_title = false, + selection_caret = '➤ ', + sorting_strategy = 'ascending', + winblend = 0, + } + + opts.pickers = { + diagnostics = { + theme = 'ivy', + initial_mode = 'normal', + layout_config = { + preview_cutoff = 9999, + }, + }, + } + + opts.extensions = { + file_browser = { + theme = 'dropdown', + hijack_netrw = true, mappings = { - i = { - [''] = actions.close + ['n'] = { + ['N'] = fb_actions.create, + ['h'] = fb_actions.goto_parent_dir, }, }, }, } + + telescope.setup(opts) + telescope.load_extension('file_browser') end, dependencies = { - 'nvim-lua/plenary.nvim' + 'nvim-lua/plenary.nvim', + 'nvim-telescope/telescope-file-browser.nvim', }, keys = { { @@ -94,5 +122,26 @@ return { require('telescope.builtin').lsp_dynamic_workspace_symbols() end }, + { + 'sf', + function() + local telescope = require('telescope') + + local function telescope_buffer_dir() + return vim.fn.expand('%:p:h') + end + + telescope.extensions.file_browser.file_browser({ + path = '%:p:h', + cwd = telescope_buffer_dir(), + respect_gitignore = false, + hidden = true, + grouped = true, + previewer = false, + initial_mode = 'normal', + layout_config = {height = 40}, + }) + end, + }, }, }