Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include specific hidden file/folder in search result when using telescope.nvim?

I'm using neovim and Telescope as a finder (find_files, live_grep, file_browser), by default Telescope is ignoring hidden files and files included in .gitignore - how can I add exception (e.g. .gitlab-ci file/folder) to this list? so Telescope will still ignore hidden files except .gitlab-ci file/folder?

like image 225
Michu Avatar asked Dec 22 '25 02:12

Michu


1 Answers

Telescope uses ripgrep to search through files. By default, ripgrep ignores several groups of files, including hidden files (dotfiles) and files ignored by git. Adding --no-ignore-vcs and --hidden flags will make it to search through those files.

Arguments for ripgrep can be configured via defaults.vimgrep_arguments. In your case, to search through hidden files, which are not in .gitignore --hidden flag should be added:

require('telescope').setup{
  defaults = {
    vimgrep_arguments = {
      'rg',
      '--color=never',
      '--no-heading',
      '--with-filename',
      '--line-number',
      '--column',
      '--smart-case',
      '--hidden',
    },
}

You can always test the command from the terminal before changing the Telescope configuration:

rg ... --hidden <search string>

As --hidden will enable search through all hidden files, you might want to look into .ignore or .rgignore files. They tell ripgrep which files to ignore during search. See ripgrep's documentation for more info.

like image 52
German Lashevich Avatar answered Dec 24 '25 11:12

German Lashevich



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!