telescope.lua 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. local status_ok, telescope = pcall(require, "telescope")
  2. if not status_ok then
  3. return
  4. end
  5. telescope.load_extension('media_files')
  6. local actions = require "telescope.actions"
  7. telescope.setup {
  8. defaults = {
  9. prompt_prefix = " ",
  10. selection_caret = " ",
  11. path_display = { "smart" },
  12. mappings = {
  13. i = {
  14. ["<C-n>"] = actions.cycle_history_next,
  15. ["<C-p>"] = actions.cycle_history_prev,
  16. ["<C-j>"] = actions.move_selection_next,
  17. ["<C-k>"] = actions.move_selection_previous,
  18. ["<C-c>"] = actions.close,
  19. ["<CR>"] = actions.select_default,
  20. ["<C-x>"] = actions.select_horizontal,
  21. ["<C-v>"] = actions.select_vertical,
  22. ["<C-t>"] = actions.select_tab,
  23. -- use arrow key
  24. ["<Down>"] = actions.move_selection_next,
  25. ["<Up>"] = actions.move_selection_previous,
  26. -- scrolling up and down the preview
  27. ["<C-u>"] = actions.preview_scrolling_up,
  28. ["<C-d>"] = actions.preview_scrolling_down,
  29. ["<PageUp>"] = actions.results_scrolling_up,
  30. ["<PageDown>"] = actions.results_scrolling_down,
  31. ["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
  32. ["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
  33. ["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
  34. ["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
  35. ["<C-l>"] = actions.complete_tag,
  36. ["<C-_>"] = actions.which_key, -- keys from pressing <C-/>
  37. },
  38. n = {
  39. ["<esc>"] = actions.close,
  40. ["<CR>"] = actions.select_default,
  41. ["<C-x>"] = actions.select_horizontal,
  42. ["<C-v>"] = actions.select_vertical,
  43. ["<C-t>"] = actions.select_tab,
  44. ["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
  45. ["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
  46. ["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
  47. ["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
  48. ["?"] = actions.which_key,
  49. -- standard vim-like keys
  50. ["j"] = actions.move_selection_next,
  51. ["<Down>"] = actions.move_selection_next,
  52. ["k"] = actions.move_selection_previous,
  53. ["<Up>"] = actions.move_selection_previous,
  54. ["H"] = actions.move_to_top,
  55. ["M"] = actions.move_to_middle,
  56. ["L"] = actions.move_to_bottom,
  57. ["gg"] = actions.move_to_top,
  58. ["G"] = actions.move_to_bottom,
  59. -- scrolling up and down the preview
  60. ["<C-u>"] = actions.preview_scrolling_up,
  61. ["<C-d>"] = actions.preview_scrolling_down,
  62. ["<PageUp>"] = actions.results_scrolling_up,
  63. ["<PageDown>"] = actions.results_scrolling_down,
  64. },
  65. },
  66. },
  67. pickers = {
  68. -- Default configuration for builtin pickers goes here:
  69. -- picker_name = {
  70. -- picker_config_key = value,
  71. -- ...
  72. -- }
  73. -- Now the picker_config_key will be applied every time you call this
  74. -- builtin picker
  75. },
  76. extensions = {
  77. media_files = {
  78. -- filetypes whitelist
  79. -- defaults to {"png", "jpg", "mp4", "webm", "pdf"}
  80. filetypes = {"png", "webp", "jpg", "jpeg"},
  81. find_cmd = "rg" -- find command (defaults to `fd`)
  82. }
  83. -- Your extension configuration goes here:
  84. -- extension_name = {
  85. -- extension_config_key = value,
  86. -- }
  87. -- please take a look at the readme of the extension you want to configure
  88. },
  89. }