From c88ea4938a434aeabd3d4f6f22e146fa19a35a43 Mon Sep 17 00:00:00 2001 From: Miguel Da Silva Date: Wed, 11 Sep 2024 21:30:20 +0200 Subject: [PATCH] Add fallback() to autocompletion, add comments shortcut, add require plugins --- lua/keymaps.lua | 15 --------------- lua/kickstart/plugins/autocompletion.lua | 20 ++++++++++++++------ lua/kickstart/plugins/comments.lua | 17 +++++++++++++++++ lua/lazy_plugins.lua | 1 + 4 files changed, 32 insertions(+), 21 deletions(-) create mode 100644 lua/kickstart/plugins/comments.lua diff --git a/lua/keymaps.lua b/lua/keymaps.lua index d30fd094..cbfe0922 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -57,18 +57,3 @@ vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagn -- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping -- or just use to exit terminal mode vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) - --- TIP: Disable arrow keys in normal mode --- vim.keymap.set('n', '', 'echo "Use h to move!!"') --- vim.keymap.set('n', '', 'echo "Use l to move!!"') --- vim.keymap.set('n', '', 'echo "Use k to move!!"') --- vim.keymap.set('n', '', 'echo "Use j to move!!"') - --- Keybinds to make split navigation easier. --- Use CTRL+ to switch between windows --- --- See `:help wincmd` for a list of all window commands --- vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) --- vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) --- vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) --- vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) diff --git a/lua/kickstart/plugins/autocompletion.lua b/lua/kickstart/plugins/autocompletion.lua index 78de22b6..cb7777b2 100644 --- a/lua/kickstart/plugins/autocompletion.lua +++ b/lua/kickstart/plugins/autocompletion.lua @@ -86,16 +86,24 @@ return { -- Autocompletion -- -- will move you to the right of each of the expansion locations. -- is similar, except moving you backwards. - [''] = cmp.mapping(function() - if luasnip.expand_or_locally_jumpable() then + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_locally_jumpable() then luasnip.expand_or_jump() + else + fallback() end - end, { 's' }), - [''] = cmp.mapping(function() - if luasnip.locally_jumpable(-1) then + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.locally_jumpable(-1) then luasnip.jump(-1) + else + fallback() end - end, { 's' }), + 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 diff --git a/lua/kickstart/plugins/comments.lua b/lua/kickstart/plugins/comments.lua new file mode 100644 index 00000000..3220e487 --- /dev/null +++ b/lua/kickstart/plugins/comments.lua @@ -0,0 +1,17 @@ +return { + 'numToStr/Comment.nvim', + + config = function() + require('Comment').setup { + opleader = { + ---Line-comment keymap + line = '/', + }, + toggler = { + line = '/', + }, + } + end, + + lazy = false, +} diff --git a/lua/lazy_plugins.lua b/lua/lazy_plugins.lua index e610893a..32c8eb3c 100644 --- a/lua/lazy_plugins.lua +++ b/lua/lazy_plugins.lua @@ -18,6 +18,7 @@ require('lazy').setup({ require 'kickstart.plugins.autopairs', require 'kickstart.plugins.harpoon', require 'kickstart.plugins.todo_comments', + require 'kickstart.plugins.comments', require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- require 'kickstart.plugins.debug',