How to configure the Telescope Neovim plugin
Telescope is a plugin for the Neovim text editor that provides a convenient and general interface for fuzzy searching over lists. In practice, it’s mainly used for quickly finding files from parts of their paths or from their contents, but has many other applications. It’s fast and operation is smooth, popping up a floating window with results that update as quickly as you type. It’s no wonder that every Neovim user seems to have installed it.
However, its documentation is obscure for the beginner, and information on the Web is fragmentary and often contradictory. Since the first task a new user would often like to do is to adjust some of Telescope’s settings, a simple example of how to do this might be useful.
If you’re coming from Vim you probably have an init.vim
configuration file for Neovim, in which case you place the following bit of code, and any other Lua bits, between the lines lua << END
and END
within that file. If you’re using an init.lua
startup file instead, you can insert the code without its bookends.
This little bit of Lua sets two overall defaults for Telescope and one for its file-finding component:
require('telescope').setup{
= {
defaults = "limit";
scroll_strategy = { ".git/[^h]" };
file_ignore_patterns },
= {
pickers = {
find_files = true;
hidden }
}
}
The scroll_strategy
setting will establish hard boundaries when you move your cursor to the top or bottom of the list of results that Telescope presents in its floating window; the default is to have periodic boundaries.
The file_ignore_patterns
setting tells Telescope not to peer within my .git
directories, because I rarely want to open files in there, except that I do sometimes want to edit my git hooks. The hooks
directory is the only one starting with “h”.
The hidden
setting tells Telescope’s file finder to show me “hidden” files along with the others. These are files beginning with a dot, that the ls
command (for example) spares you the sight of by default. But I want to see them, so that I can easily edit my .bashrc
and other startup files.
With this beginning I think it’s easier to dive into Telescope’s help file, available within Neovim, where you can find a bunch of other settings for the various pickers, sorters, greppers, and for overall Telescope defaults.