Blob config/nvim/lua/config/telescope.lua
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
require('telescope').setup({
defaults = {
mappings = {
i = {
["<esc>"] = require('telescope.actions').close
},
},
},
pickers = {
find_files = {
theme = "ivy",
previewer = false
},
git_files = {
theme = "ivy",
previewer = false,
},
buffers = {
theme = "dropdown",
previewer = false,
sort_lastused = true,
mappings = {
i = {
["<c-d>"] = "delete_buffer",
},
},
},
spell_suggest = {
theme = "cursor"
},
},
})
function git_files_with_fallback()
-- TODO Maybe restore the functionality where
-- it would pass `-- path/to/current/buffer/directory`
-- to `git ls-files` when outside of the repository root
local opts = {}
local ok = pcall(require 'telescope.builtin'.git_files, opts)
if not ok then require 'telescope.builtin'.find_files(opts) end
end
local map = vim.keymap.set
local opts = { silent = true }
map('n', "<leader>f", "<cmd>lua git_files_with_fallback()<CR>", opts)
map('n', "<leader>b", ":Telescope buffers<CR>", opts)
map('n', "z=", ":Telescope spell_suggest<CR>", opts)
map('n', '<leader>d', '<cmd>Telescope diagnostics<CR>', opts)
map('n', '<leader>g', '<cmd>Telescope grep_string<CR>', opts)
map('n', '<leader>G', '<cmd>Telescope live_grep<CR>', opts)
|