From 3de440338d533d911f2a5743b31e6d6e3b280d90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolai=20S=C3=B8borg?= Date: Sun, 11 Dec 2016 01:24:49 +0100 Subject: [PATCH] Update plugin documentation --- runtime/help/plugins.md | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/runtime/help/plugins.md b/runtime/help/plugins.md index 04429dfa..b79b4149 100644 --- a/runtime/help/plugins.md +++ b/runtime/help/plugins.md @@ -51,6 +51,12 @@ as Go's GOOS variable, so `darwin`, `windows`, `linux`, `freebsd`...) * `messenger`: lets you send messages to the user or create prompts +* `NewBuffer(text, path string) *Buffer`: creates a new buffer from a given reader with a given path + +* `GetLeadingWhitespace() bool`: returns the leading whitespace of the given string + +* `IsWordChar(str string) bool`: returns whether or not the string is a 'word character' + * `RuneStr(r rune) string`: returns a string containing the given rune * `Loc(x, y int) Loc`: returns a new `Loc` struct @@ -88,9 +94,11 @@ as Go's GOOS variable, so `darwin`, `windows`, `linux`, `freebsd`...) `waitToClose` bool only applies if `interactive` is true and means that it should wait before returning to the editor. -* `ToCharPos(loc Loc, buf *Buffer) int`: returns the character position of a given x, y location. +* `ToCharPos(loc Loc, buf *Buffer) int`: returns the character position of a given x, y location -* `ByteOffset(loc Loc, buf *Buffer) int`: exactly like `ToCharPos` except it it counts bytes instead of runes. +* `Reload`: (Re)load everything + +* `ByteOffset(loc Loc, buf *Buffer) int`: exactly like `ToCharPos` except it it counts bytes instead of runes * `JobSpawn(cmdName string, cmdArgs []string, onStdout, onStderr, onExit string, userargs ...string)`: Starts running the given process in the background. `onStdout` `onStderr` and `onExit` @@ -130,8 +138,8 @@ If you want a standard prompt, just use `messenger.Prompt(prompt, "", 0)` # Adding help files, syntax files, or colorschemes in your plugin You can use the `AddRuntimeFile(name, type, path string)` function to add various kinds of -files to your plugin. For example, if you'd like to add a help topic and to your plugin -called `test`, you would create the `test.md` file for example, and runt the function: +files to your plugin. For example, if you'd like to add a help topic to your plugin +called `test`, you would create a `test.md` file, and call the function: ```lua AddRuntimeFile("test", "help", "test.md") @@ -139,6 +147,8 @@ AddRuntimeFile("test", "help", "test.md") Use `AddRuntimeFilesFromDirectory(name, type, dir, pattern)` to add a number of files to the runtime. +To read the content of a runtime file use `ReadRuntimeFile(fileType, name string)` +or `ListRuntimeFiles(fileType string)` for all runtime files. # Autocomplete command arguments