Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added listcommands.lua #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))*
Expand Down
39 changes: 39 additions & 0 deletions plugins/listcommands.lua
Original file line number Diff line number Diff line change
@@ -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,
})