From 409dfed3237f9f0a6e96879078d1daf3d9c02e03 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Wed, 7 Jul 2021 14:10:25 +0200 Subject: Updated config again after Chris's updates --- .config/nvim/lua/cfg/which-key/init.lua | 98 +++++++++------------------------ 1 file changed, 27 insertions(+), 71 deletions(-) (limited to '.config/nvim/lua/cfg/which-key') diff --git a/.config/nvim/lua/cfg/which-key/init.lua b/.config/nvim/lua/cfg/which-key/init.lua index 1558a50..ca87c6f 100644 --- a/.config/nvim/lua/cfg/which-key/init.lua +++ b/.config/nvim/lua/cfg/which-key/init.lua @@ -1,8 +1,12 @@ -- if not package.loaded['which-key'] then -- return -- end +local status_ok, which_key = pcall(require, "which-key") +if not status_ok then + return +end -require("which-key").setup { +which_key.setup { plugins = { marks = true, -- shows a list of your marks on ' and ` registers = true, -- shows your registers on " in NORMAL or in INSERT mode @@ -61,16 +65,12 @@ vim.api.nvim_set_keymap("n", "n", ':let @/=""', { noremap = true, si -- explorer --- TODO this introduces some bugs unfortunately vim.api.nvim_set_keymap( "n", "e", ":lua require'cfg.nvimtree'.toggle_tree()", { noremap = true, silent = true } ) --- vim.api.nvim_set_keymap('n', 'e', --- ":NvimTreeToggle", --- {noremap = true, silent = true}) vim.api.nvim_set_keymap("n", "f", ":Telescope find_files", { noremap = true, silent = true }) @@ -81,23 +81,31 @@ vim.api.nvim_set_keymap("n", ";", ":Dashboard", { noremap = true, si vim.api.nvim_set_keymap("n", "k", ":CommentToggle", { noremap = true, silent = true }) vim.api.nvim_set_keymap("v", "k", ":CommentToggle", { noremap = true, silent = true }) - -- split window vim.api.nvim_set_keymap("n", "v", ":vsplit", {noremap = true, silent = true}) vim.api.nvim_set_keymap("n", "h", ":split", {noremap = true, silent = true}) + -- close buffer vim.api.nvim_set_keymap("n", "c", ":BufferClose", { noremap = true, silent = true }) --- TODO create entire treesitter section +-- open config +vim.api.nvim_set_keymap( + "n", + ".", + ":e " .. CONFIG_PATH .. "/config.lua", + { noremap = true, silent = true } +) local mappings = { + ["."] = "LunarConfig", ["k"] = "Comment", ["c"] = "Close Buffer", ["e"] = "Explorer", ["f"] = "Find File", ["n"] = "No Highlight", + [";"] = "Dashboard", ["v"] = "Vertical Split", ["h"] = "Horizontal Split", b = { @@ -127,54 +135,10 @@ local mappings = { name = "Packer", c = { "PackerCompile", "Compile" }, i = { "PackerInstall", "Install" }, - r = { ":luafile %", "Reload" }, + r = { "lua require('cfg.utils').reload_config()", "Reload" }, s = { "PackerSync", "Sync" }, u = { "PackerUpdate", "Update" }, }, - -- diagnostics vanilla nvim - -- -- diagnostic - -- function lv_utils.get_all() - -- vim.lsp.diagnostic.get_all() - -- end - -- function lv_utils.get_next() - -- vim.lsp.diagnostic.get_next() - -- end - -- function lv_utils.get_prev() - -- vim.lsp.diagnostic.get_prev() - -- end - -- function lv_utils.goto_next() - -- vim.lsp.diagnostic.goto_next() - -- end - -- function lv_utils.goto_prev() - -- vim.lsp.diagnostic.goto_prev() - -- end - -- function lv_utils.show_line_diagnostics() - -- vim.lsp.diagnostic.show_line_diagnostics() - -- end - - -- " Available Debug Adapters: - -- " https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/ - -- " Adapter configuration and installation instructions: - -- " https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation - -- " Debug Adapter protocol: - -- " https://microsoft.github.io/debug-adapter-protocol/ - -- " Debugging - d = { - name = "Debug", - t = { "lua require'dap'.toggle_breakpoint()", "Toggle Breakpoint" }, - b = { "lua require'dap'.step_back()", "Step Back" }, - c = { "lua require'dap'.continue()", "Continue" }, - C = { "lua require'dap'.run_to_cursor()", "Run To Cursor" }, - d = { "lua require'dap'.disconnect()", "Disconnect" }, - g = { "lua require'dap'.session()", "Get Session" }, - i = { "lua require'dap'.step_into()", "Step Into" }, - o = { "lua require'dap'.step_over()", "Step Over" }, - u = { "lua require'dap'.step_out()", "Step Out" }, - p = { "lua require'dap'.pause.toggle()", "Pause" }, - r = { "lua require'dap'.repl.toggle()", "Toggle Repl" }, - s = { "lua require'dap'.continue()", "Start" }, - q = { "lua require'dap'.stop()", "Quit" }, - }, g = { name = "Git", j = { "lua require 'gitsigns'.next_hunk()", "Next Hunk" }, @@ -207,7 +171,7 @@ local mappings = { "Telescope lsp_workspace_diagnostics", "Workspace Diagnostics", }, - f = { "lua vim.lsp.buf.formatting()", "Format" }, + f = { "Neoformat", "Format" }, i = { "LspInfo", "Info" }, j = { "lua vim.lsp.diagnostic.goto_next({popup_opts = {border = O.lsp.popup_border}})", "Next Diagnostic" }, k = { "lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = O.lsp.popup_border}})", "Prev Diagnostic" }, @@ -244,18 +208,6 @@ local mappings = { }, } --- if O.plugin.trouble.active then --- mappings["d"] = { --- name = "Diagnostics", --- t = { "TroubleToggle", "trouble" }, --- w = { "TroubleToggle lsp_workspace_diagnostics", "workspace" }, --- d = { "TroubleToggle lsp_document_diagnostics", "document" }, --- q = { "TroubleToggle quickfix", "quickfix" }, --- l = { "TroubleToggle loclist", "loclist" }, --- r = { "TroubleToggle lsp_references", "references" }, --- } --- end - if O.plugin.symbol_outline.active then vim.api.nvim_set_keymap("n", "o", ":SymbolsOutline", { noremap = true, silent = true }) mappings["o"] = "Symbols outline" @@ -270,10 +222,7 @@ if O.plugin.zen.active then vim.api.nvim_set_keymap("n", "z", ":ZenMode", { noremap = true, silent = true }) mappings["z"] = "Zen" end -if O.plugin.lazygit.active then - vim.api.nvim_set_keymap("n", "gg", ":LazyGit", { noremap = true, silent = true }) - mappings["gg"] = "LazyGit" -end + if O.plugin.telescope_project.active then -- open projects vim.api.nvim_set_keymap( @@ -285,8 +234,6 @@ if O.plugin.telescope_project.active then mappings["P"] = "Projects" end --- [";"] = "Dashboard", - if O.lang.latex.active then mappings["L"] = { name = "+Latex", @@ -309,5 +256,14 @@ if O.lushmode then } end +-- for _, v in pairs(O.user_which_key) do +-- end +for k, v in pairs(O.user_which_key) do + mappings[k] = v + -- table.insert(mappings, O.user_which_key[1]) + -- print(k) + -- print(v) +end + local wk = require "which-key" wk.register(mappings, opts) -- cgit v1.2.3-70-g09d2