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.

95 lines
2.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 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. initial_mode = "insert",
  18. selection_strategy = "reset",
  19. sorting_strategy = "ascending",
  20. layout_strategy = "horizontal",
  21. layout_config = {
  22. horizontal = {
  23. prompt_position = "top",
  24. preview_width = 0.55,
  25. results_width = 0.8,
  26. },
  27. vertical = {
  28. mirror = false,
  29. },
  30. width = 0.87,
  31. height = 0.80,
  32. preview_cutoff = 120,
  33. },
  34. path_display = { "truncate" },
  35. winblend = 0,
  36. border = {},
  37. borderchars = { "", "", "", "", "", "", "", "" },
  38. mappings = {
  39. i = {
  40. ['<C-x>'] = false,
  41. ['<C-q>'] = actions.send_to_qflist,
  42. },
  43. },
  44. },
  45. })
  46. function git_branches ()
  47. builtin.git_branches({
  48. attach_mappings = function(_, map)
  49. map("i", "<c-d>", actions.git_delete_branch)
  50. map("n", "<c-d>", actions.git_delete_branch)
  51. return true
  52. end,
  53. })
  54. end
  55. function files ()
  56. local ran, errorMessage = pcall(function()
  57. builtin.git_files({ show_untracked = true })
  58. end)
  59. if not ran then
  60. builtin.find_files()
  61. end
  62. end
  63. local options = { noremap = true }
  64. vim.keymap.set('n', '<C-g>', builtin.live_grep, options)
  65. vim.keymap.set('n', '<C-p>', files, options)
  66. vim.keymap.set('n', '<leader>df', function()
  67. builtin.find_files({
  68. prompt_title = "< VimRC >",
  69. cwd = vim.fn.expand('~/.config/nvim'),
  70. hidden = true,
  71. })
  72. end, options)
  73. vim.keymap.set('n', '<leader>fb', builtin.buffers, options)
  74. vim.keymap.set('n', '<leader>fo', builtin.oldfiles, options)
  75. vim.keymap.set('n', '<leader>gr', builtin.lsp_references, options)
  76. vim.keymap.set("n", '<leader>gi', builtin.lsp_implementations, options)
  77. vim.keymap.set("n", '<leader>gT', builtin.lsp_type_definitions, options)
  78. vim.keymap.set('n', '<leader>m', builtin.marks, options)
  79. vim.keymap.set('n', '<leader>ch', builtin.command_history, options)
  80. vim.keymap.set('n', '<leader>gb', git_branches, options)
  81. vim.keymap.set('n', '<leader>gs', builtin.git_status, options)