From 30de6124ed44e34907d5b2967f82619c8b0b1499 Mon Sep 17 00:00:00 2001 From: Cassin01 Date: Wed, 15 Feb 2023 17:50:48 +0900 Subject: [PATCH] doc: add input --- Makefile | 2 +- doc/tags | 1 + doc/wf.txt | 14 ++++++++++---- lua/wf/mini.lua | 35 +++++++++++++++++++++++++++++++++++ plugin/wf.lua | 10 ---------- 5 files changed, 47 insertions(+), 15 deletions(-) create mode 100644 lua/wf/mini.lua delete mode 100644 plugin/wf.lua diff --git a/Makefile b/Makefile index b92d4b4..cf30160 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/doc/tags b/doc/tags index 419e355..9348df6 100644 --- a/doc/tags +++ b/doc/tags @@ -1 +1,2 @@ select() wf.txt /*select()* +which_key() wf.txt /*which_key()* diff --git a/doc/wf.txt b/doc/wf.txt index 46581dd..c6b27b6 100644 --- a/doc/wf.txt +++ b/doc/wf.txt @@ -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)` diff --git a/lua/wf/mini.lua b/lua/wf/mini.lua new file mode 100644 index 0000000..110efb5 --- /dev/null +++ b/lua/wf/mini.lua @@ -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 diff --git a/plugin/wf.lua b/plugin/wf.lua deleted file mode 100644 index f9d78ed..0000000 --- a/plugin/wf.lua +++ /dev/null @@ -1,10 +0,0 @@ --- You can use this loaded variable to enable conditional parts of your plugin. -if _G.WfLoaded then - return -end - -_G.WfLoaded = true - -vim.api.nvim_create_user_command("Wf", function() - require("wf").toggle() -end, {})