From f93bad12f1b4feeeee007ceab4a350eb1aa26c1e Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Wed, 25 Aug 2021 23:27:45 +0200 Subject: Updates from lvim, remove legacy --- .config/nvim/lua/core/which-key.lua | 59 +++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 28 deletions(-) (limited to '.config/nvim/lua/core/which-key.lua') 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"] = { "q!", "Quit" }, ["k"] = { "CommentToggle", "Comment" }, ["c"] = { "BufferClose!", "Close Buffer" }, - ["e"] = { "lua require'core.nvimtree'.toggle_tree()", "Explorer" }, ["f"] = { "Telescope find_files", "Find File" }, - ["n"] = { 'let @/=""', "No Highlight" }, + ["n"] = { "nohlsearch", "No Highlight" }, b = { name = "Buffers", j = { "BufferPick", "jump to buffer" }, @@ -156,14 +157,8 @@ M.config = function() p = { name = "Peek", d = { "lua require('lsp.peek').Peek('definition')", "Definition" }, - t = { - "lua require('lsp.peek').Peek('typeDefinition')", - "Type Definition", - }, - i = { - "lua require('lsp.peek').Peek('implementation')", - "Implementation", - }, + t = { "lua require('lsp.peek').Peek('typeDefinition')", "Type Definition" }, + i = { "lua require('lsp.peek').Peek('implementation')", "Implementation" }, }, q = { "lua vim.lsp.diagnostic.set_loclist()", "Quickfix" }, r = { "lua vim.lsp.buf.rename()", "Rename" }, @@ -173,18 +168,31 @@ M.config = function() "Workspace Symbols", }, }, - I = { + i = { name = "+nvim", - k = { - "lua require('keymappings').print()", - "View nvim's default keymappings", + c = { + "edit ~/.config/nvim/config.lua", + "Edit config.lua", }, + k = { "lua require('keymappings').print()", "View LunarVim's default keymappings" }, i = { "lua require('core.info').toggle_popup(vim.bo.filetype)", "Toggle nvim Info", }, + l = { + name = "+logs", + D = { "edit ~/.cache/nvim/lunarvim.log", "Open the default logfile" }, + n = { "lua require('core.terminal').toggle_log_view('lsp')", "view lsp log" }, + N = { "edit ~/.cache/nvim/log", "Open the Neovim logfile" }, + l = { "lua require('core.terminal').toggle_log_view('nvim')", "view neovim log" }, + L = { "edit ~/.cache/nvim/lsp.log", "Open the LSP logfile" }, + p = { + "lua require('core.terminal').toggle_log_view('packer.nvim')", + "view packer log", + }, + P = { "edit ~/.cache/nvim/packer.nvim.log", "Open the Packer logfile" }, + }, }, - s = { name = "Search", b = { "Telescope git_branches", "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 -- cgit v1.2.3-70-g09d2