vim.api.nvim_set_keymap('', '', '', { noremap = true, silent = true }) vim.g.mapleader = " " vim.g.maplocalleader = " " local options = { noremap = true, silent = true } local normal_mode_maps = { -- toggles { key = '', map = [[set number! relativenumber!]] }, -- navigation { key = '', map = [[]] }, { key = 'n', map = [[bnext]] }, { key = 'p', map = [[bprev]] }, { key = 'q', map = [[bw]] }, { key = 'v', map = [[CHADopen]] }, -- " Find files using Telescope command-line sugar. { key = 'ff', map = [[lua require('telescope.builtin').find_files()]] }, { key = 'gg', map = [[lua require('telescope.builtin').live_grep()]] }, { key = ';', map = [[lua require('telescope.builtin').buffers()]] }, { key = 'fh', map = [[lua require('telescope.builtin').help_tags()]] }, { key = 'gB', map = [[Git blame]] }, { key = 'rd', map = [[RustDebuggables]] }, { key = 'rr', map = [[RustRunnables]] }, -- Session { key = 'ss', map = [[SessionSave]] }, { key = 'sl', map = [[SessionLoad]] }, -- lsp { key = 'K', map = [[lua vim.lsp.buf.hover()]] }, { key = '', map = [[lua vim.lsp.buf.definition()]] }, { key = 'gi', map = [[lua vim.lsp.buf.implementation()]] }, { key = 'o', map = [[TroubleToggle]] }, -- { key = 'a', map = [[lua vim.lsp.buf.document_highlight()]] }, -- { key = 'c', map = [[lua vim.lsp.buf.clear_references()]] }, { key = '"', map = [["+]] }, { key = 'F', map = [[lua vim.lsp.buf.formatting()]] }, { key = 'T', map = [[lua require'lsp_extensions'.inlay_hints()]] }, -- { key = '', map = [[vsplit]] }, -- Other { key = 'm', map = [[silent !mpcfzf]] }, { key = 'l', map = [[Glow]] }, } local insert_mode_maps = { { key = '', map = '' }, { key = "", map = 'copilot#Accept("")', options = { silent = true, expr = true } }, { key = "", map = 'copilot#Accept("")', options = { silent = true, expr = true } }, } for idx = 1, #normal_mode_maps do if normal_mode_maps[idx].options then local options = normal_mode_maps[idx].options vim.api.nvim_set_keymap('n', normal_mode_maps[idx].key, normal_mode_maps[idx].map, options) else vim.api.nvim_set_keymap('n', normal_mode_maps[idx].key, normal_mode_maps[idx].map, options) end end for idx = 1, #insert_mode_maps do if insert_mode_maps[idx].options then local options = insert_mode_maps[idx].options vim.api.nvim_set_keymap('i', insert_mode_maps[idx].key, insert_mode_maps[idx].map, options) else vim.api.nvim_set_keymap('i', insert_mode_maps[idx].key, insert_mode_maps[idx].map, options) end end