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.

76 lines
2.1 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 builtin = require('telescope.builtin')
  7. local sorters = require('telescope.sorters')
  8. local actions = require('telescope.actions')
  9. require('telescope').setup({
  10. defaults = {
  11. file_sorter = sorters.get_fzy_sorter,
  12. prompt_prefix = ' >',
  13. color_devicons = true,
  14. file_previewer = previewers.vim_buffer_cat.new,
  15. grep_previewer = previewers.vim_buffer_vimgrep.new,
  16. qflist_previewer = previewers.vim_buffer_qflist.new,
  17. mappings = {
  18. i = {
  19. ['<C-x>'] = false,
  20. ['<C-q>'] = actions.send_to_qflist,
  21. },
  22. },
  23. },
  24. })
  25. local M = {}
  26. function git_branches ()
  27. builtin.git_branches({
  28. attach_mappings = function(_, map)
  29. map("i", "<c-d>", actions.git_delete_branch)
  30. map("n", "<c-d>", actions.git_delete_branch)
  31. return true
  32. end,
  33. })
  34. end
  35. function files ()
  36. local ran, errorMessage = pcall(function()
  37. builtin.git_files({ show_untracked = true })
  38. end)
  39. if not ran then
  40. builtin.find_files()
  41. end
  42. end
  43. local options = { noremap = true }
  44. vim.keymap.set('n', '<C-g>', builtin.live_grep, options)
  45. vim.keymap.set('n', '<C-p>', files, options)
  46. vim.keymap.set('n', '<leader>df', function()
  47. builtin.find_files({
  48. prompt_title = "< VimRC >",
  49. cwd = vim.fn.expand('~/.config/nvim'),
  50. hidden = true,
  51. })
  52. end, options)
  53. vim.keymap.set('n', '<leader>fb', builtin.buffers, options)
  54. vim.keymap.set('n', '<leader>fo', builtin.oldfiles, options)
  55. vim.keymap.set('n', 'gr', builtin.lsp_references, options)
  56. vim.keymap.set("n", 'gd', builtin.lsp_definitions, options)
  57. vim.keymap.set("n", 'gi', builtin.lsp_implementations, options)
  58. vim.keymap.set("n", 'gT', builtin.lsp_type_definitions, options)
  59. vim.keymap.set('n', '<leader>m', builtin.marks, options)
  60. vim.keymap.set('n', '<leader>ch', builtin.command_history, options)
  61. vim.keymap.set('n', '<leader>gb', git_branches, options)
  62. vim.keymap.set('n', '<leader>gs', builtin.git_status, options)