telescope.lua 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. O.plugin.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" },
  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-c>"] = actions.close,
  50. ["<C-j>"] = actions.move_selection_next,
  51. ["<C-k>"] = actions.move_selection_previous,
  52. ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
  53. ["<CR>"] = actions.select_default + actions.center,
  54. -- To disable a keymap, put [map] = false
  55. -- So, to not map "<C-n>", just put
  56. -- ["<c-t>"] = trouble.open_with_trouble,
  57. -- ["<c-x>"] = false,
  58. -- ["<esc>"] = actions.close,
  59. -- Otherwise, just set the mapping to the function that you want it to be.
  60. -- ["<C-i>"] = actions.select_horizontal,
  61. -- Add up multiple actions
  62. -- You can perform as many actions in a row as you like
  63. -- ["<CR>"] = actions.select_default + actions.center + my_cool_custom_action,
  64. },
  65. n = {
  66. ["<C-j>"] = actions.move_selection_next,
  67. ["<C-k>"] = actions.move_selection_previous,
  68. ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
  69. -- ["<c-t>"] = trouble.open_with_trouble,
  70. -- ["<C-i>"] = my_cool_custom_action,
  71. },
  72. },
  73. },
  74. extensions = {
  75. fzy_native = {
  76. override_generic_sorter = false,
  77. override_file_sorter = true,
  78. },
  79. },
  80. }
  81. end
  82. M.setup = function()
  83. local status_ok, telescope = pcall(require, "telescope")
  84. if not status_ok then
  85. return
  86. end
  87. telescope.setup(O.plugin.telescope)
  88. vim.api.nvim_set_keymap("n", "<Leader>f", ":Telescope find_files<CR>", { noremap = true, silent = true })
  89. end
  90. return M