blob: 9649c903651c6297c1d83e7eacaf264bc9fc45f1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
--- Personal lua config files for NeoVim.
-- Last Changed: 2019-01-27
-- Author: Federico Igne <git@federicoigne.com>
-- License: This file is placed in the public domain.
local map = require 'dyamon.util.map'
local checkpoint = { }
--- Define insert mapping for parentesis with checkpoints
--
-- @note this uses an experimental feature of vim-surround.
--
-- @param keys key sequence to trigger the mapping.
-- @param trigger vim-surround snippet trigger.
-- @param bufnr buffer for which the mapping is defined (nil for global mappings).
function checkpoint.surround(keys, trigger, bufnr)
if bufnr then
map.b.i(bufnr, keys, '<c-g>u<c-s>'..trigger, { silent = true })
else
map.i(keys, '<c-g>u<c-s>'..trigger, { silent = true })
end
end
--- Add boilerplate to insert mode snippet
--
-- @param str snippet of code/text
-- @return snippet wrapped in additional common insert mode commands
function checkpoint.snippet(str)
return '<c-g>u' .. str .. '<esc>?<++[^>]*++><cr>gn'
end
return checkpoint
|