diff options
Diffstat (limited to '.config/nvim/lua/core/which-key.lua')
-rw-r--r-- | .config/nvim/lua/core/which-key.lua | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/.config/nvim/lua/core/which-key.lua b/.config/nvim/lua/core/which-key.lua index 775ea67..7ea86a8 100644 --- a/.config/nvim/lua/core/which-key.lua +++ b/.config/nvim/lua/core/which-key.lua @@ -1,8 +1,10 @@ local M = {} -local Log = require "core.log" + M.config = function() options.builtin.which_key = { - active = false, + ---@usage disable which-key completely [not recommeded] + active = true, + on_config_done = nil, setup = { plugins = { marks = true, -- shows a list of your marks on ' and ` @@ -66,9 +68,8 @@ M.config = function() ["q"] = { "<cmd>q!<CR>", "Quit" }, ["k"] = { "<cmd>CommentToggle<CR>", "Comment" }, ["c"] = { "<cmd>BufferClose!<CR>", "Close Buffer" }, - ["e"] = { "<cmd>lua require'core.nvimtree'.toggle_tree()<CR>", "Explorer" }, ["f"] = { "<cmd>Telescope find_files<CR>", "Find File" }, - ["n"] = { '<cmd>let @/=""<CR>', "No Highlight" }, + ["n"] = { "<cmd>nohlsearch<CR>", "No Highlight" }, b = { name = "Buffers", j = { "<cmd>BufferPick<cr>", "jump to buffer" }, @@ -156,14 +157,8 @@ M.config = function() p = { name = "Peek", d = { "<cmd>lua require('lsp.peek').Peek('definition')<cr>", "Definition" }, - t = { - "<cmd>lua require('lsp.peek').Peek('typeDefinition')<cr>", - "Type Definition", - }, - i = { - "<cmd>lua require('lsp.peek').Peek('implementation')<cr>", - "Implementation", - }, + t = { "<cmd>lua require('lsp.peek').Peek('typeDefinition')<cr>", "Type Definition" }, + i = { "<cmd>lua require('lsp.peek').Peek('implementation')<cr>", "Implementation" }, }, q = { "<cmd>lua vim.lsp.diagnostic.set_loclist()<cr>", "Quickfix" }, r = { "<cmd>lua vim.lsp.buf.rename()<cr>", "Rename" }, @@ -173,18 +168,31 @@ M.config = function() "Workspace Symbols", }, }, - I = { + i = { name = "+nvim", - k = { - "<cmd>lua require('keymappings').print()<cr>", - "View nvim's default keymappings", + c = { + "<cmd>edit ~/.config/nvim/config.lua<cr>", + "Edit config.lua", }, + k = { "<cmd>lua require('keymappings').print()<cr>", "View LunarVim's default keymappings" }, i = { "<cmd>lua require('core.info').toggle_popup(vim.bo.filetype)<cr>", "Toggle nvim Info", }, + l = { + name = "+logs", + D = { "<cmd>edit ~/.cache/nvim/lunarvim.log<cr>", "Open the default logfile" }, + n = { "<cmd>lua require('core.terminal').toggle_log_view('lsp')<cr>", "view lsp log" }, + N = { "<cmd>edit ~/.cache/nvim/log<cr>", "Open the Neovim logfile" }, + l = { "<cmd>lua require('core.terminal').toggle_log_view('nvim')<cr>", "view neovim log" }, + L = { "<cmd>edit ~/.cache/nvim/lsp.log<cr>", "Open the LSP logfile" }, + p = { + "<cmd>lua require('core.terminal').toggle_log_view('packer.nvim')<cr>", + "view packer log", + }, + P = { "<cmd>edit ~/.cache/nvim/packer.nvim.log<cr>", "Open the Packer logfile" }, + }, }, - s = { name = "Search", b = { "<cmd>Telescope git_branches<cr>", "Checkout branch" }, @@ -211,14 +219,7 @@ M.config = function() end M.setup = function() - -- if not package.loaded['which-key'] then - -- return - -- end - local status_ok, which_key = pcall(require, "which-key") - if not status_ok then - Log:get_default "Failed to load whichkey" - return - end + local which_key = require "which-key" which_key.setup(options.builtin.which_key.setup) @@ -228,10 +229,12 @@ M.setup = function() local mappings = options.builtin.which_key.mappings local vmappings = options.builtin.which_key.vmappings - local wk = require "which-key" + which_key.register(mappings, opts) + which_key.register(vmappings, vopts) - wk.register(mappings, opts) - wk.register(vmappings, vopts) + if options.builtin.which_key.on_config_done then + options.builtin.which_key.on_config_done(which_key) + end end return M |