Added surround.nvim plugin and Ctrl + / keymap for commenting/uncommenting

This commit is contained in:
Kyren223
2024-06-30 21:39:42 +03:00
parent a38effa744
commit 9dcb3ba0d8
3 changed files with 23 additions and 2 deletions

View File

@@ -2,7 +2,6 @@ return {
'numToStr/Comment.nvim',
opts = {
padding = true,
sticky = true, -- keep cursor at it's position
ignore = nil,
toggler = { line = 'gcc', block = 'gbc' },
@@ -10,8 +9,20 @@ return {
extra = { above = 'gcO', below = 'gco', eol = 'gcA' },
mappings = {
basic = true, -- `gcc` `gbc` `gc[count]{motion}` `gb[count]{motion}`
basic = true, -- `gcc` `gbc` `gc[count]{motion}` `gb[count]{motion}`
extra = false, -- `gco`, `gcO`, `gcA`
},
},
config = function()
local api = require('Comment.api')
local esc = vim.api.nvim_replace_termcodes('<ESC>', true, false, true)
-- TODO: Stay in visual mode and keep the same selection even after commenting
local toggole_linewise_selection = function()
vim.api.nvim_feedkeys(esc, 'nx', false)
api.toggle.linewise(vim.fn.visualmode())
end
vim.keymap.set('n', '<C-_>', api.toggle.linewise.current, { noremap = true, silent = true })
vim.keymap.set('v', '<C-_>', toggole_linewise_selection, { noremap = true, silent = true })
end,
}