From 52b74557415eb757ad4b7481b0aec8a3f98dd58d Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sun, 10 Oct 2021 21:07:41 +0200 Subject: feat: add an independent lvim namespace (#1699) --- lua/lvim/core/which-key.lua | 270 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 270 insertions(+) create mode 100644 lua/lvim/core/which-key.lua (limited to 'lua/lvim/core/which-key.lua') diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua new file mode 100644 index 00000000..15f63273 --- /dev/null +++ b/lua/lvim/core/which-key.lua @@ -0,0 +1,270 @@ +local M = {} + +M.config = function() + lvim.builtin.which_key = { + ---@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 ` + registers = true, -- shows your registers on " in NORMAL or in INSERT mode + -- the presets plugin, adds help for a bunch of default keybindings in Neovim + -- No actual key bindings are created + presets = { + operators = false, -- adds help for operators like d, y, ... + motions = false, -- adds help for motions + text_objects = false, -- help for text objects triggered after entering an operator + windows = true, -- default bindings on + nav = true, -- misc bindings to work with windows + z = true, -- bindings for folds, spelling and others prefixed with z + g = true, -- bindings for prefixed with g + }, + spelling = { enabled = true, suggestions = 20 }, -- use which-key for spelling hints + }, + icons = { + breadcrumb = "»", -- symbol used in the command line area that shows your active key combo + separator = "➜", -- symbol used between a key and it's label + group = "+", -- symbol prepended to a group + }, + window = { + border = "single", -- none, single, double, shadow + position = "bottom", -- bottom, top + margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left] + padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left] + }, + layout = { + height = { min = 4, max = 25 }, -- min and max height of the columns + width = { min = 20, max = 50 }, -- min and max width of the columns + spacing = 3, -- spacing between columns + }, + hidden = { "", "", "", "", "call", "lua", "^:", "^ " }, -- hide mapping boilerplate + show_help = true, -- show help message on the command line when the popup is visible + }, + + opts = { + mode = "n", -- NORMAL mode + prefix = "", + buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings + silent = true, -- use `silent` when creating keymaps + noremap = true, -- use `noremap` when creating keymaps + nowait = true, -- use `nowait` when creating keymaps + }, + vopts = { + mode = "v", -- VISUAL mode + prefix = "", + buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings + silent = true, -- use `silent` when creating keymaps + noremap = true, -- use `noremap` when creating keymaps + nowait = true, -- use `nowait` when creating keymaps + }, + -- NOTE: Prefer using : over as the latter avoids going back in normal-mode. + -- see https://neovim.io/doc/user/map.html#:map-cmd + vmappings = { + ["/"] = { ":CommentToggle", "Comment" }, + }, + mappings = { + ["w"] = { "w!", "Save" }, + ["q"] = { "q!", "Quit" }, + ["/"] = { "CommentToggle", "Comment" }, + ["c"] = { "BufferClose!", "Close Buffer" }, + ["f"] = { "Telescope find_files", "Find File" }, + ["h"] = { "nohlsearch", "No Highlight" }, + b = { + name = "Buffers", + j = { "BufferPick", "Jump" }, + f = { "Telescope buffers", "Find" }, + b = { "b#", "Previous" }, + w = { "BufferWipeout", "Wipeout" }, + e = { + "BufferCloseAllButCurrent", + "Close all but current", + }, + h = { "BufferCloseBuffersLeft", "Close all to the left" }, + l = { + "BufferCloseBuffersRight", + "Close all to the right", + }, + D = { + "BufferOrderByDirectory", + "Sort by directory", + }, + L = { + "BufferOrderByLanguage", + "Sort by language", + }, + }, + p = { + name = "Packer", + c = { "PackerCompile", "Compile" }, + i = { "PackerInstall", "Install" }, + r = { "lua require('lvim.utils').reload_lv_config()", "Reload" }, + s = { "PackerSync", "Sync" }, + S = { "PackerStatus", "Status" }, + u = { "PackerUpdate", "Update" }, + }, + + -- " 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 + g = { + name = "Git", + j = { "lua require 'gitsigns'.next_hunk()", "Next Hunk" }, + k = { "lua require 'gitsigns'.prev_hunk()", "Prev Hunk" }, + l = { "lua require 'gitsigns'.blame_line()", "Blame" }, + p = { "lua require 'gitsigns'.preview_hunk()", "Preview Hunk" }, + r = { "lua require 'gitsigns'.reset_hunk()", "Reset Hunk" }, + R = { "lua require 'gitsigns'.reset_buffer()", "Reset Buffer" }, + s = { "lua require 'gitsigns'.stage_hunk()", "Stage Hunk" }, + u = { + "lua require 'gitsigns'.undo_stage_hunk()", + "Undo Stage Hunk", + }, + o = { "Telescope git_status", "Open changed file" }, + b = { "Telescope git_branches", "Checkout branch" }, + c = { "Telescope git_commits", "Checkout commit" }, + C = { + "Telescope git_bcommits", + "Checkout commit(for current file)", + }, + d = { + "Gitsigns diffthis HEAD", + "Git Diff", + }, + }, + + l = { + name = "LSP", + a = { "lua require('core.telescope').code_actions()", "Code Action" }, + d = { + "Telescope lsp_document_diagnostics", + "Document Diagnostics", + }, + w = { + "Telescope lsp_workspace_diagnostics", + "Workspace Diagnostics", + }, + f = { "lua vim.lsp.buf.formatting()", "Format" }, + i = { "LspInfo", "Info" }, + I = { "LspInstallInfo", "Installer Info" }, + j = { + "lua vim.lsp.diagnostic.goto_next({popup_opts = {border = lvim.lsp.popup_border}})", + "Next Diagnostic", + }, + k = { + "lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lvim.lsp.popup_border}})", + "Prev Diagnostic", + }, + l = { "lua vim.lsp.codelens.run()", "CodeLens Action" }, + p = { + name = "Peek", + d = { "lua require('lvim.lsp.peek').Peek('definition')", "Definition" }, + t = { "lua require('lvim.lsp.peek').Peek('typeDefinition')", "Type Definition" }, + i = { "lua require('lvim.lsp.peek').Peek('implementation')", "Implementation" }, + }, + q = { "lua vim.lsp.diagnostic.set_loclist()", "Quickfix" }, + r = { "lua vim.lsp.buf.rename()", "Rename" }, + s = { "Telescope lsp_document_symbols", "Document Symbols" }, + S = { + "Telescope lsp_dynamic_workspace_symbols", + "Workspace Symbols", + }, + }, + L = { + name = "+LunarVim", + c = { + "edit" .. get_config_dir() .. "/config.lua", + "Edit config.lua", + }, + f = { + "lua require('lvim.core.telescope').find_lunarvim_files()", + "Find LunarVim files", + }, + g = { + "lua require('lvim.core.telescope').grep_lunarvim_files()", + "Grep LunarVim files", + }, + k = { "lua require('lvim.keymappings').print()", "View LunarVim's default keymappings" }, + i = { + "lua require('lvim.core.info').toggle_popup(vim.bo.filetype)", + "Toggle LunarVim Info", + }, + I = { + "lua require('lvim.core.telescope').view_lunarvim_changelog()", + "View LunarVim's changelog", + }, + l = { + name = "+logs", + d = { + "lua require('lvim.core.terminal').toggle_log_view(require('lvim.core.log').get_path())", + "view default log", + }, + D = { + "lua vim.fn.execute('edit ' .. require('lvim.core.log').get_path())", + "Open the default logfile", + }, + l = { "lua require('lvim.core.terminal').toggle_log_view(vim.lsp.get_log_path())", "view lsp log" }, + L = { "lua vim.fn.execute('edit ' .. vim.lsp.get_log_path())", "Open the LSP logfile" }, + n = { + "lua require('lvim.core.terminal').toggle_log_view(os.getenv('NVIM_LOG_FILE'))", + "view neovim log", + }, + N = { "edit $NVIM_LOG_FILE", "Open the Neovim logfile" }, + p = { + "lua require('lvim.core.terminal').toggle_log_view('packer.nvim')", + "view packer log", + }, + P = { "exe 'edit '.stdpath('cache').'/packer.nvim.log'", "Open the Packer logfile" }, + }, + r = { "lua require('lvim.utils').reload_lv_config()", "Reload configurations" }, + u = { "LvimUpdate", "Update LunarVim" }, + }, + s = { + name = "Search", + b = { "Telescope git_branches", "Checkout branch" }, + c = { "Telescope colorscheme", "Colorscheme" }, + f = { "Telescope find_files", "Find File" }, + h = { "Telescope help_tags", "Find Help" }, + M = { "Telescope man_pages", "Man Pages" }, + r = { "Telescope oldfiles", "Open Recent File" }, + R = { "Telescope registers", "Registers" }, + t = { "Telescope live_grep", "Text" }, + k = { "Telescope keymaps", "Keymaps" }, + C = { "Telescope commands", "Commands" }, + p = { + "lua require('telescope.builtin.internal').colorscheme({enable_preview = true})", + "Colorscheme with Preview", + }, + }, + T = { + name = "Treesitter", + i = { ":TSConfigInfo", "Info" }, + }, + }, + } +end + +M.setup = function() + local which_key = require "which-key" + + which_key.setup(lvim.builtin.which_key.setup) + + local opts = lvim.builtin.which_key.opts + local vopts = lvim.builtin.which_key.vopts + + local mappings = lvim.builtin.which_key.mappings + local vmappings = lvim.builtin.which_key.vmappings + + which_key.register(mappings, opts) + which_key.register(vmappings, vopts) + + if lvim.builtin.which_key.on_config_done then + lvim.builtin.which_key.on_config_done(which_key) + end +end + +return M -- cgit v1.2.3 From fdec599954dcc093e56522c4f9dcb126ad869979 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Mon, 11 Oct 2021 11:53:30 +0330 Subject: fix: core.telescope has migrated to lvim.core.telescope Fixes #1739 --- lua/lvim/core/which-key.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua/lvim/core/which-key.lua') diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua index 15f63273..eebdc27b 100644 --- a/lua/lvim/core/which-key.lua +++ b/lua/lvim/core/which-key.lua @@ -139,7 +139,7 @@ M.config = function() l = { name = "LSP", - a = { "lua require('core.telescope').code_actions()", "Code Action" }, + a = { "lua require('lvim.core.telescope').code_actions()", "Code Action" }, d = { "Telescope lsp_document_diagnostics", "Document Diagnostics", -- cgit v1.2.3 From 3dc24cd0c32801afd44c0451932f8245cdf10a49 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Mon, 11 Oct 2021 20:10:59 +0330 Subject: [Feature] use `Comment.nvim` instead of `nvim-comment` (#1736) --- lua/lvim/core/which-key.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lua/lvim/core/which-key.lua') diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua index eebdc27b..528c7600 100644 --- a/lua/lvim/core/which-key.lua +++ b/lua/lvim/core/which-key.lua @@ -61,12 +61,12 @@ M.config = function() -- NOTE: Prefer using : over as the latter avoids going back in normal-mode. -- see https://neovim.io/doc/user/map.html#:map-cmd vmappings = { - ["/"] = { ":CommentToggle", "Comment" }, + ["/"] = { "lua ___comment_gc(vim.fn.visualmode())", "Comment" }, }, mappings = { ["w"] = { "w!", "Save" }, ["q"] = { "q!", "Quit" }, - ["/"] = { "CommentToggle", "Comment" }, + ["/"] = { "lua require('Comment').toggle()", "Comment" }, ["c"] = { "BufferClose!", "Close Buffer" }, ["f"] = { "Telescope find_files", "Find File" }, ["h"] = { "nohlsearch", "No Highlight" }, -- cgit v1.2.3 From ef41a3d24e753b7e82fe31ebe9e74048881c13e8 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Fri, 15 Oct 2021 16:33:34 +0200 Subject: feat: better telescope integration (#1702) --- lua/lvim/core/which-key.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lua/lvim/core/which-key.lua') diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua index 528c7600..fcaeacf5 100644 --- a/lua/lvim/core/which-key.lua +++ b/lua/lvim/core/which-key.lua @@ -181,11 +181,11 @@ M.config = function() "Edit config.lua", }, f = { - "lua require('lvim.core.telescope').find_lunarvim_files()", + "lua require('lvim.core.telescope.custom-finders').find_lunarvim_files()", "Find LunarVim files", }, g = { - "lua require('lvim.core.telescope').grep_lunarvim_files()", + "lua require('lvim.core.telescope.custom-finders').grep_lunarvim_files()", "Grep LunarVim files", }, k = { "lua require('lvim.keymappings').print()", "View LunarVim's default keymappings" }, @@ -194,7 +194,7 @@ M.config = function() "Toggle LunarVim Info", }, I = { - "lua require('lvim.core.telescope').view_lunarvim_changelog()", + "lua require('lvim.core.telescope.custom-finders').view_lunarvim_changelog()", "View LunarVim's changelog", }, l = { -- cgit v1.2.3