You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.7 KiB
59 lines
1.7 KiB
-- 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) |
|
|
|
|