summaryrefslogtreecommitdiff
path: root/.config/nvim
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim')
-rw-r--r--.config/nvim/lazy-lock.json1
-rw-r--r--.config/nvim/lua/plugins/comment.lua15
-rw-r--r--.config/nvim/lua/plugins/surround.lua9
3 files changed, 23 insertions, 2 deletions
diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json
index 789d9f6..3900861 100644
--- a/.config/nvim/lazy-lock.json
+++ b/.config/nvim/lazy-lock.json
@@ -19,6 +19,7 @@
"nvim-autopairs": { "branch": "master", "commit": "c15de7e7981f1111642e7e53799e1211d4606cb9" },
"nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" },
"nvim-lspconfig": { "branch": "master", "commit": "bd7c76375a511994c9ca8d69441f134dc10ae3bd" },
+ "nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" },
"nvim-treesitter": { "branch": "master", "commit": "2e9c346aefda680bd14ebf40a50c2897fd637bc2" },
"nvim-web-devicons": { "branch": "master", "commit": "c0cfc1738361b5da1cd0a962dd6f774cc444f856" },
"plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
diff --git a/.config/nvim/lua/plugins/comment.lua b/.config/nvim/lua/plugins/comment.lua
index d41bad4..6e9a55e 100644
--- a/.config/nvim/lua/plugins/comment.lua
+++ b/.config/nvim/lua/plugins/comment.lua
@@ -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,
}
diff --git a/.config/nvim/lua/plugins/surround.lua b/.config/nvim/lua/plugins/surround.lua
new file mode 100644
index 0000000..2b8d3e0
--- /dev/null
+++ b/.config/nvim/lua/plugins/surround.lua
@@ -0,0 +1,9 @@
+return {
+ 'kylechui/nvim-surround',
+ version = '*',
+ event = 'VeryLazy',
+ config = function()
+ require('nvim-surround').setup({})
+ -- TODO: Add a way to not have to press S while in visual mode
+ end,
+}