diff --git a/README.md b/README.md index 4ca8550e..98ce1df0 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ Plugin | Description [`linecopypaste`](plugins/linecopypaste.lua?raw=1) | Copy, cut and paste the current line when nothing is selected [`lineguide`](plugins/lineguide.lua?raw=1) | Displays a line-guide at the line limit offset *([screenshot](https://user-images.githubusercontent.com/3920290/81476159-2cf70000-9208-11ea-928b-9dae3884c477.png))* [`linter`](https://github.com/drmargarido/linters)* | Linters for multiple languages +[`listcommands`](plugins/listcommands.lua?raw=1) | Dump defined commands to a new document respecting current context [`macmodkeys`](plugins/macmodkeys.lua?raw=1) | Remaps mac modkeys `command/option` to `ctrl/alt` [`markers`](plugins/markers.lua?raw=1) | Add markers to docs and jump between them quickly *([screenshot](https://user-images.githubusercontent.com/3920290/82252149-5faaa200-9946-11ea-9199-bea2efb7ee23.png))* [`motiontrail`](plugins/motiontrail.lua?raw=1) | Adds a motion-trail to the caret *([screenshot](https://user-images.githubusercontent.com/3920290/83256814-085ccb00-a1ab-11ea-9e35-e6633cbed1a9.gif))* diff --git a/plugins/listcommands.lua b/plugins/listcommands.lua new file mode 100644 index 00000000..71dc395b --- /dev/null +++ b/plugins/listcommands.lua @@ -0,0 +1,39 @@ +--[[ + listcommands.lua + creates a new document and lists commands available to current context + version: 20200627_151604 + originally by SwissalpS + + The list will be different if, for example log view is active opposed + to a document. + If sort plugin is installed, the list will also be sorted. +--]] +local core = require "core" +local command = require "core.command" + +local function pasteAndSort(sOut) + core.root_view:open_doc(core.open_doc()) + core.active_view.doc:text_input(sOut) + if command.map['sort:sort'] then + command.perform('doc:select-all') + command.perform('sort:sort') + command.perform('doc:select-none') + end +end + +local function listCommands() + + local tCommands = command.get_all_valid() + local sOut = '' + for _, sCommand in ipairs(tCommands) do + sOut = sOut .. sCommand .. '\n' + end + + pasteAndSort(sOut) + +end + +command.add(nil, { + ["listcommands:listcommands"] = listCommands, +}) +