2
3
镜像自地址 https://github.com/sammy-ette/Hilbish 已同步 2025-08-10 02:52:03 +00:00

docs: write docs for hilbish.completions

这个提交包含在:
TorchedSammy 2022-12-10 12:48:15 -04:00
父节点 2ee506f958
当前提交 65ff0c77ab
签署人:: sammyette
GPG 密钥 ID: 904FC49417B44DCD
共有 3 个文件被更改,包括 46 次插入1 次删除

查看文件

@ -189,11 +189,19 @@ func completionLoader(rtm *rt.Runtime) *rt.Table {
return mod return mod
} }
// left as a shim, might doc in the same way as hilbish functions // #interface completions
// handler(line, pos)
// The handler function is the callback for tab completion in Hilbish.
// You can check the completions doc for more info.
func completionHandler(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { func completionHandler(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
return c.Next(), nil return c.Next(), nil
} }
// #interface completions
// call(name, query, ctx, fields)
// Calls a completer function. This is mainly used to call
// a command completer, which will have a `name` in the form
// of `command.name`, example: `command.git`
func callLuaCompleter(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { func callLuaCompleter(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
if err := c.CheckNArgs(4); err != nil { if err := c.CheckNArgs(4); err != nil {
return nil, err return nil, err
@ -233,6 +241,9 @@ func callLuaCompleter(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
return c.PushingNext1(t.Runtime, completerReturn), nil return c.PushingNext1(t.Runtime, completerReturn), nil
} }
// #interface completions
// files(query, ctx, fields)
// Returns file completion candidates based on the provided query.
func luaFileComplete(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { func luaFileComplete(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
query, ctx, fds, err := getCompleteParams(t, c) query, ctx, fds, err := getCompleteParams(t, c)
if err != nil { if err != nil {
@ -249,6 +260,9 @@ func luaFileComplete(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
return c.PushingNext(t.Runtime, rt.TableValue(luaComps), rt.StringValue(pfx)), nil return c.PushingNext(t.Runtime, rt.TableValue(luaComps), rt.StringValue(pfx)), nil
} }
// #interface completions
// bins(query, ctx, fields)
// Returns binary/executale completion candidates based on the provided query.
func luaBinaryComplete(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { func luaBinaryComplete(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
query, ctx, fds, err := getCompleteParams(t, c) query, ctx, fds, err := getCompleteParams(t, c)
if err != nil { if err != nil {

查看文件

@ -7,3 +7,19 @@ layout: apidoc
## Introduction ## Introduction
The completions interface deals with tab completions. The completions interface deals with tab completions.
## Functions
### call(name, query, ctx, fields)
Calls a completer function. This is mainly used to call
a command completer, which will have a `name` in the form
of `command.name`, example: `command.git`
### handler(line, pos)
The handler function is the callback for tab completion in Hilbish.
You can check the completions doc for more info.
### bins(query, ctx, fields)
Returns binary/executale completion candidates based on the provided query.
### files(query, ctx, fields)
Returns file completion candidates based on the provided query.

查看文件

@ -7,6 +7,15 @@ local hilbish = {}
--- @param cmd string --- @param cmd string
function hilbish.aliases.add(alias, cmd) end function hilbish.aliases.add(alias, cmd) end
--- Calls a completer function. This is mainly used to call
--- a command completer, which will have a `name` in the form
--- of `command.name`, example: `command.git`
function hilbish.completions.call(name, query, ctx, fields) end
--- The handler function is the callback for tab completion in Hilbish.
--- You can check the completions doc for more info.
function hilbish.completions.handler(line, pos) end
--- Sets an alias of `cmd` to `orig` --- Sets an alias of `cmd` to `orig`
--- @param cmd string --- @param cmd string
--- @param orig string --- @param orig string
@ -113,6 +122,12 @@ function hilbish.timeout(cb, time) end
--- @param binName string --- @param binName string
function hilbish.which(name) end function hilbish.which(name) end
--- Returns binary/executale completion candidates based on the provided query.
function hilbish.completions.bins(query, ctx, fields) end
--- Returns file completion candidates based on the provided query.
function hilbish.completions.files(query, ctx, fields) end
--- Stops a timer. --- Stops a timer.
function hilbish.timers:stop() end function hilbish.timers:stop() end