(pug ...) and (vlua ...) macros #6
rktjmp
started this conversation in
Show and tell
Replies: 1 comment 3 replies
-
@rktjmp, have you got any idea why this return in (fn autocmd! [events pattern command]
"Defines an autocommand"
(let [events (if (sequence? events) events [events])
events (-> (map ->str events)
(table.concat ","))
pattern (if (sequence? pattern) pattern [pattern])
pattern (-> (map ->str pattern)
(table.concat ","))]
(if (fn? command)
`(vim.cmd ,(string.format "autocmd %s %s call v:lua.%s()" events pattern (pug command)))
`(vim.cmd ,(string.format "autocmd %s %s %s" events pattern command))))) |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Here are two helper macros I use which make using "one off" functions more easier in keymaps.
(pug ...)
or "Put/Pin Unique Global" will accept any type or function and store it in Lua's global namespace (_G
) under a unique name. This let is you easily pin functions for use in other places such as keymaps. It returns the unique name.Usage:
(vlua ...)
is a convenience wrapper aroundpug
that returns av:lua...()
expression for use in keymaps:Usage:
Beta Was this translation helpful? Give feedback.
All reactions