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.

83 lines
2.5 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-g>', require('telescope.builtin').live_grep, options)
  42. vim.keymap.set('n', '<C-p>', function()
  43. local ran, errorMessage = pcall(function()
  44. require('telescope.builtin').git_files({ show_untracked = true })
  45. end)
  46. if not ran then
  47. require('telescope.builtin').find_files()
  48. end
  49. end, options)
  50. vim.keymap.set('n', '<A-p>', function()
  51. require('telescope.builtin').find_files()
  52. end, options)
  53. vim.keymap.set('n', '<leader>df', function()
  54. require("telescope.builtin").find_files({
  55. prompt_title = "< VimRC >",
  56. cwd = vim.fn.expand('~/.config/nvim'),
  57. hidden = true,
  58. })
  59. end, options)
  60. -- vim.keymap.set('n', '<C-q>', function()
  61. -- end, options)
  62. vim.keymap.set('n', '<leader>fb', require('telescope.builtin').buffers, options)
  63. vim.keymap.set('n', '<leader>fo', require('telescope.builtin').oldfiles, options)
  64. vim.keymap.set('n', 'gr', require('telescope.builtin').lsp_references, options)
  65. vim.keymap.set('n', '<leader>m', require('telescope.builtin').marks, options)
  66. vim.keymap.set('n', '<leader>ch', require('telescope.builtin').command_history, options)
  67. vim.keymap.set('n', '<leader>gb', git_branches, options)
  68. vim.keymap.set('n', '<leader>gs', require('telescope.builtin').git_status, options)