From 130e629434c4d87a18a886e5f98fa83dd897f742 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Thu, 21 Apr 2016 10:00:11 +0200 Subject: vis-lua: add vis:command_register to map a Lua function to a :-command The following registers `:foo` as a command which prints a few things to stdout: vis:command_register("foo", function(argv, force, win, cursor, range) for i,arg in ipairs(argv) do print(i..": "..arg) end print("was command forced with ! "..(force and "yes" or "no")) print(win.file.name) print(cursor.pos) print(range ~= nil and ('['..range.start..', '..range.finish..']') or "invalid range") return true; end) --- README.md | 1 + 1 file changed, 1 insertion(+) (limited to 'README.md') diff --git a/README.md b/README.md index 96bbec5..1abd8b2 100644 --- a/README.md +++ b/README.md @@ -594,6 +594,7 @@ At this time there exists no API stability guarantees. - `textobject(id)` select/execute a text object - `motion_register(function)` register a Lua function as a motion, returns associated `id` or `-1` - `motion(id)` select/execute a motion + - `command_register(name, function(argv, force, win, cursor, range))` hook up a Lua function to `:name` command - `map(mode, key, function)` map a Lua function to `key` in `mode` - `file` - `content(pos, len)` -- cgit v1.2.3