telescope: ignore .git but search hidden files

This commit is contained in:
Oliver Hartmann 2023-01-29 11:41:44 +01:00
parent c60cf314be
commit fa0d4ffd8f

View File

@ -117,6 +117,18 @@ return {
if not ok then require "telescope.builtin".find_files(opts) end if not ok then require "telescope.builtin".find_files(opts) end
end end
local telescopeConfig = require("telescope.config")
-- Clone the default Telescope configuration
local vimgrep_arguments = { unpack(telescopeConfig.values.vimgrep_arguments) }
-- I want to search in hidden/dot files.
table.insert(vimgrep_arguments, "--hidden")
-- I don't want to search in the `.git` directory.
table.insert(vimgrep_arguments, "--glob")
table.insert(vimgrep_arguments, "!**/.git/*")
require('telescope').setup({ require('telescope').setup({
defaults = { defaults = {
mappings = { mappings = {
@ -126,6 +138,8 @@ return {
['<C-q>'] = actions.smart_send_to_qflist, ['<C-q>'] = actions.smart_send_to_qflist,
}, },
}, },
-- `hidden = true` is not supported in text grep commands.
vimgrep_arguments = vimgrep_arguments,
}, },
pickers = { pickers = {
-- Your special builtin config goes in here -- Your special builtin config goes in here
@ -145,6 +159,8 @@ return {
find_files = { find_files = {
theme = 'ivy', theme = 'ivy',
previewer = false, previewer = false,
-- `hidden = true` will still show the inside of `.git/` as it's not `.gitignore`d.
find_command = { "rg", "--files", "--hidden", "--glob", "!**/.git/*" },
}, },
oldfiles = { oldfiles = {
theme = 'ivy', theme = 'ivy',