|
|
|
-- 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', '<leader>ff', builtin.find_files, {})
|
|
|
|
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
|
|
|
|
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
|
|
|
|
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
|
|
|
|
|
|
|
|
vim.api.nvim_set_keymap('', '<Leader>t', ':NERDTreeToggle<CR>', {silent = true})
|
|
|
|
|
|
|
|
-- <SPC>-r controls relative line numbering.
|
|
|
|
vim.api.nvim_set_keymap('n', '<Leader>r', '<cmd>lua NumberToggle()<CR>', keymap_opts)
|
|
|
|
|
|
|
|
-- Pressing enter in command mode clears the current search highlighting until
|
|
|
|
-- the next search.
|
|
|
|
vim.api.nvim_set_keymap('n', '<CR>', ':noh<CR><CR>', keymap_opts)
|
|
|
|
|
|
|
|
-- Autocomplete bindings
|
|
|
|
vim.keymap.set('i', '<Tab>', function()
|
|
|
|
if vim.fn.pumvisible() == 1 then return '<C-n>' end
|
|
|
|
return '<Tab>'
|
|
|
|
end, {expr = true})
|
|
|
|
|
|
|
|
vim.keymap.set('i', '<S-Tab>', function()
|
|
|
|
if vim.fn.pumvisible() == 1 then return '<C-p>' end
|
|
|
|
return '<S-Tab>'
|
|
|
|
end, {expr = true})
|
|
|
|
|
|
|
|
vim.keymap.set('i', '<CR>', function()
|
|
|
|
if vim.fn.pumvisible() == 1 then
|
|
|
|
vim.cmd [[ asyncomplete#close_popup() . "\<CR>" ]]
|
|
|
|
else
|
|
|
|
return '<CR>'
|
|
|
|
end
|
|
|
|
end, {expr = true})
|
|
|
|
|
|
|
|
vim.keymap.set('i', '<C-Space>', '<Plug>(asyncomplete_force_refresh)', keymap_opts)
|
|
|
|
|
|
|
|
-- This one maps F5 to delete all trailing whitespace
|
|
|
|
vim.api.nvim_set_keymap(
|
|
|
|
'n',
|
|
|
|
'<F5>',
|
|
|
|
[[:let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>]],
|
|
|
|
keymap_opts)
|
|
|
|
|
|
|
|
|
|
|
|
-- vimspector keybinds
|
|
|
|
vim.keymap.set('n', '<F9>', '<cmd>call vimspector#Launch()<cr>')
|
|
|
|
vim.keymap.set('n', '<F5>', '<cmd>call vimspector#StepOver()<cr>')
|
|
|
|
vim.keymap.set('n', '<F8>', '<cmd>call vimspector#Reset()<cr>')
|
|
|
|
vim.keymap.set('n', '<F11>', '<cmd>call vimspector#StepOver()<cr>')
|
|
|
|
vim.keymap.set('n', '<F12>', '<cmd>call vimspector#StepOut()<cr>')
|
|
|
|
vim.keymap.set('n', '<F10>', '<cmd>call vimspector#StepInto()<cr>')
|
|
|
|
|
|
|
|
vim.keymap.set('n', "Db", ":call vimspector#ToggleBreakpoint()<cr>")
|
|
|
|
vim.keymap.set('n', "Dw", ":call vimspector#AddWatch()<cr>")
|
|
|
|
vim.keymap.set('n', "De", ":call vimspector#Evaluate()<cr>")
|
|
|
|
|
|
|
|
-- Fugitive bindings
|
|
|
|
vim.api.nvim_set_keymap('n', '<Leader>gs', ':Git<CR>', {noremap = true})
|
|
|
|
vim.api.nvim_set_keymap('n', '<Leader>gd', ':Git diff<CR>', {noremap = true})
|
|
|
|
vim.api.nvim_set_keymap('n', '<Leader>gb', ':Git blame<CR>', {noremap = true})
|
|
|
|
vim.api.nvim_set_keymap('n', '<Leader>gc', ':Git commit<CR>', {noremap = true})
|
|
|
|
vim.api.nvim_set_keymap('n', '<Leader>gp', ':Git push<CR>', {noremap = true})
|