init.lua 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. require("which-key").setup {
  2. plugins = {
  3. marks = true, -- shows a list of your marks on ' and `
  4. registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
  5. -- the presets plugin, adds help for a bunch of default keybindings in Neovim
  6. -- No actual key bindings are created
  7. presets = {
  8. operators = true, -- adds help for operators like d, y, ...
  9. motions = true, -- adds help for motions
  10. text_objects = true, -- help for text objects triggered after entering an operator
  11. windows = true, -- default bindings on <c-w>
  12. nav = true, -- misc bindings to work with windows
  13. z = true, -- bindings for folds, spelling and others prefixed with z
  14. g = true -- bindings for prefixed with g
  15. }
  16. },
  17. icons = {
  18. breadcrumb = "»", -- symbol used in the command line area that shows your active key combo
  19. separator = "➜", -- symbol used between a key and it's label
  20. group = "+" -- symbol prepended to a group
  21. },
  22. window = {
  23. border = "single", -- none, single, double, shadow
  24. position = "bottom", -- bottom, top
  25. margin = {1, 0, 1, 0}, -- extra window margin [top, right, bottom, left]
  26. padding = {2, 2, 2, 2} -- extra window padding [top, right, bottom, left]
  27. },
  28. layout = {
  29. height = {min = 4, max = 25}, -- min and max height of the columns
  30. width = {min = 20, max = 50}, -- min and max width of the columns
  31. spacing = 3 -- spacing between columns
  32. },
  33. hidden = {"<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ "}, -- hide mapping boilerplate
  34. show_help = true -- show help message on the command line when the popup is visible
  35. }
  36. local opts = {
  37. mode = "n", -- NORMAL mode
  38. prefix = "<leader>",
  39. buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings
  40. silent = true, -- use `silent` when creating keymaps
  41. noremap = true, -- use `noremap` when creating keymaps
  42. nowait = false -- use `nowait` when creating keymaps
  43. }
  44. -- Set leader
  45. vim.api.nvim_set_keymap('n', '<Space>', '<NOP>', {noremap = true, silent = true})
  46. vim.g.mapleader = ' '
  47. -- no hl
  48. vim.api.nvim_set_keymap('n', '<Leader>h', ':set hlsearch!<CR>', {noremap = true, silent = true})
  49. -- explorer
  50. vim.api.nvim_set_keymap('n', '<Leader>e', ':NvimTreeToggle<CR>', {noremap = true, silent = true})
  51. -- telescope
  52. vim.api.nvim_set_keymap('n', '<Leader>f', ':Telescope find_files<CR>', {noremap = true, silent = true})
  53. -- dashboard
  54. vim.api.nvim_set_keymap('n', '<Leader>;', ':Dashboard<CR>', {noremap = true, silent = true})
  55. -- Comments
  56. vim.api.nvim_set_keymap("n", "<leader>/", ":CommentToggle<CR>", {noremap = true, silent = true})
  57. vim.api.nvim_set_keymap("v", "<leader>/", ":CommentToggle<CR>", {noremap = true, silent = true})
  58. -- close buffer
  59. vim.api.nvim_set_keymap("n", "<leader>c", ":BufferClose<CR>", {noremap = true, silent = true})
  60. -- TODO create entire treesitter section
  61. local mappings = {
  62. ["/"] = "Comment",
  63. ["c"] = "Close Buffer",
  64. ["e"] = "Explorer",
  65. ["f"] = "Find File",
  66. ["h"] = "No Highlight",
  67. d = {
  68. name = "+Debug",
  69. b = {"<cmd>DebugToggleBreakpoint<cr>", "Toggle Breakpoint"},
  70. c = {"<cmd>DebugContinue<cr>", "Continue"},
  71. i = {"<cmd>DebugStepInto<cr>", "Step Into"},
  72. o = {"<cmd>DebugStepOver<cr>", "Step Over"},
  73. r = {"<cmd>DebugToggleRepl<cr>", "Toggle Repl"},
  74. s = {"<cmd>DebugStart<cr>", "Start"}
  75. },
  76. g = {
  77. name = "+Git",
  78. j = {"<cmd>NextHunk<cr>", "Next Hunk"},
  79. k = {"<cmd>PrevHunk<cr>", "Prev Hunk"},
  80. p = {"<cmd>PreviewHunk<cr>", "Preview Hunk"},
  81. r = {"<cmd>ResetHunk<cr>", "Reset Hunk"},
  82. R = {"<cmd>ResetBuffer<cr>", "Reset Buffer"},
  83. s = {"<cmd>StageHunk<cr>", "Stage Hunk"},
  84. u = {"<cmd>UndoStageHunk<cr>", "Undo Stage Hunk"}
  85. },
  86. l = {
  87. name = "+LSP",
  88. a = {"<cmd>Lspsaga code_action<cr>", "Code Action"},
  89. A = {"<cmd>Lspsaga range_code_action<cr>", "Selected Action"},
  90. d = {"<cmd>Telescope lsp_document_diagnostics<cr>", "Document Diagnostics"},
  91. D = {"<cmd>Telescope lsp_workspace_diagnostics<cr>", "Workspace Diagnostics"},
  92. f = {"<cmd>LspFormatting<cr>", "Format"},
  93. i = {"<cmd>LspInfo<cr>", "Info"},
  94. l = {"<cmd>Lspsaga lsp_finder<cr>", "LSP Finder"},
  95. L = {"<cmd>Lspsaga show_line_diagnostics<cr>", "Line Diagnostics"},
  96. p = {"<cmd>Lspsaga preview_definition<cr>", "Preview Definition"},
  97. q = {"<cmd>Telescope quickfix<cr>", "Quickfix"},
  98. r = {"<cmd>Lspsaga rename<cr>", "Rename"},
  99. t = {"<cmd>LspTypeDefinition<cr>", "Type Definition"},
  100. x = {"<cmd>cclose<cr>", "Close Quickfix"},
  101. s = {"<cmd>Telescope lsp_document_symbols<cr>", "Document Symbols"},
  102. S = {"<cmd>Telescope lsp_workspace_symbols<cr>", "Workspace Symbols"}
  103. },
  104. s = {
  105. name = "+Search",
  106. b = {"<cmd>Telescope git_branches<cr>", "File"},
  107. c = {"<cmd>Telescope colorscheme<cr>", "Colorscheme"},
  108. d = {"<cmd>Telescope lsp_document_diagnostics<cr>", "Document Diagnostics"},
  109. D = {"<cmd>Telescope lsp_workspace_diagnostics<cr>", "Workspace Diagnostics"},
  110. f = {"<cmd>Telescope find_files<cr>", "Find File"},
  111. m = {"<cmd>Telescope marks<cr>", "Marks"},
  112. M = {"<cmd>Telescope man_pages<cr>", "Man Pages"},
  113. r = {"<cmd>Telescope oldfiles<cr>", "Open Recent File"},
  114. R = {"<cmd>Telescope registers<cr>", "Registers"},
  115. t = {"<cmd>Telescope live_grep<cr>", "Text"}
  116. },
  117. S = {name = "+Session", s = {"<cmd>SessionSave<cr>", "Save Session"}, l = {"<cmd>SessionLoad<cr>", "Load Session"}}
  118. }
  119. local wk = require("which-key")
  120. wk.register(mappings, opts)