diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-07-07 14:10:25 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-07-07 14:10:25 +0200 |
commit | 409dfed3237f9f0a6e96879078d1daf3d9c02e03 (patch) | |
tree | fd340e6803212b5ae401e2d6a1b524c412498663 /.config/nvim/lua/cfg/which-key | |
parent | 4918f8747e2d3e4d3342bb1f5ee05db6198819d1 (diff) |
Updated config again after Chris's updates
Diffstat (limited to '.config/nvim/lua/cfg/which-key')
-rw-r--r-- | .config/nvim/lua/cfg/which-key/init.lua | 98 |
1 files changed, 27 insertions, 71 deletions
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 <C-r> in INSERT mode @@ -61,16 +65,12 @@ vim.api.nvim_set_keymap("n", "<Leader>n", ':let @/=""<CR>', { noremap = true, si -- explorer --- TODO this introduces some bugs unfortunately vim.api.nvim_set_keymap( "n", "<Leader>e", ":lua require'cfg.nvimtree'.toggle_tree()<CR>", { noremap = true, silent = true } ) --- vim.api.nvim_set_keymap('n', '<Leader>e', --- ":NvimTreeToggle<CR>", --- {noremap = true, silent = true}) vim.api.nvim_set_keymap("n", "<Leader>f", ":Telescope find_files<CR>", { noremap = true, silent = true }) @@ -81,23 +81,31 @@ vim.api.nvim_set_keymap("n", "<Leader>;", ":Dashboard<CR>", { noremap = true, si vim.api.nvim_set_keymap("n", "<leader>k", ":CommentToggle<CR>", { noremap = true, silent = true }) vim.api.nvim_set_keymap("v", "<leader>k", ":CommentToggle<CR>", { noremap = true, silent = true }) - -- split window vim.api.nvim_set_keymap("n", "<leader>v", ":vsplit<CR>", {noremap = true, silent = true}) vim.api.nvim_set_keymap("n", "<leader>h", ":split<CR>", {noremap = true, silent = true}) + -- close buffer vim.api.nvim_set_keymap("n", "<leader>c", ":BufferClose<CR>", { noremap = true, silent = true }) --- TODO create entire treesitter section +-- open config +vim.api.nvim_set_keymap( + "n", + "<leader>.", + ":e " .. CONFIG_PATH .. "/config.lua<CR>", + { 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 = { "<cmd>PackerCompile<cr>", "Compile" }, i = { "<cmd>PackerInstall<cr>", "Install" }, - r = { ":luafile %<cr>", "Reload" }, + r = { "<cmd>lua require('cfg.utils').reload_config()<cr>", "Reload" }, s = { "<cmd>PackerSync<cr>", "Sync" }, u = { "<cmd>PackerUpdate<cr>", "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 = { "<cmd>lua require'dap'.toggle_breakpoint()<cr>", "Toggle Breakpoint" }, - b = { "<cmd>lua require'dap'.step_back()<cr>", "Step Back" }, - c = { "<cmd>lua require'dap'.continue()<cr>", "Continue" }, - C = { "<cmd>lua require'dap'.run_to_cursor()<cr>", "Run To Cursor" }, - d = { "<cmd>lua require'dap'.disconnect()<cr>", "Disconnect" }, - g = { "<cmd>lua require'dap'.session()<cr>", "Get Session" }, - i = { "<cmd>lua require'dap'.step_into()<cr>", "Step Into" }, - o = { "<cmd>lua require'dap'.step_over()<cr>", "Step Over" }, - u = { "<cmd>lua require'dap'.step_out()<cr>", "Step Out" }, - p = { "<cmd>lua require'dap'.pause.toggle()<cr>", "Pause" }, - r = { "<cmd>lua require'dap'.repl.toggle()<cr>", "Toggle Repl" }, - s = { "<cmd>lua require'dap'.continue()<cr>", "Start" }, - q = { "<cmd>lua require'dap'.stop()<cr>", "Quit" }, - }, g = { name = "Git", j = { "<cmd>lua require 'gitsigns'.next_hunk()<cr>", "Next Hunk" }, @@ -207,7 +171,7 @@ local mappings = { "<cmd>Telescope lsp_workspace_diagnostics<cr>", "Workspace Diagnostics", }, - f = { "<cmd>lua vim.lsp.buf.formatting()<cr>", "Format" }, + f = { "<cmd>Neoformat<cr>", "Format" }, i = { "<cmd>LspInfo<cr>", "Info" }, j = { "<cmd>lua vim.lsp.diagnostic.goto_next({popup_opts = {border = O.lsp.popup_border}})<cr>", "Next Diagnostic" }, k = { "<cmd>lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = O.lsp.popup_border}})<cr>", "Prev Diagnostic" }, @@ -244,18 +208,6 @@ local mappings = { }, } --- if O.plugin.trouble.active then --- mappings["d"] = { --- name = "Diagnostics", --- t = { "<cmd>TroubleToggle<cr>", "trouble" }, --- w = { "<cmd>TroubleToggle lsp_workspace_diagnostics<cr>", "workspace" }, --- d = { "<cmd>TroubleToggle lsp_document_diagnostics<cr>", "document" }, --- q = { "<cmd>TroubleToggle quickfix<cr>", "quickfix" }, --- l = { "<cmd>TroubleToggle loclist<cr>", "loclist" }, --- r = { "<cmd>TroubleToggle lsp_references<cr>", "references" }, --- } --- end - if O.plugin.symbol_outline.active then vim.api.nvim_set_keymap("n", "<leader>o", ":SymbolsOutline<CR>", { noremap = true, silent = true }) mappings["o"] = "Symbols outline" @@ -270,10 +222,7 @@ if O.plugin.zen.active then vim.api.nvim_set_keymap("n", "<leader>z", ":ZenMode<CR>", { noremap = true, silent = true }) mappings["z"] = "Zen" end -if O.plugin.lazygit.active then - vim.api.nvim_set_keymap("n", "<leader>gg", ":LazyGit<CR>", { 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) |