-- General-Purpose keybinds local keymap_opts = { silent = true, noremap = true } function NumberToggle() if vim.o.relativenumber then vim.opt.relativenumber = false vim.opt.number = true else vim.opt.relativenumber = true end end -- Space is the leader key when outside of insert mode. vim.g.mapleader = " " -- Telescope local builtin = require('telescope.builtin') vim.keymap.set('n', 'ff', builtin.find_files, {}) vim.keymap.set('n', 'fg', builtin.live_grep, {}) vim.keymap.set('n', 'fb', builtin.buffers, {}) vim.keymap.set('n', 'fh', builtin.help_tags, {}) vim.api.nvim_set_keymap('', 't', ':NERDTreeToggle', {silent = true}) -- -r controls relative line numbering. vim.api.nvim_set_keymap('n', 'r', 'lua NumberToggle()', keymap_opts) -- Pressing enter in command mode clears the current search highlighting until -- the next search. vim.api.nvim_set_keymap('n', '', ':noh', keymap_opts) -- Autocomplete bindings vim.keymap.set('i', '', function() if vim.fn.pumvisible() == 1 then return '' end return '' end, {expr = true}) vim.keymap.set('i', '', function() if vim.fn.pumvisible() == 1 then return '' end return '' end, {expr = true}) vim.keymap.set('i', '', function() if vim.fn.pumvisible() == 1 then vim.cmd [[ asyncomplete#close_popup() . "\" ]] else return '' end end, {expr = true}) vim.keymap.set('i', '', '(asyncomplete_force_refresh)', keymap_opts) -- This one maps F5 to delete all trailing whitespace vim.api.nvim_set_keymap( 'n', '', [[:let _s=@/:%s/\s\+$//e:let @/=_s:nohl]], keymap_opts) -- vimspector keybinds vim.keymap.set('n', '', 'call vimspector#Launch()') vim.keymap.set('n', '', 'call vimspector#StepOver()') vim.keymap.set('n', '', 'call vimspector#Reset()') vim.keymap.set('n', '', 'call vimspector#StepOver()') vim.keymap.set('n', '', 'call vimspector#StepOut()') vim.keymap.set('n', '', 'call vimspector#StepInto()') vim.keymap.set('n', "Db", ":call vimspector#ToggleBreakpoint()") vim.keymap.set('n', "Dw", ":call vimspector#AddWatch()") vim.keymap.set('n', "De", ":call vimspector#Evaluate()") -- Fugitive bindings vim.api.nvim_set_keymap('n', 'gs', ':Git', {noremap = true}) vim.api.nvim_set_keymap('n', 'gd', ':Git diff', {noremap = true}) vim.api.nvim_set_keymap('n', 'gb', ':Git blame', {noremap = true}) vim.api.nvim_set_keymap('n', 'gc', ':Git commit', {noremap = true}) vim.api.nvim_set_keymap('n', 'gp', ':Git push', {noremap = true})