From 74c70a76cc430495b744616bb6195a5ee7e56d43 Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Sat, 27 Jan 2024 22:22:49 +0100 Subject: nvim: parens: Add extra useful keybindings --- nvim/nvim/lua/parens.lua | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/nvim/nvim/lua/parens.lua b/nvim/nvim/lua/parens.lua index d60a35c..da41695 100644 --- a/nvim/nvim/lua/parens.lua +++ b/nvim/nvim/lua/parens.lua @@ -130,6 +130,49 @@ parpar.setup { repeatable = false, mode = { "o", "v" }, }, + ["w"] = { + function() + -- place cursor and set mode to `insert` + paredit.cursor.place_cursor( + -- wrap element under cursor with `( ` and `)` + paredit.wrap.wrap_element_under_cursor("( ", ")"), + -- cursor placement opts + { placement = "inner_start", mode = "insert" } + ) + end, + "Wrap element insert head", + }, + + ["W"] = { + function() + paredit.cursor.place_cursor( + paredit.wrap.wrap_element_under_cursor("(", ")"), + { placement = "inner_end", mode = "insert" } + ) + end, + "Wrap element insert tail", + }, + + -- same as above but for enclosing form + ["i"] = { + function() + paredit.cursor.place_cursor( + paredit.wrap.wrap_enclosing_form_under_cursor("( ", ")"), + { placement = "inner_start", mode = "insert" } + ) + end, + "Wrap form insert head", + }, + + ["I"] = { + function() + paredit.cursor.place_cursor( + paredit.wrap.wrap_enclosing_form_under_cursor("(", ")"), + { placement = "inner_end", mode = "insert" } + ) + end, + "Wrap form insert tail", + } } } } -- cgit v1.2.3