Gaze deeply into unknown regions using the power of the moon.
What Is Telescope?
telescope.nvim is a highly extendable fuzzy finder over lists. Built on the
latest awesome features from neovim core. Telescope is centered around
modularity, allowing for easy customization.
We also suggest you install one native telescope sorter to significantly improve
sorting performance. Take a look at either
telescope-fzf-native.nvim
or
telescope-fzy-native.nvim.
For more information and a performance benchmark take a look at the
Extensions
wiki.
This section should help you explore available options to configure and
customize your telescope.nvim.
Unlike most vim plugins, telescope.nvim can be customized by either applying
customizations globally, or individually per picker.
Global Customization affecting all pickers can be done through the main
setup() method (see defaults below)
Individual Customization affecting a single picker by passing opts to
builtin pickers (e.g. builtin.find_files(opts)) see
Configuration recipes
wiki page for ideas.
Telescope setup structure
require('telescope').setup{
defaults = {
-- Default configuration for telescope goes here:-- config_key = value,
mappings = {
i = {
-- map actions.which_key to <C-h> (default: <C-/>)-- actions.which_key shows the mappings for your picker,-- e.g. git_{create, delete, ...}_branch for the git_branches picker
["<C-h>"] ="which_key"
}
}
},
pickers = {
-- Default configuration for builtin pickers goes here:-- picker_name = {-- picker_config_key = value,-- ...-- }-- Now the picker_config_key will be applied every time you call this-- builtin picker
},
extensions = {
-- Your extension configuration goes here:-- extension_name = {-- extension_config_key = value,-- }-- please take a look at the readme of the extension you want to configure
}
}
To look at what default configuration options exist please read: :help telescope.setup(). For picker specific opts please read: :help telescope.builtin.
To embed the above code snippet in a .vim file
(for example in after/plugin/telescope.nvim.vim),
wrap it in lua << EOF code-snippet EOF:
Mappings are fully customizable.
Many familiar mapping patterns are set up as defaults.
Mappings
Action
<C-n>/<Down>
Next item
<C-p>/<Up>
Previous item
j/k
Next/previous (in normal mode)
H/M/L
Select High/Middle/Low (in normal mode)
gg/G
Select the first/last item (in normal mode)
<CR>
Confirm selection
<C-x>
Go to file selection as a split
<C-v>
Go to file selection as a vsplit
<C-t>
Go to a file in a new tab
<C-u>
Scroll up in preview window
<C-d>
Scroll down in preview window
<C-/>
Show mappings for picker actions (insert mode)
?
Show mappings for picker actions (normal mode)
<C-c>
Close telescope
<Esc>
Close telescope (in normal mode)
<Tab>
Toggle selection and move to next selection
<S-Tab>
Toggle selection and move to prev selection
<C-q>
Send all items not filtered to quickfixlist (qflist)
<M-q>
Send all selected items to qflist
To see the full list of mappings, check out lua/telescope/mappings.lua and the
default_mappings table.
Tip: you can use <C-/> and ? in insert and normal mode, respectively, to show the actions mapped to your picker.
Much like builtin pickers, there are a number of
actions
you can pick from to remap your telescope buffer mappings, or create a new
custom action:
-- Built-in actionslocal transform_mod =require('telescope.actions.mt').transform_mod-- or create your custom actionlocal my_cool_custom_action =transform_mod({
x =function(prompt_bufnr)
print("This function ran after another action. Prompt_bufnr: ".. prompt_bufnr)
-- Enter your function logic here. You can take inspiration from lua/telescope/actions.luaend,
})
To remap telescope mappings, please read :help telescope.defaults.mappings.
To do picker specific mappings, its suggested to do this with the pickers
table in telescope.setup. Each picker accepts a mappings table like its
explained in :help telescope.defaults.mappings.
Pickers
Built-in functions. Ready to be bound to any key you like.
Lists files in your current working directory, respects .gitignore
builtin.git_files
Fuzzy search through the output of git ls-files command, respects .gitignore, optionally ignores untracked files
builtin.grep_string
Searches for the string under your cursor in your current working directory
builtin.live_grep
Search for a string in your current working directory and get results live as you type (respecting .gitignore)
Vim Pickers
Functions
Description
builtin.buffers
Lists open buffers in current neovim instance
builtin.oldfiles
Lists previously open files
builtin.commands
Lists available plugin/user commands and runs them on <cr>
builtin.tags
Lists tags in current directory with tag location file preview (users are required to run ctags -R to generate tags or update when introducing new changes)
builtin.command_history
Lists commands that were executed recently, and reruns them on <cr>
builtin.search_history
Lists searches that were executed recently, and reruns them on <cr>
builtin.help_tags
Lists available help tags and opens a new window with the relevant help info on <cr>
builtin.man_pages
Lists manpage entries, opens them in a help window on <cr>
builtin.marks
Lists vim marks and their value
builtin.colorscheme
Lists available colorschemes and applies them on <cr>
builtin.quickfix
Lists items in the quickfix list
builtin.quickfixhistory
Lists all quickfix lists in your history and open them with builtin.quickfix
builtin.loclist
Lists items from the current window's location list
builtin.jumplist
Lists Jump List entries
builtin.vim_options
Lists vim options, allows you to edit the current value on <cr>
builtin.registers
Lists vim registers, pastes the contents of the register on <cr>
builtin.autocommands
Lists vim autocommands and goes to their declaration on <cr>
builtin.spell_suggest
Lists spelling suggestions for the current word under the cursor, replaces word with selected suggestion on <cr>
builtin.keymaps
Lists normal mode keymappings
builtin.filetypes
Lists all available filetypes
builtin.highlights
Lists all available highlights
builtin.current_buffer_fuzzy_find
Live fuzzy search inside of the currently open buffer
builtin.current_buffer_tags
Lists all of the tags for the currently open buffer, with a preview
builtin.resume
Lists the results incl. multi-selections of the previous picker
builtin.pickers
Lists the previous pickers incl. multi-selections (see :h telescope.defaults.cache_picker)
Neovim LSP Pickers
Functions
Description
builtin.lsp_references
Lists LSP references for word under the cursor
builtin.lsp_incoming_calls
Lists LSP incoming calls for word under the cursor
builtin.lsp_outgoing_calls
Lists LSP outgoing calls for word under the cursor
builtin.lsp_document_symbols
Lists LSP document symbols in the current buffer
builtin.lsp_workspace_symbols
Lists LSP document symbols in the current workspace
builtin.lsp_dynamic_workspace_symbols
Dynamically Lists LSP for all workspace symbols
builtin.diagnostics
Lists Diagnostics for all open buffers or a specific buffer. Use option bufnr=0 for current buffer.
builtin.lsp_implementations
Goto the implementation of the word under the cursor if there's only one, otherwise show all options in Telescope
builtin.lsp_definitions
Goto the definition of the word under the cursor, if there's only one, otherwise show all options in Telescope
builtin.lsp_type_definitions
Goto the definition of the type of the word under the cursor, if there's only one, otherwise show all options in Telescope
Git Pickers
Functions
Description
builtin.git_commits
Lists git commits with diff preview, checkout action <cr>, reset mixed <C-r>m, reset soft <C-r>s and reset hard <C-r>h
builtin.git_bcommits
Lists buffer's git commits with diff preview and checks them out on <cr>
builtin.git_branches
Lists all branches with log preview, checkout action <cr>, track action <C-t> and rebase action<C-r>
builtin.git_status
Lists current changes per file with diff preview and add action. (Multi-selection still WIP)
builtin.git_stash
Lists stash items in current repository with ability to apply them on <cr>
Treesitter Picker
Functions
Description
builtin.treesitter
Lists Function names, variables, from Treesitter!
Lists Picker
Functions
Description
builtin.planets
Use the telescope...
builtin.builtin
Lists Built-in pickers and run them on <cr>.
builtin.reloader
Lists Lua modules and reload them on <cr>.
builtin.symbols
Lists symbols inside a file data/telescope-sources/*.json found in your rtp. More info and symbol sources can be found here
Previewers
Previewers
Description
previewers.vim_buffer_cat.new
Default previewer for files. Uses vim buffers
previewers.vim_buffer_vimgrep.new
Default previewer for grep and similar. Uses vim buffers
previewers.vim_buffer_qflist.new
Default previewer for qflist. Uses vim buffers
previewers.cat.new
Terminal previewer for files. Uses cat/bat
previewers.vimgrep.new
Terminal previewer for grep and similar. Uses cat/bat
previewers.qflist.new
Terminal previewer for qflist. Uses cat/bat
The default previewers are from now on vim_buffer_ previewers. They use vim
buffers for displaying files and use tree-sitter or regex for file highlighting.
These previewers are guessing the filetype of the selected file, so there might
be cases where they miss, leading to wrong highlights. This is because we can't
determine the filetype in the traditional way: We don't do bufload and instead
read the file asynchronously with vim.loop.fs_ and attach only a highlighter;
otherwise the speed of the previewer would slow down considerably. If you want
to configure more filetypes, take a look at
plenary wiki.
If you want to configure the vim_buffer_ previewer (e.g. you want the line to wrap), do this:
autocmdUserTelescopePreviewerLoadedsetlocalwrap
Sorters
Sorters
Description
sorters.get_fuzzy_file
Telescope's default sorter for files
sorters.get_generic_fuzzy_sorter
Telescope's default sorter for everything else
sorters.get_levenshtein_sorter
Using Levenshtein distance algorithm (don't use :D)
sorters.get_fzy_sorter
Using fzy algorithm
sorters.fuzzy_with_index_bias
Used to list stuff with consideration to when the item is added
A Sorter is called by the Picker on each item returned by the Finder. It
returns a number, which is equivalent to the "distance" between the current
prompt and the entry returned by a finder.
Layout (display)
Layout can be configured by choosing a specific layout_strategy and
specifying a particular layout_config for that strategy.
For more details on available strategies and configuration options,
see :help telescope.layout.
Some options for configuring sizes in layouts are "resolvable". This means that
they can take different forms, and will be interpreted differently according to
which form they take.
For example, if we wanted to set the width of a picker using the vertical
layout strategy to 50% of the screen width, we would specify that width
as 0.5, but if we wanted to specify the width to be exactly 80
characters wide, we would specify it as 80.
For more details on resolving sizes, see :help telescope.resolve.
As an example, if we wanted to specify the layout strategy and width,
but only for this instance, we could do something like:
请发表评论