init.lua 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. -- if not package.loaded['which-key'] then
  2. -- return
  3. -- end
  4. local status_ok, which_key = pcall(require, "which-key")
  5. if not status_ok then
  6. return
  7. end
  8. which_key.setup(O.plugin.which_key.setup)
  9. -- Set leader
  10. if O.leader_key == " " or O.leader_key == "space" then
  11. vim.api.nvim_set_keymap("n", "<Space>", "<NOP>", { noremap = true, silent = true })
  12. vim.g.mapleader = " "
  13. else
  14. vim.api.nvim_set_keymap("n", O.leader_key, "<NOP>", { noremap = true, silent = true })
  15. vim.g.mapleader = O.leader_key
  16. end
  17. local opts = O.plugin.which_key.opts
  18. local vopts = O.plugin.which_key.vopts
  19. local mappings = O.plugin.which_key.mappings
  20. local vmappings = O.plugin.which_key.vmappings;
  21. -- if O.plugin.ts_playground.active then
  22. -- vim.api.nvim_set_keymap("n", "<leader>Th", ":TSHighlightCapturesUnderCursor<CR>", { noremap = true, silent = true })
  23. -- mappings[""] = "Highlight Capture"
  24. -- end
  25. if O.plugin.zen.active then
  26. vim.api.nvim_set_keymap("n", "<leader>z", ":ZenMode<CR>", { noremap = true, silent = true })
  27. mappings["z"] = "Zen"
  28. end
  29. if O.plugin.telescope_project.active then
  30. -- open projects
  31. vim.api.nvim_set_keymap(
  32. "n",
  33. "<leader>P",
  34. ":lua require'telescope'.extensions.project.project{}<CR>",
  35. { noremap = true, silent = true }
  36. )
  37. mappings["P"] = "Projects"
  38. end
  39. if O.plugin.lush.active then
  40. mappings["L"] = {
  41. name = "+Lush",
  42. l = { ":Lushify<cr>", "Lushify" },
  43. x = { ":lua require('lush').export_to_buffer(require('lush_theme.cool_name'))", "Lush Export" },
  44. t = { ":LushRunTutorial<cr>", "Lush Tutorial" },
  45. q = { ":LushRunQuickstart<cr>", "Lush Quickstart" },
  46. }
  47. end
  48. for k, v in pairs(O.user_which_key) do
  49. mappings[k] = v
  50. end
  51. local wk = require "which-key"
  52. wk.register(mappings, opts)
  53. wk.register(vmappings, vopts)