diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2024-01-28 16:40:20 +0100 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2024-01-28 16:40:20 +0100 |
commit | 873a8bc28588c6605eeb51c63a4de4fb4da765ff (patch) | |
tree | 5c24f7f5d42cc9fd0f954f66d40c5e10b670e1e5 /nvim | |
parent | 6c20ef3d3bf884a30f138be47d08d352236ceeff (diff) |
nvim: parens: add wrapping with quotes and clean
Diffstat (limited to 'nvim')
-rw-r--r-- | nvim/nvim/lua/parens.lua | 51 |
1 files changed, 47 insertions, 4 deletions
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 ["<localleader>w"] = { function() -- place cursor and set mode to `insert` @@ -171,6 +169,51 @@ paredit.setup({ ) end, "Wrap form insert tail", + }, + + -- Wrap quotes + ["<localleader>\"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", + }, + + ["<localleader>\"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 + ["<localleader>\"i"] = { + function() + paredit.cursor.place_cursor( + paredit.wrap.wrap_element_under_cursor("\" ", "\""), + { placement = "inner_start", mode = "insert" } + ) + end, + "Wrap form insert head", + }, + + ["<localleader>\"I"] = { + function() + paredit.cursor.place_cursor( + paredit.wrap.wrap_element_under_cursor("\"", "\""), + { placement = "inner_end", mode = "insert" } + ) + end, + "Wrap form insert tail", } } }) |