--- Personal lua config files for NeoVim. -- Last Changed: 2019-01-27 -- Author: Federico Igne -- 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, 'u'..trigger, { silent = true }) else map.i(keys, 'u'..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 'u' .. str .. '?<++[^>]*++>gn' end return checkpoint