diff options
Diffstat (limited to '.config')
-rw-r--r-- | .config/nvim/init.lua | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index fe7ed8f..1c2d070 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -62,16 +62,12 @@ vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' }) vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' }) -vim.keymap.set('n', '<C-v>', 'V', - { desc = 'Enter visual-line mode' }) vim.keymap.set('n', '<leader>h', function() vim.cmd 'split' end, { desc = 'Open a [H]orizontal split' }) vim.keymap.set('n', '<leader>v', function() vim.cmd 'vsplit' end, { desc = 'Open a [V]ertical split' }) vim.keymap.set('n', 'M', ':w! | make<CR>', { desc = 'Run the configured compiler' }) -vim.keymap.set('n', 'V', '<C-v>', - { desc = 'Enter visual-block mode' }) vim.keymap.set('x', '<C-j>', ":m '>+1<CR>gv=gv", { desc = 'Move a selection down a line' }) vim.keymap.set('x', '<C-k>', ":m '<-2<CR>gv=gv", @@ -86,6 +82,16 @@ vim.keymap.set('n', '<leader>T', function() vim.cmd.normal('"zX"zp') end, { desc = '[T]ranspose the current and previous characters' }) vim.keymap.set('n', '-', ':Ex<CR>', { desc = 'Open Netrw' }) +vim.keymap.set('n', 'gJ', function() + vim.cmd [[ + let save = winsaveview() + normal! gJ + if matchstr(getline('.'), '\%' . col('.') . 'c.') =~ '\s' + normal! "_dw + endif + call winrestview(save) + ]] +end, { desc = '[J]oin lines without whitespace' }) vim.keymap.set('n', '<leader>k', function() vim.cmd 'vsplit' @@ -96,6 +102,13 @@ vim.keymap.set('n', '<leader>K', function() mk_scratch_buffer() end, { desc = 'Open the scratch buffer in a horizontal split' }) +if vim.loop.os_uname().sysname ~= 'Darwin' then + vim.keymap.set('n', '<C-v>', 'V', + { desc = 'Enter visual-line mode' }) + vim.keymap.set('n', 'V', '<C-v>', + { desc = 'Enter visual-block mode' }) +end + -- Don’t move the cursor with various commands vim.keymap.set('n', 'J', 'mzJ`z') vim.keymap.set('n', '<C-d>', '<C-d>zz') |