telescope.lua 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. local M = {}
  2. M.config = function()
  3. local status_ok, actions = pcall(require, "telescope.actions")
  4. if not status_ok then
  5. return
  6. end
  7. lvim.builtin.telescope = {
  8. active = false,
  9. defaults = {
  10. prompt_prefix = " ",
  11. selection_caret = " ",
  12. entry_prefix = " ",
  13. initial_mode = "insert",
  14. selection_strategy = "reset",
  15. sorting_strategy = "descending",
  16. layout_strategy = "horizontal",
  17. layout_config = {
  18. width = 0.75,
  19. prompt_position = "bottom",
  20. preview_cutoff = 120,
  21. horizontal = { mirror = false },
  22. vertical = { mirror = false },
  23. },
  24. file_sorter = require("telescope.sorters").get_fzy_sorter,
  25. file_ignore_patterns = {},
  26. generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter,
  27. path_display = { shorten = 5 },
  28. winblend = 0,
  29. border = {},
  30. borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" },
  31. color_devicons = true,
  32. use_less = true,
  33. set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil,
  34. file_previewer = require("telescope.previewers").vim_buffer_cat.new,
  35. grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new,
  36. qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new,
  37. -- Developer configurations: Not meant for general override
  38. -- buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker,
  39. mappings = {
  40. i = {
  41. ["<C-n>"] = actions.cycle_history_next,
  42. ["<C-p>"] = actions.cycle_history_prev,
  43. ["<C-c>"] = actions.close,
  44. ["<C-j>"] = actions.move_selection_next,
  45. ["<C-k>"] = actions.move_selection_previous,
  46. ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
  47. ["<CR>"] = actions.select_default + actions.center,
  48. -- To disable a keymap, put [map] = false
  49. -- So, to not map "<C-n>", just put
  50. -- ["<c-t>"] = trouble.open_with_trouble,
  51. -- ["<c-x>"] = false,
  52. -- ["<esc>"] = actions.close,
  53. -- Otherwise, just set the mapping to the function that you want it to be.
  54. -- ["<C-i>"] = actions.select_horizontal,
  55. -- Add up multiple actions
  56. -- You can perform as many actions in a row as you like
  57. -- ["<CR>"] = actions.select_default + actions.center + my_cool_custom_action,
  58. },
  59. n = {
  60. ["<C-j>"] = actions.move_selection_next,
  61. ["<C-k>"] = actions.move_selection_previous,
  62. ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
  63. -- ["<c-t>"] = trouble.open_with_trouble,
  64. -- ["<C-i>"] = my_cool_custom_action,
  65. },
  66. },
  67. },
  68. extensions = {
  69. fzy_native = {
  70. override_generic_sorter = false,
  71. override_file_sorter = true,
  72. },
  73. },
  74. }
  75. end
  76. M.setup = function()
  77. local status_ok, telescope = pcall(require, "telescope")
  78. if not status_ok then
  79. return
  80. end
  81. telescope.setup(lvim.builtin.telescope)
  82. end
  83. return M