some variety on macbook
This commit is contained in:
parent
1bbc50e3a9
commit
63e44654f1
19 changed files with 229 additions and 99 deletions
|
|
@ -1,9 +1,22 @@
|
|||
local map = vim.keymap.set
|
||||
lcal map = vim.keymap.set
|
||||
|
||||
-- The good 'ol keybinds
|
||||
map('n', '<C-s>', '<cmd>w<CR>', { noremap = true, silent = true, desc = 'File save' })
|
||||
map('n', '<C-a>', 'ggVG', { noremap = true, silent = true })
|
||||
map('n', '<C-s>', '<cmd>w<CR>', { noremap = true, desc = 'File save' })
|
||||
map('n', '<C-c>', '<cmd>%y+<CR>', { desc = 'File copy whole' })
|
||||
|
||||
-- Activate Ctrl+V as paste
|
||||
map('c', '<C-v>', function()
|
||||
local pos = vim.fn.getcmdpos()
|
||||
local text = vim.fn.getcmdline()
|
||||
local lt = text:sub(1, pos - 1)
|
||||
local rt = text:sub(pos)
|
||||
local clip = vim.fn.getreg '+'
|
||||
vim.fn.setcmdline(lt .. clip .. rt, pos + clip:len())
|
||||
vim.cmd [[echo '' | redraw]]
|
||||
end, { silent = true, noremap = true, desc = 'Command paste' })
|
||||
map({ 'i', 'n' }, '<C-v>', '"+p', { noremap = true, desc = 'Command paste' })
|
||||
|
||||
-- Move between windows with arrows
|
||||
map('n', '<C-Left>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
|
||||
map('n', '<C-Right>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
|
||||
|
|
@ -20,8 +33,12 @@ map('n', '<C-Up>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
|
|||
-- })
|
||||
|
||||
-- Keep cursor centered when PgUp & PgDown
|
||||
map({ 'n', 'i', 'v' }, '<PageUp>', '<PageUp><CMD>normal zz<CR>', { desc = 'Page up' })
|
||||
map({ 'n', 'i', 'v' }, '<PageDown>', '<PageDown><CMD>normal zz<CR>', { desc = 'Page down' })
|
||||
map('n', '<PgDown>', '<C-d><C-d>', { desc = 'Page down' })
|
||||
map('n', '<PgUp>', '<C-u><C-u>', { desc = 'Page up' })
|
||||
map('n', '<C-d>', '<C-d>zz', { desc = 'Half page down' })
|
||||
map('n', '<C-u>', '<C-u>zz', { desc = 'Half page up' })
|
||||
map('n', 'n', 'nzzzv', { desc = 'so and so...' })
|
||||
map('n', 'N', 'Nzzzv', { desc = 'so and so...' })
|
||||
|
||||
-- Redirect command output and allow edit
|
||||
map('c', '<S-CR>', function()
|
||||
|
|
@ -44,5 +61,36 @@ vim.api.nvim_create_autocmd('LspAttach', {
|
|||
map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclarations')
|
||||
map('gic', builtin.lsp_incoming_calls, '[G]oto [I]ncoming [C]alls')
|
||||
map('goc', builtin.lsp_outgoing_calls, '[G]oto [O]utgoing [C]alls')
|
||||
|
||||
vim.keymap.set({ 'n', 'i' }, '<A-k>', vim.lsp.buf.hover, { noremap = true })
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
callback = function(event)
|
||||
local gitsigns = require 'gitsigns'
|
||||
|
||||
local function map(mode, l, r, opts)
|
||||
opts = opts or {}
|
||||
opts.buffer = bufnr
|
||||
vim.keymap.set(mode, l, r, opts)
|
||||
end
|
||||
|
||||
-- Navigation
|
||||
map('n', ']c', function()
|
||||
if vim.wo.diff then
|
||||
vim.cmd.normal { ']c', bang = true }
|
||||
else
|
||||
gitsigns.nav_hunk 'next'
|
||||
end
|
||||
end, { desc = 'Jump to next git [C]hange' })
|
||||
|
||||
map('n', '[c', function()
|
||||
if vim.wo.diff then
|
||||
vim.cmd.normal { '[c', bang = true }
|
||||
else
|
||||
gitsigns.nav_hunk 'prev'
|
||||
end
|
||||
end, { desc = 'Jump to previous git [C]hange' })
|
||||
end,
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue