nixos-configuration/users/jrpotter/neovim/config/utils/telescope.lua

61 lines
1.4 KiB
Lua
Raw Normal View History

2023-11-24 15:21:43 +00:00
local M = {}
local function set_telescope_map(key, picker)
vim.keymap.set(
2024-03-05 03:10:57 +00:00
"n",
string.format("<c-;>%s", key),
string.format("<cmd>Telescope %s<cr>", picker)
2023-11-24 15:21:43 +00:00
)
vim.keymap.set(
2024-03-05 03:10:57 +00:00
"n",
string.format("<c-;><c-%s>", key),
string.format("<cmd>Telescope %s<cr>", picker)
2023-11-24 15:21:43 +00:00
)
end
function M.setup()
2024-03-05 03:10:57 +00:00
require("telescope").setup {
defaults = {
mappings = {
i = {
2024-03-05 03:10:57 +00:00
["<c-s>"] = "select_horizontal",
["<c-t>"] = "select_tab",
["<c-v>"] = "select_vertical",
["<esc>"] = "close",
},
},
},
2023-11-24 15:21:43 +00:00
pickers = {
2024-03-05 03:10:57 +00:00
buffers = { theme = "ivy" },
find_files = { theme = "ivy" },
live_grep = { theme = "ivy" },
lsp_definitions = { theme = "cursor" },
lsp_implementations = { theme = "cursor" },
lsp_type_definitions = { theme = "cursor" },
lsp_workspace_symbols = { theme = "ivy" },
2023-11-24 15:21:43 +00:00
},
}
-- General
2024-03-05 03:10:57 +00:00
set_telescope_map(";", "resume")
set_telescope_map("b", "buffers")
set_telescope_map("f", "find_files")
set_telescope_map("g", "live_grep")
2023-11-24 15:21:43 +00:00
-- LSP
2024-03-05 03:10:57 +00:00
set_telescope_map("?", "diagnostics")
set_telescope_map("]", "lsp_definitions")
set_telescope_map("i", "lsp_implementations")
set_telescope_map("s", "lsp_workspace_symbols")
set_telescope_map("t", "lsp_type_definitions")
2023-11-24 15:21:43 +00:00
2024-03-05 03:10:57 +00:00
vim.api.nvim_create_autocmd("User", {
pattern = "TelescopePreviewerLoaded",
2023-11-24 15:21:43 +00:00
callback = function()
vim.wo.wrap = true
end,
})
end
return M