You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.7 KiB

  1. local pickers = require("telescope.pickers")
  2. local finders = require("telescope.finders")
  3. local previewers = require("telescope.previewers")
  4. local action_state = require("telescope.actions.state")
  5. local conf = require("telescope.config").values
  6. local actions = require("telescope.actions")
  7. require("telescope").setup({
  8. defaults = {
  9. file_sorter = require("telescope.sorters").get_fzy_sorter,
  10. prompt_prefix = " >",
  11. color_devicons = true,
  12. file_previewer = require("telescope.previewers").vim_buffer_cat.new,
  13. grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new,
  14. qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new,
  15. mappings = {
  16. i = {
  17. ["<C-x>"] = false,
  18. ["<C-q>"] = actions.send_to_qflist,
  19. },
  20. },
  21. },
  22. })
  23. local M = {}
  24. function git_branches ()
  25. require("telescope.builtin").git_branches({
  26. attach_mappings = function(_, map)
  27. map("i", "<c-d>", actions.git_delete_branch)
  28. map("n", "<c-d>", actions.git_delete_branch)
  29. return true
  30. end,
  31. })
  32. end
  33. local options = { noremap = true }
  34. vim.keymap.set('n', '<C-g>', function()
  35. local term = vim.fn.input("Grep For > ")
  36. if term == '' then
  37. return
  38. end
  39. require('telescope.builtin').grep_string({ search = term })
  40. end, options)
  41. vim.keymap.set('n', '<C-p>', function()
  42. local ran, errorMessage = pcall(require('telescope.builtin').git_files)
  43. if not ran then
  44. require('telescope.builtin').find_files()
  45. end
  46. end, options)
  47. -- vim.keymap.set('n', '<C-q>', function()
  48. -- end, options)
  49. vim.keymap.set('n', '<leader>fb', require('telescope.builtin').buffers, options)
  50. vim.keymap.set('n', 'gr', require('telescope.builtin').lsp_references, options)