mirror of
https://git.disroot.org/FollieHiyuki/dotfiles.git
synced 2024-11-29 10:48:46 -05:00
52b9be4bee
Also add more nord highlight groups
126 lines
3.3 KiB
Lua
126 lines
3.3 KiB
Lua
local api = vim.api
|
|
local wk = require('which-key')
|
|
|
|
--------------------
|
|
-- Basic bindings --
|
|
--------------------
|
|
-- No one likes Esc
|
|
api.nvim_set_keymap('i', 'jk', [[<Esc>]], {noremap = true, silent = true})
|
|
|
|
-- Escape to normal mode in terminal buffer
|
|
api.nvim_set_keymap('t', '<Esc>', '<C-\\><C-n>', {noremap = true, silent = true})
|
|
|
|
-- Continuous indent
|
|
api.nvim_set_keymap('v', '<', '<gv', {noremap = true, silent = true})
|
|
api.nvim_set_keymap('v', '>', '>gv', {noremap = true, silent = true})
|
|
|
|
-- Normal mode
|
|
wk.register({
|
|
-- Better Y
|
|
Y = {'y$', 'Yank to eol'},
|
|
|
|
-- Copy the whole buffer
|
|
['<C-a>'] = {'<Cmd>%y+<CR>', 'Copy whole buffer'},
|
|
|
|
-- 'Legacy' save buffer
|
|
-- ['<C-s>'] = {':w<CR>', 'Write buffer'},
|
|
|
|
-- Close buffer
|
|
['<C-x>'] = {':bd!<CR>', 'Close buffer'},
|
|
|
|
-- Remove trailing whitespace
|
|
['<A-w>'] = {':%s/\\s\\+$//e<CR>', 'Remove trailing'},
|
|
|
|
-- Resize buffer
|
|
['<A-j>'] = {':resize -2<CR>', 'Resize vertical -2'},
|
|
['<A-k>'] = {':resize +2<CR>', 'Resize vertical +2'},
|
|
['<A-h>'] = {':vertical resize -2<CR>', 'Resize horizontal -2'},
|
|
['<A-l>'] = {':vertical resize +2<CR>', 'Resize horizontal +2'},
|
|
|
|
-- Switch between tabs and spaces
|
|
['<A-t>'] = {
|
|
function()
|
|
if vim.o.expandtab == true then
|
|
vim.cmd('set noexpandtab nosmarttab softtabstop& shiftwidth&')
|
|
vim.cmd('echomsg "Switched to indent with tabs"')
|
|
else
|
|
vim.opt.expandtab = true
|
|
vim.opt.smarttab = true
|
|
vim.opt.softtabstop = 4
|
|
vim.opt.shiftwidth = 4
|
|
vim.cmd('echomsg "Switched to indent with 4 spaces"')
|
|
end
|
|
end,
|
|
'Switch indent style'
|
|
},
|
|
|
|
-- Naming common keys
|
|
['['] = {name = 'Block motions (previous)'},
|
|
[']'] = {name = 'Block motions (next)'},
|
|
g = {name = 'Goto motions'},
|
|
z = {name = 'Misc utils'}
|
|
})
|
|
|
|
-------------
|
|
-- Plugins --
|
|
-------------
|
|
-- Normal mode
|
|
wk.register({
|
|
-- Don't need to show bufferline numbers
|
|
['<leader>1'] = 'which_key_ignore',
|
|
['<leader>2'] = 'which_key_ignore',
|
|
['<leader>3'] = 'which_key_ignore',
|
|
['<leader>4'] = 'which_key_ignore',
|
|
['<leader>5'] = 'which_key_ignore',
|
|
['<leader>6'] = 'which_key_ignore',
|
|
['<leader>7'] = 'which_key_ignore',
|
|
['<leader>8'] = 'which_key_ignore',
|
|
['<leader>9'] = 'which_key_ignore',
|
|
|
|
-- Move between tabs
|
|
['<TAB>'] = {'<Cmd>BufferLineCycleNext<CR>', 'Next buffer'},
|
|
['<S-TAB>'] = {'<Cmd>BufferLineCyclePrev<CR>', 'Previous buffer'},
|
|
|
|
-- NvimTree
|
|
['<C-n>'] = {':NvimTreeToggle<CR>', 'NvimTree'},
|
|
|
|
-- ToggleTerm
|
|
['<C-\\>'] = 'Toggle terminal',
|
|
})
|
|
|
|
-- With leader key (normal mode)
|
|
wk.register({
|
|
-- GitSigns
|
|
g = {
|
|
name = 'Git',
|
|
b = 'Blame current line',
|
|
i = 'Preview hunk',
|
|
n = 'Next hunk',
|
|
p = 'Previous hunk',
|
|
r = 'Reset hunk',
|
|
R = 'Reset all hunks in buffer',
|
|
s = 'Stage hunk',
|
|
u = 'Undo hunk'
|
|
},
|
|
|
|
-- Telescope
|
|
f = {
|
|
name = 'Telescope'
|
|
},
|
|
|
|
b = {
|
|
name = 'Buffer',
|
|
n = {':DashboardNewFile<CR>', 'New file'}
|
|
}
|
|
}, {prefix = '<leader>'})
|
|
|
|
-- With leader key (visual mode)
|
|
wk.register({
|
|
-- GitSigns
|
|
g = {
|
|
name = 'Git',
|
|
r = 'Reset hunk',
|
|
s = 'Stage hunk'
|
|
}
|
|
}, {mode = 'v', prefix = '<leader>'})
|