-- Mapping data with "desc" stored directly by vim.keymap.set(). -- -- Please use this mappings table to set keyboard mapping since this is the -- lower level configuration and more robust one. (which-key will -- automatically pick-up stored data by this setting.) local utils = require "astronvim.utils" require("telescope").load_extension("refactoring") require("telescope").load_extension("yank_history") require("telescope").load_extension("undo") return { -- normal mode n = { -- second key is the lefthand side of the map -- mappings seen under group name "Buffer" ["bn"] = { "tabnew", desc = "New tab" }, -- quick save [""] = { ":w!", desc = "Save File" }, -- change description but the same command -- Terminal -- NOTE: https://neovim.io/doc/user/builtin.html#jobstart() -- 1. If {cmd} is a List it runs directly (no 'shell') -- 2. If {cmd} is a String it runs in the 'shell' -- search and replace globally ['ss'] = {'lua require("spectre").toggle()', desc = "Toggle Spectre" }, ['sw'] = {'lua require("spectre").open_visual({select_word=true})', desc = "Search current word" }, ['sp'] ={'lua require("spectre").open_file_search({select_word=true})', desc = "Search on current file" }, -- refactoring ["ri"] = { function() require('refactoring').refactor('Inline Variable') end, desc = "Inverse of extract variable" }, ["rb"] = { function() require('refactoring').refactor('Extract Block') end, desc = "Extract Block" }, ["rbf"] = { function() require('refactoring').refactor('Extract Block To File') end, desc = "Extract Block To File" }, ["rr"] = { function() require('telescope').extensions.refactoring.refactors() end, desc = "Prompt for a refactor to apply" }, ["rp"] = { function() require('refactoring').debug.printf({below = false}) end, desc = "Insert print statement to mark the calling of a function" }, ["rv"] = { function() require('refactoring').debug.print_var() end, desc = "Insert print statement to print a variable" }, ["rc"] = { function() require('refactoring').debug.cleanup({}) end, desc = "Cleanup of all generated print statements" }, -- yank_history ["yh"] = { function() require("telescope").extensions.yank_history.yank_history() end, desc = "Preview Yank History" }, -- undo history ["uh"] = {"Telescope undo", desc="Telescope undo" }, -- implementation/definition preview ["gpd"] = { "lua require('goto-preview').goto_preview_definition()", desc="goto_preview_definition" }, ["gpt"] = { "lua require('goto-preview').goto_preview_type_definition()", desc="goto_preview_type_definition" }, ["gpi"] = { "lua require('goto-preview').goto_preview_implementation()", desc="goto_preview_implementation" }, ["gP" ] = { "lua require('goto-preview').close_all_win()", desc="close_all_win" }, ["gpr"] = { "lua require('goto-preview').goto_preview_references()", desc="goto_preview_references" }, }, -- Visual mode v = { -- search and replace globally ['sw'] = {'lua require("spectre").open_visual()', desc = "Search current word" }, }, -- visual mode(what's the difference between v and x???) x = { -- refactoring ["ri"] = { function() require('refactoring').refactor('Inline Variable') end, desc = "Inverse of extract variable" }, ["re"] = { function() require('refactoring').refactor('Extract Function') end, desc = "Extracts the selected code to a separate function" }, ["rf"] = { function() require('refactoring').refactor('Extract Function To File') end, desc = "Extract Function To File" }, ["rv"] = { function() require('refactoring').refactor('Extract Variable') end, desc = "Extracts occurrences of a selected expression to its own variable" }, ["rr"] = { function() require('telescope').extensions.refactoring.refactors() end, desc = "Prompt for a refactor to apply" }, }, }