From facde2d5504e7212ba327d343647d9725af540d4 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Wed, 12 Oct 2022 23:05:11 +0200 Subject: [PATCH] vim: add telescope file browser --- config/nvim/after/plugin/telescope.lua | 86 ++++++++++++++++---------- config/nvim/lua/fs/plugins.lua | 1 + 2 files changed, 53 insertions(+), 34 deletions(-) diff --git a/config/nvim/after/plugin/telescope.lua b/config/nvim/after/plugin/telescope.lua index d838580..bd7d7c9 100644 --- a/config/nvim/after/plugin/telescope.lua +++ b/config/nvim/after/plugin/telescope.lua @@ -2,6 +2,58 @@ local ok, telescope = pcall(require, 'telescope') if not ok then return end local actions = require 'telescope.actions' + +telescope.setup { + defaults = { + prompt_prefix = '❯ ', + selection_caret = '➔ ', + + layout_strategy = 'flex', + layout_config = { + anchor = 'center', + width = 0.92, + height = 0.95, + + flex = { + flip_columns = 130, + }, + + horizontal = { + preview_width = 0.5, + preview_cutoff = 130, + }, + + vertical = { + preview_height = 0.5, + }, + }, + + mappings = { + i = { + [''] = actions.cycle_history_next, + [''] = actions.cycle_history_prev, + }, + }, + }, + + extensions = { + file_browser = { + theme = 'ivy', + mappings = { + n = { + -- normal mode mappings go here + }, + i = { + -- insert mode mappings go here + }, + }, + }, + }, +} + +telescope.load_extension 'file_browser' +vim.keymap.set('n', 'br', 'Telescope file_browser') + local builtin = require 'telescope.builtin' local find_buffers = function() @@ -53,40 +105,6 @@ local find_options = function() } end -telescope.setup { - defaults = { - prompt_prefix = '❯ ', - selection_caret = '➔ ', - - layout_strategy = 'flex', - layout_config = { - anchor = 'center', - width = 0.92, - height = 0.95, - - flex = { - flip_columns = 130, - }, - - horizontal = { - preview_width = 0.5, - preview_cutoff = 130, - }, - - vertical = { - preview_height = 0.5, - }, - }, - - mappings = { - i = { - [''] = actions.cycle_history_next, - [''] = actions.cycle_history_prev, - }, - }, - }, -} - vim.keymap.set('n', 'fb', find_buffers) vim.keymap.set('n', 'fc', find_commits) vim.keymap.set('n', 'fd', find_dotfiles) diff --git a/config/nvim/lua/fs/plugins.lua b/config/nvim/lua/fs/plugins.lua index 34bc86c..a6a20ea 100644 --- a/config/nvim/lua/fs/plugins.lua +++ b/config/nvim/lua/fs/plugins.lua @@ -32,6 +32,7 @@ packer.startup(function(use) -- Navigation ------------------------------------------------------------- use 'nvim-telescope/telescope.nvim' + use 'nvim-telescope/telescope-file-browser.nvim' use 'kyazdani42/nvim-tree.lua' -- Editing ----------------------------------------------------------------