This commit is contained in:
Christoph J. Scherr 2024-07-04 17:35:15 +02:00
parent 15d3715bea
commit 33e8aea3f0
3 changed files with 50 additions and 27 deletions

View File

@ -27,8 +27,8 @@ vim.keymap.set({ 'v', 'n' }, 'zj', '<C-y>', { desc = 'move and scroll down' })
-- go to beginning and end in insert mode
vim.keymap.set('i', '<C-s>', '<esc>^i', { desc = 'Go to the start of the line' })
vim.keymap.set('i', '<C-e>', '<End>', { desc = 'Go to the end of the line' })
vim.keymap.set('i', '<C-w>', '<esc>wa', { desc = 'Go a word further' })
vim.keymap.set('i', '<C-b>', '<esc>ba', { desc = 'Go a word backward' })
vim.keymap.set('i', '<C-w>', '<esc>wi', { desc = 'Go a word further' })
vim.keymap.set('i', '<C-b>', '<esc>bi', { desc = 'Go a word backward' })
-- navigate hjkl in insert mode
vim.keymap.set('i', '<C-h>', '<Left>', { desc = 'Move left' })
@ -36,6 +36,20 @@ vim.keymap.set('i', '<C-j>', '<Right>', { desc = 'Move right' })
vim.keymap.set('i', '<C-k>', '<Down>', { desc = 'Move down' })
vim.keymap.set('i', '<C-l>', '<Up>', { desc = 'Move up' })
-- move to window
-- See `:help wincmd` for a list of all window commands
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
-- diagnostics
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
-- let me out!!!
vim.keymap.set({ 'n', 'v' }, 'qq', '<cmd>q!<cr>', { desc = '[Q]uit the current window' })
--------------------------------------------------------------------------------
-- Workspace, buffer and window manipulation
--------------------------------------------------------------------------------
@ -59,20 +73,6 @@ vim.keymap.set('n', '<leader>wj', '<cmd>tabprevious<cr>', { desc = 'Last [W]orks
vim.keymap.set('t', '<C-w>', vim.api.nvim_replace_termcodes('<C-\\><C-N>', true, true, true), { desc = 'Leave terminal mode' })
--------------------------------------------------------------------------------
-- Move to things
--------------------------------------------------------------------------------
-- move to window
-- See `:help wincmd` for a list of all window commands
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
-- diagnostics
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
--------------------------------------------------------------------------------
-- Editing
--------------------------------------------------------------------------------

View File

@ -13,9 +13,19 @@ return {
function()
require('Comment.api').toggle.linewise.current()
end,
mode = { 'n', 'v' },
mode = { 'n' },
desc = 'Comment toggle current line',
},
{
'<leader>v',
function()
local esc = vim.api.nvim_replace_termcodes('<ESC>', true, false, true)
vim.api.nvim_feedkeys(esc, 'nx', false)
require('Comment.api').toggle.linewise(vim.fn.visualmode())
end,
mode = { 'x' },
desc = 'Comment toggle selected lines',
},
},
config = function(_, opts)
vim.keymap.set('n', '<leader>c', function()
@ -59,4 +69,17 @@ return {
require('icon-picker').setup { disable_legacy_commands = true }
end,
},
{
'windwp/nvim-autopairs',
event = 'InsertEnter',
-- Optional dependency
dependencies = { 'hrsh7th/nvim-cmp' },
config = function()
require('nvim-autopairs').setup {}
-- If you want to automatically add `(` after selecting a function or method
local cmp_autopairs = require 'nvim-autopairs.completion.cmp'
local cmp = require 'cmp'
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
end,
},
}

View File

@ -157,16 +157,16 @@ return {
--
-- <c-l> will move you to the right of each of the expansion locations.
-- <c-h> is similar, except moving you backwards.
['<C-l>'] = cmp.mapping(function()
if luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
end
end, { 'i', 's' }),
['<C-h>'] = cmp.mapping(function()
if luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
end
end, { 'i', 's' }),
--['<C-l>'] = cmp.mapping(function()
-- if luasnip.expand_or_locally_jumpable() then
-- luasnip.expand_or_jump()
-- end
--end, { 'i', 's' }),
--['<C-h>'] = cmp.mapping(function()
-- if luasnip.locally_jumpable(-1) then
-- luasnip.jump(-1)
-- end
--end, { 'i', 's' }),
-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps