chore: better telescope layouts

This commit is contained in:
əlemi 2022-09-21 12:07:07 +02:00
parent 61681bf7d8
commit 1c5f7f48c7
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 27 additions and 10 deletions

View file

@ -98,27 +98,27 @@ function KEYBINDS:set_telescope_keys(opts)
local telescope = require('telescope.builtin')
local theme = require('telescope.themes')
-- File navigation
vim.keymap.set('n', '<C-ESC>', telescope.oldfiles, opts)
vim.keymap.set('n', '<M-!>', telescope.oldfiles, opts) -- fallback for windows... even <M-Esc> is used
vim.keymap.set('n', '<C-ESC>', wrap(telescope.oldfiles, {layout_strategy = 'vertical' }), opts)
vim.keymap.set('n', '<M-!>', wrap(telescope.oldfiles, {layout_strategy = 'vertical' }), opts) -- fallback for windows... even <M-Esc> is used
vim.keymap.set('n', '<C-f>', telescope.find_files, opts)
vim.keymap.set('n', '<M-f>', telescope.find_files, opts) -- fallback for windows
vim.keymap.set('n', '<C-,>', telescope.live_grep, opts)
vim.keymap.set('n', '<M-,>', telescope.live_grep, opts) -- fallback for windows
vim.keymap.set('n', '<C-,>', wrap(telescope.live_grep, {layout_strategy = 'vertical'}), opts)
vim.keymap.set('n', '<M-,>', wrap(telescope.live_grep, {layout_strategy = 'vertical'}), opts) -- fallback for windows
vim.keymap.set('n', '<C-[>', wrap(telescope.lsp_references, theme.get_cursor()), opts)
vim.keymap.set('n', '<M-[>', wrap(telescope.lsp_references, theme.get_cursor()), opts) -- fallback for windows
vim.keymap.set('n', '<C-;>', telescope.git_bcommits, opts)
vim.keymap.set('n', '<M-;>', telescope.git_bcommits, opts) -- fallback for windows
vim.keymap.set('n', '<M-=>', telescope.registers, opts) -- fallback for windows
vim.keymap.set('n', '<M-=>', wrap(telescope.registers, theme.get_dropdown()), opts) -- fallback for windows
-- Marks and buffers with telescope
vim.keymap.set('n', '<C-End>', telescope.buffers, opts)
vim.keymap.set('n', '<C-\'>', wrap(telescope.marks, theme.get_dropdown()), opts)
vim.keymap.set('n', '<M-\'>', wrap(telescope.marks, theme.get_dropdown()), opts) -- fallback for windows
vim.keymap.set('n', '<C-/>', wrap(telescope.current_buffer_fuzzy_find, theme.get_dropdown()), opts)
vim.keymap.set('n', '<M-/>', wrap(telescope.current_buffer_fuzzy_find, theme.get_dropdown()), opts) -- fallback for windows
vim.keymap.set('n', '<C-/>', wrap(telescope.current_buffer_fuzzy_find, {layout_strategy = 'vertical'}), opts)
vim.keymap.set('n', '<M-/>', wrap(telescope.current_buffer_fuzzy_find, {layout_strategy = 'vertical'}), opts) -- fallback for windows
-- Symbols with telescope
vim.keymap.set('n', '<C-\\>', telescope.lsp_document_symbols, opts)
vim.keymap.set('n', '<C-CR>', telescope.lsp_workspace_symbols, opts)
vim.keymap.set('n', '<NL>', telescope.lsp_workspace_symbols, opts) -- fallback for windows
vim.keymap.set('n', '<C-CR>', wrap(telescope.lsp_workspace_symbols, {layout_strategy = 'vertical'}), opts)
vim.keymap.set('n', '<NL>', wrap(telescope.lsp_workspace_symbols, {layout_strategy = 'vertical'}), opts) -- fallback for windows
-- Error list with telescope
vim.keymap.set('n', '<C-PageUp>', wrap(telescope.diagnostics, theme.get_ivy()), opts)
vim.keymap.set('n', '<C-PageDown>', wrap(telescope.diagnostics, theme.get_ivy({bufnr=0})), opts)

View file

@ -119,7 +119,24 @@ local init_fn = function(use)
{'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }, -- fzf algorithm implemented in C for faster searches
},
config = function()
require('telescope').load_extension('fzf')
local telescope = require('telescope')
telescope.load_extension('fzf')
telescope.setup({
defaults = {
path_display = { "truncate" },
layout_config = {
horizontal = {
preview_width = 0.65,
results_width = 0.7,
},
vertical = {
mirror = false,
},
height = 0.9,
width = 0.9
},
}
})
require('keybinds'):set_telescope_keys({})
end
}