qol.lua 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. return {
  2. "folke/snacks.nvim",
  3. dependencies = {
  4. "nvim-lua/plenary.nvim",
  5. },
  6. priority = 1000,
  7. init = function()
  8. local group = vim.api.nvim_create_augroup("BlinkCmpSnacksToggle", { clear = true })
  9. vim.api.nvim_create_autocmd("User", {
  10. group = group,
  11. pattern = "BlinkCmpMenuOpen",
  12. callback = function()
  13. vim.g.snacks_animate = false
  14. end,
  15. })
  16. vim.api.nvim_create_autocmd("User", {
  17. group = group,
  18. pattern = "BlinkCmpMenuClose",
  19. callback = function()
  20. vim.g.snacks_animate = true
  21. end,
  22. })
  23. end,
  24. config = function()
  25. local snacks = require("snacks")
  26. snacks.setup({
  27. bigfile = { enabled = true },
  28. input = {
  29. enabled = true,
  30. prompt_pos = "left",
  31. icon_pos = "left",
  32. expand = false,
  33. win = {
  34. row = 0.4,
  35. position = "float",
  36. border = "rounded",
  37. },
  38. },
  39. select = {
  40. enabled = true,
  41. win = { border = "rounded" },
  42. },
  43. debug = { enabled = true },
  44. indent = { enabled = true, animate = { enabled = false } },
  45. rename = { enabled = true },
  46. notifier = { enabled = true },
  47. scroll = {
  48. enabled = true,
  49. animate = {
  50. duration = { step = 5, total = 50 },
  51. easing = "linear",
  52. },
  53. },
  54. dashboard = {
  55. preset = {
  56. keys = function()
  57. return {
  58. { icon = "⏻", key = "q", desc = "Quit", action = "<cmd>qa<CR>" },
  59. { icon = "󱇧", key = "e", desc = "New Buffer", action = "<cmd>ene<CR>" },
  60. }
  61. end,
  62. header = table.concat({
  63. [[ █ █ ]],
  64. [[ █ ██ ]],
  65. [[ ████ ]],
  66. [[ ██ ███ ]],
  67. [[ █ █ ]],
  68. [[ ]],
  69. [[ n e o v i m ]],
  70. }, "\n"),
  71. },
  72. sections = {
  73. {
  74. section = "header",
  75. },
  76. { title = "MRU ", file = vim.fn.fnamemodify(".", ":~"), padding = 1 },
  77. { section = "recent_files", cwd = true, limit = 10, padding = 1 },
  78. { title = "GMRU", padding = 1 },
  79. { section = "recent_files", limit = 5, padding = 1 },
  80. { title = "Sessions", padding = 1 },
  81. { section = "projects", padding = 1 },
  82. { section = "keys", gap = 0, padding = 1 },
  83. },
  84. },
  85. })
  86. -- Show notifier history
  87. nmap("<leader>ns", snacks.notifier.show_history, { desc = "Show notifier history" })
  88. -- -----------------
  89. -- LSP
  90. -- -----------------
  91. nmap("gd", function()
  92. snacks.picker.lsp_definitions()
  93. end, { desc = "Goto Definition" })
  94. nmap("gr", function()
  95. snacks.picker.lsp_references({ include_current = false })
  96. end, { desc = "Goto References" })
  97. nmap("gi", function()
  98. snacks.picker.lsp_implementations()
  99. end, { desc = "Goto Implementation" })
  100. nmap("<leader>D", function()
  101. snacks.picker.lsp_type_definitions()
  102. end, { desc = "Type Definition" })
  103. nmap("<leader>ca", function()
  104. vim.lsp.buf.code_action()
  105. end, { desc = "Code Action" })
  106. nmap("<leader>ds", function()
  107. snacks.picker.lsp_symbols()
  108. end, { desc = "Document Symbols" })
  109. nmap("<leader>ic", function()
  110. snacks.picker.lsp_incoming_calls()
  111. end, { desc = "Incoming Calls" })
  112. nmap("<leader>oc", function()
  113. snacks.picker.lsp_outgoing_calls()
  114. end, { desc = "Outgoing Calls" })
  115. -- -----------------
  116. -- Grep / Search
  117. -- -----------------
  118. nmap("<leader>gf", function()
  119. snacks.picker.grep()
  120. end, { desc = "Find Live Grep" })
  121. nmap("sb", function()
  122. snacks.picker.lines()
  123. end, { desc = "Search Current Buffer" })
  124. nmap("gw", function()
  125. snacks.picker.grep_word()
  126. end, { desc = "Search word under cursor" })
  127. nmap("gW", function()
  128. snacks.picker.grep_word({ word = vim.fn.expand("<cWORD>") })
  129. end, { desc = "Search WORD under cursor" })
  130. -- -----------------
  131. -- Files
  132. -- -----------------
  133. nmap("<leader>/", function()
  134. snacks.picker.files({
  135. hidden = true,
  136. ignored = true,
  137. exclude = {
  138. "node_modules",
  139. ".git",
  140. "dist",
  141. "build",
  142. "coverage",
  143. "public",
  144. },
  145. })
  146. end, { desc = "Find Files" })
  147. -- -----------------
  148. -- Buffers / Help / Keymaps
  149. -- -----------------
  150. nmap(";", function()
  151. snacks.picker.buffers()
  152. end, { desc = "Find Buffers" })
  153. nmap("sk", function()
  154. snacks.picker.keymaps()
  155. end, { desc = "Search Keymaps" })
  156. nmap("sh", function()
  157. snacks.picker.help()
  158. end, { desc = "Search Help" })
  159. end,
  160. }