telescope.lua 3.2 KB

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