From 5e4b015307a78ed2f018fc672c897e1aeabe32c6 Mon Sep 17 00:00:00 2001 From: matthias314 Date: Mon, 23 Dec 2024 12:57:54 -0500 Subject: [PATCH] added documentation --- runtime/help/plugins.md | 4 ++-- runtime/plugins/autoclose/autoclose.lua | 7 +++++-- runtime/plugins/autoclose/help/autoclose.md | 13 +++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 runtime/plugins/autoclose/help/autoclose.md diff --git a/runtime/help/plugins.md b/runtime/help/plugins.md index fbab646943..ae200d5b29 100644 --- a/runtime/help/plugins.md +++ b/runtime/help/plugins.md @@ -486,8 +486,8 @@ The following plugins come pre-installed with micro: directory, the diff gutter will show changes with respect to the most recent Git commit rather than the diff since opening the file. -See `> help linter`, `> help comment`, and `> help status` for additional -documentation specific to those plugins. +See `> help autoclose`, `> help linter`, `> help comment`, and `> help status` +for additional documentation specific to those plugins. These are good examples for many use-cases if you are looking to write your own plugins. diff --git a/runtime/plugins/autoclose/autoclose.lua b/runtime/plugins/autoclose/autoclose.lua index 5670b77ec8..f2d6c31471 100644 --- a/runtime/plugins/autoclose/autoclose.lua +++ b/runtime/plugins/autoclose/autoclose.lua @@ -4,8 +4,11 @@ local config = import("micro/config") local uutil = import("micro/util") local utf8 = import("utf8") -config.RegisterCommonOption("autoclose", "pairs", {"\"\"", "''", "``", "()", "{}", "[]"}) -config.RegisterCommonOption("autoclose", "newlinePairs", {"()", "{}", "[]"}) +function preinit() + config.RegisterCommonOption("autoclose", "pairs", {"\"\"", "''", "``", "()", "{}", "[]"}) + config.RegisterCommonOption("autoclose", "newlinePairs", {"()", "{}", "[]"}) + config.AddRuntimeFile("autoclose", config.RTHelp, "help/autoclose.md") +end function charAt(str, i) -- lua indexing is one off from go diff --git a/runtime/plugins/autoclose/help/autoclose.md b/runtime/plugins/autoclose/help/autoclose.md new file mode 100644 index 0000000000..25d56c44ed --- /dev/null +++ b/runtime/plugins/autoclose/help/autoclose.md @@ -0,0 +1,13 @@ +# Autoclose + +The autoclose plugin automatically closes brackets, quotes and the like, +and it can add indentation between such symbols. The plugin can be configured +on a per-buffer basis via the following options: + +- `autoclose.pairs`: When the first rune in a pair is entered, autoclose will + add the second automatically. Moreover, when the first rune is deleted while + the cursor is on the second, then this second rune is also deleted. + The default value is ```{"\"\"", "''", "``", "()", "{}", "[]"}```. +- `autoclose.newlinePairs`: When `Enter` is pressed between such a pair, + autoclose will put the closing rune on a separate line and add indentation. + The default value is `{"()", "{}", "[]"}`.