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

doc: add input #20

Merged
merged 1 commit into from
Feb 15, 2023
Merged
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test-ci: deps test

# generates the documentation.
documentation:
nvim --headless --noplugin -u ./scripts/minimal_init.lua -c "lua require('mini.doc').generate()" -c "qa!"
nvim --headless --noplugin -u ./scripts/minimal_init.lua -c "lua require('mini.doc').generate(require(\"wf.mini\").setup)" -c "qa!"

# installs deps before running the documentation generation, useful for the CI.
documentation-ci: deps documentation
Expand Down
1 change: 1 addition & 0 deletions doc/tags
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
select() wf.txt /*select()*
which_key() wf.txt /*which_key()*
14 changes: 10 additions & 4 deletions doc/wf.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
==============================================================================
------------------------------------------------------------------------------
*which_key()*
`which_key`({opts})
Parameters~
{opts} `(optional)` `(table)`


==============================================================================
------------------------------------------------------------------------------
*select()*
`select`({items}, {opts}, {on_choice})
Define your wf setup.

Parameters~
{items} items
{the} options for wf
{on_choice} A callback that will be carried
{opts} the options for wf
{on_choice} a callback that will be carried
Usage~
`require("wf").select(items, opts, on_choice)`

Expand Down
35 changes: 35 additions & 0 deletions lua/wf/mini.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
local H = {}

-- Default documentation targets ----------------------------------------------
H.input = function()
-- Search in current and recursively in other directories for files with
-- 'lua' extension
local res = {}
for _, dir_glob in ipairs({ ".", "lua/**", "after/**", "colors/**", "lua/builtin/**" }) do
local files = vim.fn.globpath(dir_glob, "*.lua", false, true)

-- Use full paths
files = vim.tbl_map(function(x)
return vim.fn.fnamemodify(x, ":p")
end, files)

-- Put 'init.lua' first among files from same directory
table.sort(files, function(a, b)
if vim.fn.fnamemodify(a, ":h") == vim.fn.fnamemodify(b, ":h") then
if vim.fn.fnamemodify(a, ":t") == "init.lua" then
return true
end
if vim.fn.fnamemodify(b, ":t") == "init.lua" then
return false
end
end

return a < b
end)
table.insert(res, files)
end

return vim.tbl_flatten(res)
end

return H
10 changes: 0 additions & 10 deletions plugin/wf.lua

This file was deleted.