From 32a74e1d5451faad157c39cb977756dc7ef8eae4 Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Wed, 28 Feb 2024 10:12:28 +0100 Subject: [PATCH] show hidden files, ignore special entries --- lua/telescope-setup.lua | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/lua/telescope-setup.lua b/lua/telescope-setup.lua index d800b37..46cc8b1 100644 --- a/lua/telescope-setup.lua +++ b/lua/telescope-setup.lua @@ -19,6 +19,7 @@ pcall(require('telescope').load_extension, 'ui-select') -- See `:help telescope.builtin` local builtin = require 'telescope.builtin' +local actions = require 'telescope.actions' -- Telescope live_grep in git root -- Function to find the git root directory based on the current buffer's path @@ -76,7 +77,31 @@ end vim.keymap.set('n', 's/', telescope_live_grep_open_files, { desc = '[S]earch [/] in Open Files' }) vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) vim.keymap.set('n', 'gf', builtin.git_files, { desc = 'Search [G]it [F]iles' }) -vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) +vim.keymap.set('n', 'sf', function() + builtin.find_files { + -- This will ignore the directories you specified + find_command = { + 'rg', + '--files', + '--hidden', + '-u', + '-g', + '!{' .. table.concat({ + '.git', + 'target', + 'node_modules', + '.svelte-kit', + 'bin', + 'obj', + }, ',') .. '}', + }, + attach_mappings = function(_, map) + map('i', '', actions.select_default + actions.center) + return true + end, + desc = '[S]earch [F]iles', + } +end) vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })