.config/nvim/lua/config/util.lua

changeset 1078
aa4c1aa529a5
child 1085
c2d11f022cf0
equal deleted inserted replaced
1077:5439ee582f9b 1078:aa4c1aa529a5
1 local M = {}
2
3 function M.calias(abbrev, expand)
4 vim.cmd.cnoreabbrev(
5 string.format(
6 [[<expr> %s (getcmdtype() == ":" && getcmdline() == "%s") ? "%s" : "%s"]],
7 abbrev,
8 abbrev,
9 expand,
10 abbrev
11 )
12 )
13 end
14
15 function M.autocmd(group, event, pattern, opts)
16 if type(opts) == "function" then
17 local func = opts
18 opts = { callback = function (_)
19 func()
20 end }
21 end
22
23 vim.api.nvim_create_autocmd(
24 event,
25 vim.tbl_extend("keep", opts, {
26 group = group,
27 pattern = pattern,
28 })
29 )
30 end
31
32 return M

mercurial