36 lines
1.9 KiB
Nix
36 lines
1.9 KiB
Nix
{ nix2lua }:
|
|
|
|
with nix2lua.lib;
|
|
{
|
|
g = varName: expr: set "vim.g.${varName}" expr;
|
|
fn.isdirectory = file: call1 "vim.fn.isdirectory" (var file);
|
|
|
|
cmd' = expr: call1 "vim.cmd" expr;
|
|
cmd.cd = file: call1 "vim.cmd.cd" (var file);
|
|
|
|
keymap.set = { mode, bind, command, opts ? { } }:
|
|
call "vim.keymap.set" [ mode bind command opts ];
|
|
|
|
/*
|
|
Parameters:
|
|
- {event} (string|array) Event(s) that will trigger the handler (callback or command).
|
|
- {opts} Options dict:
|
|
- group (string|integer) optional: autocommand group name or id to match against.
|
|
- pattern (string|array) optional: pattern(s) to match literally autocmd-pattern.
|
|
- buffer (integer) optional: buffer number for buffer-local autocommands autocmd-buflocal. Cannot be used with {pattern}.
|
|
- desc (string) optional: description (for documentation and troubleshooting).
|
|
- callback (function|string) optional: Lua function (or Vimscript function name, if string) called when the event(s) is triggered. Lua callback can return a truthy value (not false or nil) to delete the autocommand. Receives a table argument with these keys:
|
|
- id: (number) autocommand id
|
|
- event: (string) name of the triggered event autocmd-events
|
|
- group: (number|nil) autocommand group id, if any
|
|
- match: (string) expanded value of <amatch>
|
|
- buf: (number) expanded value of <abuf>
|
|
- file: (string) expanded value of <afile>
|
|
- data: (any) arbitrary data passed from nvim_exec_autocmds()
|
|
- command (string) optional: Vim command to execute on event. Cannot be used with {callback}
|
|
- once (boolean) optional: defaults to false. Run the autocommand only once autocmd-once.
|
|
- nested (boolean) optional: defaults to false. Run nested autocommands autocmd-nested.
|
|
*/
|
|
api.nvim_create_autocmd = event: opts:
|
|
call "vim.api.nvim_create_autocmd" [ event opts ];
|
|
}
|