From 873a8bc28588c6605eeb51c63a4de4fb4da765ff Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Sun, 28 Jan 2024 16:40:20 +0100 Subject: nvim: parens: add wrapping with quotes and clean --- nvim/nvim/lua/parens.lua | 51 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) (limited to 'nvim') diff --git a/nvim/nvim/lua/parens.lua b/nvim/nvim/lua/parens.lua index 4e88750..fe3072f 100644 --- a/nvim/nvim/lua/parens.lua +++ b/nvim/nvim/lua/parens.lua @@ -3,15 +3,12 @@ local parpar = require "parpar" local scheme = require "nvim-paredit-scheme" paredit.setup({ - extensions = { - scheme = require "nvim-paredit-scheme" - }, -- should plugin use default keybindings? (default = true) use_default_keys = true, -- sometimes user wants to restrict plugin to certain file types only -- defaults to all supported file types including custom lang -- extensions (see next section) - filetypes = { "scheme", "clojure", "guix", "fennel", "lisp", "guile" }, + filetypes = { "scheme", "clojure", "fennel"}, -- This controls where the cursor is placed when performing slurp/barf operations -- @@ -129,6 +126,7 @@ paredit.setup({ repeatable = false, mode = { "o", "v" }, }, + -- Wrap parenthesis ["w"] = { function() -- place cursor and set mode to `insert` @@ -171,6 +169,51 @@ paredit.setup({ ) end, "Wrap form insert tail", + }, + + -- Wrap quotes + ["\"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_element_under_cursor("\" ", "\""), + { placement = "inner_start", mode = "insert" } + ) + end, + "Wrap form insert head", + }, + + ["\"I"] = { + function() + paredit.cursor.place_cursor( + paredit.wrap.wrap_element_under_cursor("\"", "\""), + { placement = "inner_end", mode = "insert" } + ) + end, + "Wrap form insert tail", } } }) -- cgit v1.2.3