86 lines
2.4 KiB
Lua
86 lines
2.4 KiB
Lua
local misc = require('core.misc')
|
|
local map = misc.map
|
|
|
|
return { 'nvim-telescope/telescope.nvim',
|
|
disable = vim.version().minor < 9,
|
|
requires = {
|
|
'nvim-lua/plenary.nvim',
|
|
{ 'nvim-telescope/telescope-fzf-native.nvim',
|
|
config = function()
|
|
vim.cmd.make()
|
|
end
|
|
}
|
|
},
|
|
function()
|
|
local telescope = require("telescope")
|
|
local actions = require('telescope.actions')
|
|
local action_layout = require("telescope.actions.layout")
|
|
|
|
local function telescopew()
|
|
if vim.o.columns <= 80 then
|
|
return vim.o.columns
|
|
else
|
|
return 0.8
|
|
end
|
|
end
|
|
|
|
telescope.setup {
|
|
defaults = {
|
|
borderchars = {
|
|
prompt = { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },
|
|
results = { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },
|
|
preview = { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' },
|
|
},
|
|
winblend = 0,
|
|
layout_strategy = 'horizontal',
|
|
sorting_strategy = 'descending',
|
|
scroll_strategy = 'limit',
|
|
layout_config = {
|
|
horizontal = {
|
|
width = telescopew(),
|
|
height = 20,
|
|
prompt_position = 'bottom',
|
|
anchor = 'N',
|
|
}
|
|
},
|
|
mappings = {
|
|
i = {
|
|
["<esc>"] = actions.close,
|
|
['<C-j>'] = actions.move_selection_next,
|
|
['<C-k>'] = actions.move_selection_previous,
|
|
['<C-l>'] = actions.select_default,
|
|
['<C-u>'] = actions.preview_scrolling_up,
|
|
['<C-d>'] = actions.preview_scrolling_down,
|
|
["<C-p>"] = action_layout.toggle_preview
|
|
},
|
|
n = {
|
|
["gg"] = actions.move_to_top,
|
|
["G"] = actions.move_to_bottom,
|
|
}
|
|
}
|
|
},
|
|
extensions = {
|
|
fzf = {}
|
|
}
|
|
}
|
|
|
|
-- load in the fzf extension
|
|
telescope.load_extension('fzf')
|
|
|
|
-- keymaps
|
|
local telebuilt = require('telescope.builtin')
|
|
map('n', '<leader>f', function()
|
|
telebuilt.fd { follow = true }
|
|
end, { desc = 'Find files.' })
|
|
map('n', '<leader>s', telebuilt.live_grep, { desc = 'Find string in project.' })
|
|
map('n', '<leader>b', telebuilt.current_buffer_fuzzy_find, {
|
|
desc = 'Find string in current buffer.',
|
|
})
|
|
|
|
-- enable previewing in the default colorscheme switcher
|
|
telebuilt.colorscheme = function()
|
|
require("telescope.builtin.__internal").colorscheme { enable_preview = true }
|
|
end
|
|
end
|
|
}
|