From 08d5556ab2f104cc2daff59c078c12816b8c9acc Mon Sep 17 00:00:00 2001 From: Ariel D'Alessandro Date: Mon, 10 Apr 2023 10:18:01 +0200 Subject: feat(general): update keymaps --- init.lua | 6 ++++ lazy-lock.json | 30 ++++++++++---------- lua/alpha/lsp/attach.lua | 20 +++++++------- lua/alpha/lsp/null-ls.lua | 6 ++-- lua/alpha/php/gateway.lua | 4 +-- lua/alpha/snips/ft/go.lua | 7 +---- lua/alpha/telescope/actions.lua | 13 +++++---- lua/alpha/telescope/init.lua | 6 ++-- lua/alpha/telescope/mappings.lua | 60 ++++++++++++++++++++++------------------ lua/alpha/utils.lua | 24 ++++++++-------- lua/config/keymaps.lua | 44 +++++++++++++++-------------- lua/plugins/color-picker.lua | 2 +- lua/plugins/comment.lua | 2 +- lua/plugins/dap.lua | 2 +- lua/plugins/database.lua | 2 +- lua/plugins/easy-align.lua | 2 +- lua/plugins/fugitive.lua | 8 +++--- lua/plugins/harpoon.lua | 13 ++++++--- lua/plugins/icon-picker.lua | 6 ++-- lua/plugins/laravel.lua | 4 +-- lua/plugins/neogen.lua | 2 +- lua/plugins/overseer.lua | 2 +- lua/plugins/refactoring.lua | 1 + lua/plugins/rest.lua | 18 +++++++++--- lua/plugins/smart-splits.lua | 4 +++ lua/plugins/smooth-cursor.lua | 2 +- lua/plugins/snippets.lua | 2 +- lua/plugins/spectre.lua | 2 +- lua/plugins/test.lua | 2 +- lua/plugins/todo-comments.lua | 2 ++ lua/plugins/trouble.lua | 2 +- lua/plugins/worktree.lua | 2 ++ 32 files changed, 168 insertions(+), 134 deletions(-) diff --git a/init.lua b/init.lua index 7255d55..f7baee1 100644 --- a/init.lua +++ b/init.lua @@ -1,2 +1,8 @@ +-- TODO: remove once 0.9 is more widly available +if vim.fn.has "nvim-0.9.0" ~= 1 then + vim.treesitter.query.get = vim.treesitter.get_query + vim.treesitter.query.set = vim.treesitter.set_query +end + require "config" require "alpha.globals" diff --git a/lazy-lock.json b/lazy-lock.json index 148f851..4eb14d4 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,7 +1,7 @@ { "Comment.nvim": { "branch": "master", "commit": "8d3aa5c22c2d45e788c7a5fe13ad77368b783c20" }, "LuaSnip": { "branch": "master", "commit": "500981ff6cefc7343e3959ef0f939bd0bfd49ba9" }, - "NeoColumn.nvim": { "branch": "main", "commit": "9cdfa8213a9d89aa0ab64a855d1136fccf369e28" }, + "NeoColumn.nvim": { "branch": "main", "commit": "566afd9caf0045e379f62782e9d375353118429b" }, "SmoothCursor.nvim": { "branch": "main", "commit": "b61173fb107455f18099715b88d86002579f2736" }, "catppuccin": { "branch": "main", "commit": "73587f9c454da81679202f1668c30fea6cdafd5e" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, @@ -14,7 +14,7 @@ "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, "color-picker.nvim": { "branch": "master", "commit": "e23de39cff3babdc97c39ae79bb68fedf1a1fe00" }, - "dressing.nvim": { "branch": "master", "commit": "c705b3890779ea05bd910e9d06af8a209bfb6ad8" }, + "dressing.nvim": { "branch": "master", "commit": "91b9ba8a9474d2c4156dc2f3e858e07ae8faecf0" }, "fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" }, "fzf.vim": { "branch": "master", "commit": "dc71692255b62d1f67dc55c8e51ab1aa467b1d46" }, "git-worktree.nvim": { "branch": "master", "commit": "d7f4e2584e81670154f07ca9fa5dd791d9c1b458" }, @@ -26,44 +26,44 @@ "lazy.nvim": { "branch": "main", "commit": "57cce98dfdb2f2dd05a0567d89811e6d0505e13b" }, "lsp-inlayhints.nvim": { "branch": "main", "commit": "84ca3abe8aaecbb5b30ad89e4701d4a9c821b72c" }, "lspkind-nvim": { "branch": "master", "commit": "c68b3a003483cf382428a43035079f78474cd11e" }, - "lualine.nvim": { "branch": "master", "commit": "c28a7427c3fb29322db136f0564ec58807b26747" }, + "lualine.nvim": { "branch": "master", "commit": "84ffb80e452d95e2c46fa29a98ea11a240f7843e" }, "markdown-preview.nvim": { "branch": "main", "commit": "cc05a30393e2bf9f12e2d59fc35a1aa928ed1727" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "b64fdede85fd5e0b720ce722919e0a9b95ed6547" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "a8d5db8f227b9b236d1c54a9c6234bc033825ce7" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "a6c4d7df448a78b0a05fd2065bef11ed52bee51c" }, - "mason.nvim": { "branch": "main", "commit": "e57d9bd671adce24970480a194690d207e2a141d" }, + "mason.nvim": { "branch": "main", "commit": "2311d9d883eb709ad9979a726a38c5ce1343b63c" }, "neogen": { "branch": "main", "commit": "9c17225aac94bdbf93baf16e1b2d2c6dcffb0901" }, "null-ls.nvim": { "branch": "main", "commit": "5855128178fa78293acdfb5b4e41ef046779240b" }, - "nvim-autopairs": { "branch": "master", "commit": "0fd6519d44eac3a6736aafdb3fe9da916c3701d4" }, + "nvim-autopairs": { "branch": "master", "commit": "7470af886ffb3df32800e5ef9c072a6cd825770d" }, "nvim-cmp": { "branch": "main", "commit": "777450fd0ae289463a14481673e26246b5e38bf2" }, "nvim-colorizer.lua": { "branch": "master", "commit": "36c610a9717cc9ec426a07c8e6bf3b3abcb139d6" }, - "nvim-dap": { "branch": "master", "commit": "1dd02e82c77d558e30ba831db4c2e7ed534e874f" }, + "nvim-dap": { "branch": "master", "commit": "debd7c2f80eaf20c5f5df25db8d8c1b9b18f4421" }, "nvim-dap-go": { "branch": "main", "commit": "b4ded7de579b4e2a85c203388233b54bf1028816" }, - "nvim-dap-ui": { "branch": "master", "commit": "56a2df0e96bfa64ebd6967e7cad877a1530633d5" }, + "nvim-dap-ui": { "branch": "master", "commit": "286f682f366fbc652b38dff893569374e9433dd3" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "9dc45a6eb33871f4c5cb2ba08fa307467657471e" }, "nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" }, - "nvim-lspconfig": { "branch": "master", "commit": "7179a46c2345050783d14397e672e7b152a7af4f" }, + "nvim-lspconfig": { "branch": "master", "commit": "27e9e1d2638ffd133b06f314a49ac55825cb1017" }, "nvim-notify": { "branch": "master", "commit": "50d037041ada0895aeba4c0215cde6d11b7729c4" }, "nvim-projectconfig": { "branch": "master", "commit": "05fd34831e170db269d1b84597615bcdcdde930e" }, "nvim-spectre": { "branch": "master", "commit": "6e5ce371f93625c7dc43f5e2647d3647f2ea15e2" }, "nvim-transparent": { "branch": "main", "commit": "2d8d650fc8a3b8da6a01031295547295eb473b7d" }, - "nvim-treesitter": { "branch": "master", "commit": "411e771d511442ab81670701f5c830f6c74aadd7" }, + "nvim-treesitter": { "branch": "master", "commit": "fa9fe9a95ba481e26e11eede4657f8c5350a0eaa" }, "nvim-treesitter-refactor": { "branch": "master", "commit": "65ad2eca822dfaec2a3603119ec3cc8826a7859e" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "b55fe6175f0001347a433c9df358c8cbf8a4e90f" }, - "nvim-various-textobjs": { "branch": "main", "commit": "a717bd2c30d352d98e3a2e5aea9f14b570954a70" }, - "nvim-web-devicons": { "branch": "master", "commit": "0568104bf8d0c3ab16395433fcc5c1638efc25d4" }, + "nvim-various-textobjs": { "branch": "main", "commit": "b0ec67f8d06f03b5e84aa90eac96f6153100c963" }, + "nvim-web-devicons": { "branch": "master", "commit": "f16ec8f6e5d23e4349501dae46e0a661918e086e" }, "phpactor.nvim": { "branch": "main", "commit": "013d9727c983bd4f0f8b3b25b77f3afb9e1eb98e" }, - "playground": { "branch": "master", "commit": "4044b53c4d4fcd7a78eae20b8627f78ce7dc6f56" }, + "playground": { "branch": "master", "commit": "934cb4c4adc2e7f4f351846a63c9532018c996ed" }, "plenary.nvim": { "branch": "master", "commit": "253d34830709d690f013daf2853a9d21ad7accab" }, "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, "refactoring.nvim": { "branch": "master", "commit": "e7c40818b2995016ede93c5620055206b1aba44f" }, "rest.nvim": { "branch": "main", "commit": "0fdb69f328529b34a2279c14be63b3325dc52740" }, - "smart-splits.nvim": { "branch": "master", "commit": "a39f98d40152aa293c55ab00d4730842da12cfe8" }, + "smart-splits.nvim": { "branch": "master", "commit": "68a7fedd4032d230fea11dfe4f2e7409b3a01345" }, "telescope-dap.nvim": { "branch": "master", "commit": "313d2ea12ae59a1ca51b62bf01fc941a983d9c9c" }, "telescope-file-browser.nvim": { "branch": "master", "commit": "e0fcb12702ad0d2873544a31730f9aaef04fd032" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "580b6c48651cabb63455e97d7e131ed557b8c7e2" }, "telescope-fzy-native.nvim": { "branch": "master", "commit": "282f069504515eec762ab6d6c89903377252bf5b" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "62ea5e58c7bbe191297b983a9e7e89420f581369" }, - "telescope.nvim": { "branch": "master", "commit": "942fe5faef47b21241e970551eba407bc10d9547" }, + "telescope.nvim": { "branch": "master", "commit": "7141515a7cabde46449675a403ed564416363887" }, "todo-comments.nvim": { "branch": "main", "commit": "8febc60a76feefd8203077ef78b6a262ea1a41f9" }, "trouble.nvim": { "branch": "main", "commit": "2ae7237c2917d661f458443c9a88680f8ca2d7b2" }, "vim-blade": { "branch": "master", "commit": "9534101808cc320eef003129a40cab04b026a20c" }, diff --git a/lua/alpha/lsp/attach.lua b/lua/alpha/lsp/attach.lua index d9f32bf..45ce904 100644 --- a/lua/alpha/lsp/attach.lua +++ b/lua/alpha/lsp/attach.lua @@ -8,11 +8,11 @@ local filetype_attach = setmetatable({}, { return function(client, bufnr) local filetype = vim.api.nvim_buf_get_option(0, "filetype") -- keymaps for lsp - vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = 0 }) - vim.keymap.set("n", "vrn", vim.lsp.buf.rename, { buffer = 0 }) - vim.keymap.set("i", "", vim.lsp.buf.signature_help, { buffer = 0 }) - vim.keymap.set("n", "vo", ":LspRestart", { noremap = true }) - vim.keymap.set({ "n", "v" }, "vca", vim.lsp.buf.code_action, {}) + vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = 0, desc = "LSP Help information of symbol under the cursor" }) + vim.keymap.set("n", "vrn", vim.lsp.buf.rename, { buffer = 0, desc = "LSP Rename symbol under cursor" }) + vim.keymap.set("i", "", vim.lsp.buf.signature_help, { buffer = 0, desc = "LSP Signature help" }) + vim.keymap.set("n", "vo", ":LspRestart", { noremap = true, desc = "LSP Restart Server" }) + vim.keymap.set({ "n", "v" }, "vca", vim.lsp.buf.code_action, { buffer = 0, desc = "LSP Code actions" }) vim.keymap.set("n", "vf", function() return vim.lsp.buf.format { async = true, @@ -20,12 +20,12 @@ return function(client, bufnr) return cli.name ~= "lua_ls" end, } - end, {}) + end, { buffer = 0, desc = "LSP format file" }) - telescope_mapper("gr", "lsp_references", nil, true) - telescope_mapper("pv", "find_symbol", nil, true) - telescope_mapper("pd", "lsp_document_symbols", nil, true) - telescope_mapper("", "lsp_definitions", nil, true) + telescope_mapper("gr", "lsp_references", { buffer = true, desc = "LSP References of symbol on cursor" }) + telescope_mapper("pv", "find_symbol", { buffer = true, desc = "LSP find symbol on the project" }) + telescope_mapper("pd", "lsp_document_symbols", { buffer = true, desc = "LSP document symbols" }) + telescope_mapper("", "lsp_definitions", { buffer = true, desc = "LSP go to definition" }) vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc" diff --git a/lua/alpha/lsp/null-ls.lua b/lua/alpha/lsp/null-ls.lua index 0a4443a..2c4c3bc 100644 --- a/lua/alpha/lsp/null-ls.lua +++ b/lua/alpha/lsp/null-ls.lua @@ -4,7 +4,7 @@ local php_actions = require "php-code-actions" null_ls.setup { sources = { - null_ls.builtins.code_actions.gitsigns, + -- null_ls.builtins.code_actions.gitsigns, null_ls.builtins.formatting.jq, null_ls.builtins.code_actions.refactoring, null_ls.builtins.formatting.alejandra, @@ -32,7 +32,7 @@ null_ls.setup { }, } -vim.keymap.set({ "n", "v" }, "vca", vim.lsp.buf.code_action, {}) +vim.keymap.set({ "n", "v" }, "vca", vim.lsp.buf.code_action, {desc = "LSP (null ls) Code actions"}) vim.keymap.set("n", "vf", function() return vim.lsp.buf.format { async = true } -end, {}) +end, {desc = "LSP (null ls) Format file"}) diff --git a/lua/alpha/php/gateway.lua b/lua/alpha/php/gateway.lua index 614c4f2..07fad33 100644 --- a/lua/alpha/php/gateway.lua +++ b/lua/alpha/php/gateway.lua @@ -49,7 +49,7 @@ end --- @param bufnr integer Buff id gateway.get_graphql_definitions = function(bufnr) - vim.treesitter.set_query( + vim.treesitter.query.set( "yaml", "GraphQL_endpoints", [[ @@ -69,7 +69,7 @@ gateway.get_graphql_definitions = function(bufnr) ]] ) - local query = vim.treesitter.get_query("yaml", "GraphQL_endpoints") + local query = vim.treesitter.query.get("yaml", "GraphQL_endpoints") local elements = {} diff --git a/lua/alpha/snips/ft/go.lua b/lua/alpha/snips/ft/go.lua index 637f57d..9c3977f 100644 --- a/lua/alpha/snips/ft/go.lua +++ b/lua/alpha/snips/ft/go.lua @@ -13,11 +13,6 @@ local ts_utils = require "nvim-treesitter.ts_utils" local get_node_text = vim.treesitter.get_node_text -if vim.fn.has "nvim-0.9.0" ~= 1 then - vim.treesitter.query.get = vim.treesitter.get_query - vim.treesitter.query.set = vim.treesitter.set_query -end - vim.treesitter.query.set( "go", "LuaSnip_Result", @@ -88,7 +83,7 @@ local function go_result_type(info) end end - local query = vim.treesitter.query.get_query("go", "LuaSnip_Result") + local query = vim.treesitter.query.get("go", "LuaSnip_Result") for _, node in query:iter_captures(function_node, 0) do if handlers[node:type()] then return handlers[node:type()](node, info) diff --git a/lua/alpha/telescope/actions.lua b/lua/alpha/telescope/actions.lua index c7cdaa8..b0e9f10 100644 --- a/lua/alpha/telescope/actions.lua +++ b/lua/alpha/telescope/actions.lua @@ -9,8 +9,9 @@ M.create_plugin = function(prompt_bufnr) vim.cmd(string.format("edit ~/.config/nvim/lua/plugins/%s.lua", new_plugin)) end + local get_disable_stm_node = function(bufnr, tree) - vim.treesitter.set_query( + vim.treesitter.query.set( "lua", "alpha_plugin_is_disabled", [[ @@ -27,7 +28,7 @@ local get_disable_stm_node = function(bufnr, tree) ]] ) - local query = vim.treesitter.get_query("lua", "alpha_plugin_is_disabled") + local query = vim.treesitter.query.get("lua", "alpha_plugin_is_disabled") for id, node in query:iter_captures(tree:root(), bufnr) do if query.captures[id] == "enabled" then @@ -39,7 +40,7 @@ local get_disable_stm_node = function(bufnr, tree) end local get_enabled_node = function(bufnr, tree) - vim.treesitter.set_query( + vim.treesitter.query.set( "lua", "alpha_plugin_has_enable_property", [[ @@ -55,7 +56,7 @@ local get_enabled_node = function(bufnr, tree) ]] ) - local query = vim.treesitter.get_query("lua", "alpha_plugin_has_enable_property") + local query = vim.treesitter.query.get("lua", "alpha_plugin_has_enable_property") for id, node in query:iter_captures(tree:root(), bufnr) do if query.captures[id] == "enabled" then @@ -67,7 +68,7 @@ local get_enabled_node = function(bufnr, tree) end local get_return_node = function(bufnr, tree) - vim.treesitter.set_query( + vim.treesitter.query.set( "lua", "alpha_plugin_return_table_constructor", [[ @@ -79,7 +80,7 @@ local get_return_node = function(bufnr, tree) ]] ) - local query = vim.treesitter.get_query("lua", "alpha_plugin_return_table_constructor") + local query = vim.treesitter.query.get("lua", "alpha_plugin_return_table_constructor") for id, node in query:iter_captures(tree:root(), bufnr) do if query.captures[id] == "table_constructor" then diff --git a/lua/alpha/telescope/init.lua b/lua/alpha/telescope/init.lua index 28397b0..70ef47f 100644 --- a/lua/alpha/telescope/init.lua +++ b/lua/alpha/telescope/init.lua @@ -84,7 +84,7 @@ function M.find_symbol() end function M.my_plugins() - if vim.fn.isdirectory "~/code/plugins/" == 0 then + if vim.fn.isdirectory(vim.fn.getenv "HOME" .. "/code/plugins/") == 0 then vim.notify("Directory ~/code/plugins does not exists", vim.log.levels.WARN, { title = "Telescope Mappings" }) return end @@ -98,11 +98,11 @@ function M.scratchs() prompt_title = "Scratchs", no_ignore = true, cwd = "~/.config/nvim/lua/scratchs/", - attach_mappings = function (_, map) + attach_mappings = function(_, map) map("i", "", my_actions.create_scratch_file) return true - end + end, } end diff --git a/lua/alpha/telescope/mappings.lua b/lua/alpha/telescope/mappings.lua index be59eaf..4843731 100644 --- a/lua/alpha/telescope/mappings.lua +++ b/lua/alpha/telescope/mappings.lua @@ -1,44 +1,50 @@ -TelescopeMapArgs = TelescopeMapArgs or {} - -local map_tele = function(key, f, options, buffer, mode) - mode = mode or "n" +local map_tele = function(key, f, opts) + local default = { + mode = "n", + options = {}, + buffer = nil, + desc = nil, + } + opts = opts or {} + opts = vim.tbl_deep_extend("force", default, opts or {}) local rhs = function() - R("alpha.telescope")[f](options or {}) + R("alpha.telescope")[f](opts.options) end local map_options = { remap = false, silent = true, } - if buffer then - map_options.buffer = buffer + if opts.buffer then + map_options.buffer = opts.buffer + end + if opts.desc then + map_options.desc = "Telescope: " .. opts.desc end - vim.keymap.set(mode, key, rhs, map_options) + vim.keymap.set(opts.mode, key, rhs, map_options) end -- not shure what this line does vim.api.nvim_set_keymap("c", "", "(TelescopeFuzzyCommandSearch)", { noremap = false, nowait = true }) -map_tele("pp", "project_files") -map_tele("gc", "branches") -map_tele("pw", "grep_word") -map_tele("ps", "grep_string") -map_tele("pf", "projectionist") -map_tele("rc", "search_config") -map_tele("rn", "find_nvim_config") -map_tele("rp", "find_nvim_plugin") -map_tele("rs", "scratchs") -map_tele("ph", "help_tags") -map_tele("pe", "buffers") -map_tele("pr", "treesitter") -map_tele("bb", "file_browser_relative") -map_tele("bp", "file_browser") -map_tele("gs", "git_status") -map_tele("ve", "diagnostics") -map_tele("fp", "my_plugins") -map_tele("po", "api_specs") -map_tele("pm", "gateway") +map_tele("pp", "project_files", { desc = "Open Project files" }) +map_tele("gc", "branches", { desc = "Git Branches selector" }) +map_tele("pw", "grep_word", { desc = "Grep word under cursor" }) +map_tele("ps", "grep_string", { desc = "Grep provided input string" }) +map_tele("rc", "search_config", { desc = "Search Files in .dotfiles directory" }) +map_tele("rn", "find_nvim_config", { desc = "Search Files in nvim config directory" }) +map_tele("rp", "find_nvim_plugin", { desc = "Search Neovim plugins" }) +map_tele("rs", "scratchs", { desc = "Search Neovim Scratchs files" }) +map_tele("ph", "help_tags", { desc = "Neovim Help" }) +map_tele("pe", "buffers", { desc = "Open buffers" }) +map_tele("pr", "treesitter", { desc = "Treesitter buffer elements" }) +map_tele("bb", "file_browser_relative", { desc = "Current directory" }) +map_tele("bp", "file_browser", { desc = "Project directory" }) +map_tele("gs", "git_status", { desc = "Git status" }) +map_tele("ve", "diagnostics", { desc = "Diagnostic of the buffer" }) +map_tele("po", "api_specs", { desc = "Openapi directory" }) +map_tele("pm", "gateway", { desc = "Graphql mutations and queries" }) return map_tele diff --git a/lua/alpha/utils.lua b/lua/alpha/utils.lua index b1202d6..ee80a1c 100644 --- a/lua/alpha/utils.lua +++ b/lua/alpha/utils.lua @@ -1,21 +1,21 @@ local M = {} M.save_and_exec = function() - local source_commands = { - lua = "luafi %", - vim = "source %", - } - - local ft = vim.api.nvim_buf_get_option(0, "filetype") - local command = source_commands[ft] - if command == nil then - vim.notify("This type cant not be sourced", vim.log.levels.ERROR, { title = "Alpha Developer" }) - return - end + -- local source_commands = { + -- lua = "luafi %", + -- vim = "source %", + -- } + -- + -- local ft = vim.api.nvim_buf_get_option(0, "filetype") + -- local command = source_commands[ft] + -- if command == nil then + -- vim.notify("This type cant not be sourced", vim.log.levels.ERROR, { title = "Alpha Developer" }) + -- return + -- end -- Save and source vim.api.nvim_command "silent w" - vim.api.nvim_command(command) + vim.api.nvim_command "so" local current_file_name = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(0), ":t") vim.notify(string.format("File %s Sourced", current_file_name), vim.log.levels.INFO, { title = "Alpha Developer" }) diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index ae03444..39831ed 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -4,36 +4,33 @@ map("v", "p", function() local val = vim.fn.getreg '"' vim.api.nvim_command [[normal! p]] vim.fn.setreg('"', val) -end) +end, { desc = "Special paste, paste without replacing copy register content" }) -map("n", "bd", ":bd!") +map("n", "bd", ":bd!", { desc = "Deletes the current buffer" }) -- lists navigation -map("n", "j", ":cnextzz") -map("n", "k", ":cprevzz") -map("n", "i", ":lnextzz") -map("n", "o", ":lprevzz") -map("n", "cc", ":cclose") - --- quick split -map("n", "wsv", ":vsp") +map("n", "", ":cnextzz", { desc = "Goes to the next item in the quickfixlist and center to the screen" }) +map("n", "", ":cprevzz", { desc = "Goes to the previous item in the quickfixlist and center to the screen" }) +-- map("n", "i", ":lnextzz") +-- map("n", "o", ":lprevzz") +map("n", "cc", ":cclose", { desc = "Close the quick fix list" }) -- tabulation -map("v", "<", "", ">gv") +map("v", "<", "", ">gv", { desc = "Indent in and keeps the selection" }) -- symbols to add undo points local symbols = { ",", ".", "!", "?", "$", ">", "<" } for _, symbol in pairs(symbols) do - map("i", symbol, symbol .. "u") + map("i", symbol, symbol .. "u", { desc = string.format("Add symbol %s to the undo list and writes it", symbol) }) end -- search result focus -map("n", "n", "nzzzv") -map("n", "N", "Nzzzv") +map("n", "n", "nzzzv", { desc = "Goes to next result on the search and put the cursor in the middle of the screen" }) +map("n", "N", "Nzzzv", { desc = "Goes to prev result on the search and put the cursor in the middle of the screen" }) -- join lines focus -map("n", "J", "mzJ`z") +map("n", "J", "mzJ`z", { desc = "Join lines and keep in the same place the cursor" }) -- Terminal map("t", "", "") @@ -43,10 +40,15 @@ map("t", "k", "k") map("t", "l", "l") -- quick env file edit -map("n", "ee", ":vsp .env") +map("n", "ee", ":vsp .env", { desc = "Open .env file in a vertical split" }) -- quick save and exec -map("n", "x", require("alpha.utils").save_and_exec) - -map("n", "vn", vim.diagnostic.goto_next, {}) -map("n", "vp", vim.diagnostic.goto_prev, {}) +map( + "n", + "x", + require("alpha.utils").save_and_exec, + { desc = "Save the current file and source it for .vim and .lua files" } +) + +map("n", "vn", vim.diagnostic.goto_next, { desc = "Goes to next diagnostic error" }) +map("n", "vp", vim.diagnostic.goto_prev, { desc = "Goes to prev diagnostic error" }) diff --git a/lua/plugins/color-picker.lua b/lua/plugins/color-picker.lua index 482103f..1e6c88b 100644 --- a/lua/plugins/color-picker.lua +++ b/lua/plugins/color-picker.lua @@ -1,7 +1,7 @@ return { "ziontee113/color-picker.nvim", keys = { - {"", "PickColorInsert", mode = "i"}, + { "", "PickColorInsert", mode = "i", desc = "ColorPicker" }, }, config = true, } diff --git a/lua/plugins/comment.lua b/lua/plugins/comment.lua index 84de2ba..801223b 100644 --- a/lua/plugins/comment.lua +++ b/lua/plugins/comment.lua @@ -1,5 +1,5 @@ return { "numToStr/Comment.nvim", - keys = { { "gcc" }, { "gbc" }, { "gc", mode = "v" }, { "gb", mode = "v" } }, + keys = { { "gcc", desc = "Comment current line" }, { "gc", mode = "v", desc = "Comment selected text" } }, config = true, } diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua index cdcdf85..a6582a6 100644 --- a/lua/plugins/dap.lua +++ b/lua/plugins/dap.lua @@ -9,7 +9,7 @@ return { "nvim-telescope/telescope-dap.nvim", "rcarriga/cmp-dap", }, - keys = { { "d" } }, + keys = { { "d", desc = "Open Debug menu" } }, config = function() require "alpha.dap" local ok_telescope, telescope = pcall(require, "telescope") diff --git a/lua/plugins/database.lua b/lua/plugins/database.lua index c6ed7ea..5c0bddf 100644 --- a/lua/plugins/database.lua +++ b/lua/plugins/database.lua @@ -5,7 +5,7 @@ return { "kristijanhusak/vim-dadbod-completion", "tpope/vim-dotenv", }, - keys = { { "db", ":tab DBUI" } }, + keys = { { "db", ":tab DBUI", desc = "Open Database client" } }, init = function() require "alpha.database" end, diff --git a/lua/plugins/easy-align.lua b/lua/plugins/easy-align.lua index 6e14908..7d33478 100644 --- a/lua/plugins/easy-align.lua +++ b/lua/plugins/easy-align.lua @@ -1,4 +1,4 @@ return { "junegunn/vim-easy-align", - keys = { { "ga", "(EasyAlign)", mode = { "n", "v" } } }, + keys = { { "ga", "(EasyAlign)", mode = { "n", "v" }, desc = "EasyAlign" } }, } diff --git a/lua/plugins/fugitive.lua b/lua/plugins/fugitive.lua index 10df419..4698d40 100644 --- a/lua/plugins/fugitive.lua +++ b/lua/plugins/fugitive.lua @@ -1,10 +1,10 @@ return { "tpope/vim-fugitive", keys = { - { "ga", ":Git fetch --all -p" }, - { "gl", ":Git pull" }, - { "gdh", ":diffget //2" }, - { "gdl", ":diffget //3" }, + { "ga", ":Git fetch --all -p", desc = "Git fetch" }, + { "gl", ":Git pull", desc = "Git pull" }, + { "gdh", ":diffget //2", desc = "Git diff grab from left" }, + { "gdl", ":diffget //3", desc = "Git diff grab from right" }, }, cmd = { "G", "Git" }, } diff --git a/lua/plugins/harpoon.lua b/lua/plugins/harpoon.lua index 06ec2aa..a214924 100644 --- a/lua/plugins/harpoon.lua +++ b/lua/plugins/harpoon.lua @@ -7,6 +7,7 @@ table.insert(keys, { function() require("harpoon.ui").toggle_quick_menu() end, + desc = "Harpoon Menu", }) table.insert(keys, { @@ -14,15 +15,17 @@ table.insert(keys, { function() require("harpoon.mark").add_file() end, + desc = "Harpoon Add file", }) table.insert(keys, { "st", - function () - vim.api.nvim_command([[vsplit]]) + function() + vim.api.nvim_command [[vsplit]] require("harpoon.term").gotoTerminal(1) - vim.api.nvim_command([[startinsert]]) - end + vim.api.nvim_command [[startinsert]] + end, + desc = "Harpoon quick split Terminal", }) for i = 1, terms do @@ -31,6 +34,7 @@ for i = 1, terms do function() require("harpoon.term").gotoTerminal(i) end, + desc = "Harpoon go to terminal " .. i, }) end @@ -40,6 +44,7 @@ for i = 1, binds do function() require("harpoon.ui").nav_file(i) end, + desc = "Harpoon go to file " .. i, }) end diff --git a/lua/plugins/icon-picker.lua b/lua/plugins/icon-picker.lua index e9f1e94..a466b6a 100644 --- a/lua/plugins/icon-picker.lua +++ b/lua/plugins/icon-picker.lua @@ -1,9 +1,9 @@ return { "ziontee113/icon-picker.nvim", keys = { - { "i", "IconPickerNormal nerd_font", mode = "n" }, - { "y", "IconPickerYank nerd_font", mode = "n" }, - { "", "IconPickerInsert nerd_font", mode = "i" }, + { "i", "IconPickerNormal nerd_font", mode = "n", desc = "IconPicker NerdFont Insert" }, + { "y", "IconPickerYank nerd_font", mode = "n", desc = "IconPicker NerdFont Yank" }, + { "", "IconPickerInsert nerd_font", mode = "i", desc = "IconPicker NerdFont Insert mode" }, }, opts = { disable_legacy_commands = true }, } diff --git a/lua/plugins/laravel.lua b/lua/plugins/laravel.lua index b236e54..b87b12b 100644 --- a/lua/plugins/laravel.lua +++ b/lua/plugins/laravel.lua @@ -6,8 +6,8 @@ return { }, cmd = { "Sail", "Artisan", "Composer", "Npm", "Laravel" }, keys = { - { "la", ":Laravel artisan" }, - { "lr", ":Laravel routes" }, + { "la", ":Laravel artisan", desc = "Laravel Application Commands" }, + { "lr", ":Laravel routes", desc = "Laravel Application Routes" }, }, config = function() vim.g.laravel_log_level = "debug" diff --git a/lua/plugins/neogen.lua b/lua/plugins/neogen.lua index 9fd3c36..6b234ae 100644 --- a/lua/plugins/neogen.lua +++ b/lua/plugins/neogen.lua @@ -2,6 +2,6 @@ return { "danymat/neogen", dependencies = "nvim-treesitter/nvim-treesitter", cmd = { "Neogen" }, - keys = {{"n", ":Neogen"}}, + keys = { { "n", ":Neogen", desc = "Add comment to the near possible object" } }, opts = { snippet_engine = "luasnip" }, } diff --git a/lua/plugins/overseer.lua b/lua/plugins/overseer.lua index ab773ac..634de8b 100644 --- a/lua/plugins/overseer.lua +++ b/lua/plugins/overseer.lua @@ -1,5 +1,5 @@ return { "stevearc/overseer.nvim", - enabled = false, + enabled = false, config = true, } diff --git a/lua/plugins/refactoring.lua b/lua/plugins/refactoring.lua index 6c48610..92cdf64 100644 --- a/lua/plugins/refactoring.lua +++ b/lua/plugins/refactoring.lua @@ -11,6 +11,7 @@ return { require("telescope").extensions.refactoring.refactors() end, mode = { "n", "v" }, + desc = "Refactoring menu", }, }, config = function() diff --git a/lua/plugins/rest.lua b/lua/plugins/rest.lua index 2391d02..2eca102 100644 --- a/lua/plugins/rest.lua +++ b/lua/plugins/rest.lua @@ -32,11 +32,21 @@ return { pattern = "http", callback = function() local buff = tonumber(vim.fn.expand "", 10) - vim.keymap.set("n", "rn", rest_nvim.run, { noremap = true, buffer = buff }) - vim.keymap.set("n", "rl", rest_nvim.last, { noremap = true, buffer = buff }) - vim.keymap.set("n", "rp", function() + vim.keymap.set( + "n", + "hn", + rest_nvim.run, + { noremap = true, buffer = buff, desc = "Run near http request" } + ) + vim.keymap.set( + "n", + "hl", + rest_nvim.last, + { noremap = true, buffer = buff, desc = "Run last http resquest" } + ) + vim.keymap.set("n", "hp", function() rest_nvim.run(true) - end, { noremap = true, buffer = buff }) + end, { noremap = true, buffer = buff, desc = "Preview http curl" }) end, }) end, diff --git a/lua/plugins/smart-splits.lua b/lua/plugins/smart-splits.lua index 49e1df3..57faedb 100644 --- a/lua/plugins/smart-splits.lua +++ b/lua/plugins/smart-splits.lua @@ -7,24 +7,28 @@ return { function() require("smart-splits").resize_left() end, + desc = "Resize window left +10", }, { "", function() require("smart-splits").resize_down() end, + desc = "Resize window down +10", }, { "", function() require("smart-splits").resize_up() end, + desc = "Resize window up +10", }, { "", function() require("smart-splits").resize_right() end, + desc = "Resize window right +10", }, }, } diff --git a/lua/plugins/smooth-cursor.lua b/lua/plugins/smooth-cursor.lua index d855e1c..58efc73 100644 --- a/lua/plugins/smooth-cursor.lua +++ b/lua/plugins/smooth-cursor.lua @@ -1,7 +1,7 @@ return { "gen740/SmoothCursor.nvim", config = function() - require("smoothcursor").setup({cursor = ""}) + require("smoothcursor").setup { cursor = "" } vim.api.nvim_set_hl(0, "SmoothCursor", { fg = "#8a9baa" }) diff --git a/lua/plugins/snippets.lua b/lua/plugins/snippets.lua index 9ed2edf..48c93b8 100644 --- a/lua/plugins/snippets.lua +++ b/lua/plugins/snippets.lua @@ -133,6 +133,6 @@ return { event = "VeryLazy", config = function() config() - vim.keymap.set("n", "s", config) + vim.keymap.set("n", "s", config, { desc = "Reload snippets" }) end, } diff --git a/lua/plugins/spectre.lua b/lua/plugins/spectre.lua index e11a328..7510c7a 100644 --- a/lua/plugins/spectre.lua +++ b/lua/plugins/spectre.lua @@ -1,5 +1,5 @@ return { "nvim-pack/nvim-spectre", - keys = {{"F", ":Spectre"}}, + keys = { { "F", ":Spectre", desc = "Spectre Search open" } }, config = true, } diff --git a/lua/plugins/test.lua b/lua/plugins/test.lua index e203679..aa9cba7 100644 --- a/lua/plugins/test.lua +++ b/lua/plugins/test.lua @@ -1,6 +1,6 @@ return { "vim-test/vim-test", - keys = { { "t" } }, + keys = { { "t", desc = "Open Test menu" } }, dependencies = { "anuvyklack/hydra.nvim", }, diff --git a/lua/plugins/todo-comments.lua b/lua/plugins/todo-comments.lua index 2e53f49..fef635e 100644 --- a/lua/plugins/todo-comments.lua +++ b/lua/plugins/todo-comments.lua @@ -12,12 +12,14 @@ return { function() require("todo-comments").jump_next() end, + desc = "Jump to next TODO", }, { "[t", function() require("todo-comments").jump_prev() end, + desc = "Jump to prev TODO", }, }, } diff --git a/lua/plugins/trouble.lua b/lua/plugins/trouble.lua index 5d53edb..81dcff9 100644 --- a/lua/plugins/trouble.lua +++ b/lua/plugins/trouble.lua @@ -1,6 +1,6 @@ return { "folke/trouble.nvim", dependencies = "kyazdani42/nvim-web-devicons", - keys = { { "t", "TroubleToggle" } }, + keys = { { "t", "TroubleToggle", desc = "Trouble toggle" } }, config = true, } diff --git a/lua/plugins/worktree.lua b/lua/plugins/worktree.lua index c3bfd8d..9e74a9c 100644 --- a/lua/plugins/worktree.lua +++ b/lua/plugins/worktree.lua @@ -6,12 +6,14 @@ return { function() require("telescope").extensions.git_worktree.git_worktrees() end, + desc = "Git Worktree switch", }, { "gn", function() require("telescope").extensions.git_worktree.create_git_worktree() end, + desc = "Git Worktree new branch", }, }, config = function() -- cgit v1.2.3