Skip to main content

Telescope

info

You can enable the extra with the :LazyExtras command. Plugins marked as optional will only be configured if they are installed.

Alternatively, you can add it to your lazy.nvim imports
lua/config/lazy.lua
require("lazy").setup({
spec = {
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
{ import = "lazyvim.plugins.extras.editor.telescope" },
{ import = "plugins" },
},
})

Options

Additional options for this extra can be configured in your lua/config/options.lua file:

lua/config/options.lua
-- In case you don't want to use `:LazyExtras`,
-- then you need to set the option below.
vim.g.lazyvim_picker = "telescope"

Below you can find a list of included plugins and their default settings.

caution

You don't need to copy the default settings to your config. They are only shown here for reference.

telescope.nvim

Fuzzy finder. The default key bindings to find files will use Telescope's find_files or git_files depending on whether the directory is a git repo.

opts = function()
local actions = require("telescope.actions")

local open_with_trouble = function(...)
return require("trouble.sources.telescope").open(...)
end
local find_files_no_ignore = function()
local action_state = require("telescope.actions.state")
local line = action_state.get_current_line()
LazyVim.pick("find_files", { no_ignore = true, default_text = line })()
end
local find_files_with_hidden = function()
local action_state = require("telescope.actions.state")
local line = action_state.get_current_line()
LazyVim.pick("find_files", { hidden = true, default_text = line })()
end

local function find_command()
if 1 == vim.fn.executable("rg") then
return { "rg", "--files", "--color", "never", "-g", "!.git" }
elseif 1 == vim.fn.executable("fd") then
return { "fd", "--type", "f", "--color", "never", "-E", ".git" }
elseif 1 == vim.fn.executable("fdfind") then
return { "fdfind", "--type", "f", "--color", "never", "-E", ".git" }
elseif 1 == vim.fn.executable("find") and vim.fn.has("win32") == 0 then
return { "find", ".", "-type", "f" }
elseif 1 == vim.fn.executable("where") then
return { "where", "/r", ".", "*" }
end
end

return {
defaults = {
prompt_prefix = " ",
selection_caret = " ",
-- open files in the first window that is an actual file.
-- use the current window if no other window is available.
get_selection_window = function()
local wins = vim.api.nvim_list_wins()
table.insert(wins, 1, vim.api.nvim_get_current_win())
for _, win in ipairs(wins) do
local buf = vim.api.nvim_win_get_buf(win)
if vim.bo[buf].buftype == "" then
return win
end
end
return 0
end,
mappings = {
i = {
["<c-t>"] = open_with_trouble,
["<a-t>"] = open_with_trouble,
["<a-i>"] = find_files_no_ignore,
["<a-h>"] = find_files_with_hidden,
["<C-Down>"] = actions.cycle_history_next,
["<C-Up>"] = actions.cycle_history_prev,
["<C-f>"] = actions.preview_scrolling_down,
["<C-b>"] = actions.preview_scrolling_up,
},
n = {
["q"] = actions.close,
},
},
},
pickers = {
find_files = {
find_command = find_command,
hidden = true,
},
},
}
end

dressing.nvim

better vim.ui with telescope

opts = nil

telescope.nvim

Flash Telescope config

opts = function(_, opts)
if not LazyVim.has("flash.nvim") then
return
end
local function flash(prompt_bufnr)
require("flash").jump({
pattern = "^",
label = { after = { 0, 0 } },
search = {
mode = "search",
exclude = {
function(win)
return vim.bo[vim.api.nvim_win_get_buf(win)].filetype ~= "TelescopeResults"
end,
},
},
action = function(match)
local picker = require("telescope.actions.state").get_current_picker(prompt_bufnr)
picker:set_selection(match.pos[1] - 1)
end,
})
end
opts.defaults = vim.tbl_deep_extend("force", opts.defaults or {}, {
mappings = { n = { s = flash }, i = { ["<c-s>"] = flash } },
})
end

telescope-fzf-native.nvim

opts = {}

nvim-lspconfig

opts = function()
if LazyVim.pick.want() ~= "telescope" then
return
end
local Keys = require("lazyvim.plugins.lsp.keymaps").get()
-- stylua: ignore
vim.list_extend(Keys, {
{ "gd", function() require("telescope.builtin").lsp_definitions({ reuse_win = true }) end, desc = "Goto Definition", has = "definition" },
{ "gr", "<cmd>Telescope lsp_references<cr>", desc = "References", nowait = true },
{ "gI", function() require("telescope.builtin").lsp_implementations({ reuse_win = true }) end, desc = "Goto Implementation" },
{ "gy", function() require("telescope.builtin").lsp_type_definitions({ reuse_win = true }) end, desc = "Goto T[y]pe Definition" },
})
end