command-palette.lua 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. return {
  2. {
  3. dir = vim.fn.stdpath("config") .. "/custom/command-palette",
  4. name = "command-palette",
  5. dependencies = { "nvim-telescope/telescope.nvim" },
  6. enabled = true,
  7. config = function(_, _)
  8. local palette = require("command-palette")
  9. palette.add({
  10. {
  11. "Manage project", "", {
  12. {
  13. "Close project",
  14. "Safely close the project and then close the associated tmux pane",
  15. function()
  16. vim.api.nvim_create_autocmd({ "VimLeave" }, {
  17. pattern = { "*" },
  18. group = vim.api.nvim_create_augroup(
  19. "tmux_close_group", { clear = true }),
  20. callback = function()
  21. vim.api.nvim_exec("!tmux kill-pane",
  22. false)
  23. end
  24. })
  25. vim.api.nvim_exec("qa", true)
  26. end
  27. }
  28. }
  29. }
  30. })
  31. vim.keymap.set("n", "sP", palette.open)
  32. vim.keymap.set("n", "sp", palette.open_full)
  33. vim.keymap.set("n", "sL", function()
  34. palette.open({}, "LSP Finders", {
  35. { "Treesitter", "", ":Telescope treesitter" },
  36. { "LSP References", "", ":Telescope lsp_references" },
  37. { "LSP Incoming Calls", "", ":Telescope lsp_incoming_calls" },
  38. { "LSP Outgoing Calls", "", ":Telescope lsp_outgoing_calls" },
  39. {
  40. "LSP Document Symbols", "",
  41. ":Telescope lsp_document_symbols"
  42. },
  43. {
  44. "LSP Workspace Symbols", "",
  45. ":Telescope lsp_workspace_symbols"
  46. }, {
  47. "LSP Dynamic Workspace Symbols", "",
  48. ":Telescope lsp_workspace_symbols"
  49. }, { "Diagnostics", "", ":Telescope diagnostics" },
  50. {
  51. "LSP Implementations", "",
  52. ":Telescope lsp_implementations"
  53. }, { "LSP Definitions", "", ":Telescope lsp_definitions" },
  54. {
  55. "LSP Type Definitions", "",
  56. ":Telescope lsp_type_definitions"
  57. }
  58. })
  59. end)
  60. end
  61. }, {
  62. dir = vim.fn.stdpath("config") .. "/custom/bit-browser/",
  63. name = "bit-browser",
  64. enabled = true,
  65. dependencies = { "command-palette" },
  66. config = function(_, _)
  67. local bitbrowser = require("bit-browser")
  68. vim.keymap.set("n", "n", bitbrowser.next)
  69. vim.keymap.set("n", "N", bitbrowser.prev)
  70. for i, v in pairs({ 'e', 'w', 'i', 'd', 's', 'g' }) do
  71. vim.keymap.set("n", "sn" .. v, function()
  72. bitbrowser.set_target(i);
  73. bitbrowser.next()
  74. end)
  75. vim.keymap.set("n", "sN" .. v, function()
  76. bitbrowser.set_target(i);
  77. bitbrowser.prev()
  78. end)
  79. end
  80. end
  81. }, {
  82. dir = vim.fn.stdpath("config") .. "/custom/save-formatter",
  83. name = "save-formatter",
  84. dependencies = { "nvim-telescope/telescope.nvim", "command-palette" },
  85. enabled = true,
  86. config = function(_, _)
  87. local formatter = require("save-formatter")
  88. formatter.setup()
  89. vim.keymap.set("n", "Sw",
  90. function() vim.api.nvim_exec2("write", {}) end)
  91. require("command-palette").add({ {
  92. "Save Formatter", "Configure automatic formatters", formatter.picker }
  93. })
  94. end
  95. }
  96. }