diff --git a/book/lua/module/example.lua b/book/lua/module/example.lua new file mode 100644 index 0000000..67f2cc9 --- /dev/null +++ b/book/lua/module/example.lua @@ -0,0 +1,56 @@ +local word = require("word") + +local mod, config, util = word.mod, word.config, word.util + +local M = mod.create("user.example", { + --- @brief submodules + --- child directories containing + --- modules to load in tandem, relative + --- to this (parent) module. + --- "subexample", + --- "pre_example", + --- ... +}) + +M.setup = function() + return { + requires = { + ---@brief required modules + --- modules from builtin or custom + --- modules that can be loaded in (same as + --- if calling `require 'module'`) as a dependency + --- for the module. + --- "ui.popup", + --- "edit.link", + --- "integration.treesitter", + --- ... + }, + loaded = true, + } +end + +---@class (exact) example.Config +M.config.public = { + --- @brief module config + --- the public facing config for this module that can be + --- set by the user from its default values here. + --- ... +} + +---@class example.Data +M.data = { + --- @brief module data + --- the home of the module's internal data and methods + --- TODO: split up concerns + --- ... +} + +M.load = function() + --- @brief module load + --- a set of functions to run whenever the + --- module is fist loaded upon startup. + --- TODO: maybe just merge in with setup() + --- ... +end + +return M diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index 96afea6..35c6672 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -26,12 +26,17 @@ Welcome -- to the `word.lua` book. I hope this helps! - [Keymaps](./extend/keymaps.md) - [Autocmds](./extend/autocmd.md) +- [Modules](./modules.md) + + - [Introduction](./modules/intro.md) + - [Customizing](./customizing.md) - [Themes](./customizing/themes.md) - [Highlights](./customizing/highlights.md) - [Export](./export.md) + - [Frameworks](./publish/frameworks.md) - [org](./export/org.md) @@ -42,6 +47,7 @@ Welcome -- to the `word.lua` book. I hope this helps! - [Digital garden](./publish/digital_garden.md) - [Plans](./plans/index.md) + - [Near](./plans/near.md) - [Far](./plans/far.md) diff --git a/book/src/modules.md b/book/src/modules.md new file mode 100644 index 0000000..a032180 --- /dev/null +++ b/book/src/modules.md @@ -0,0 +1,63 @@ +# Modules + +## Example custom module + +```lua +local word = require("word") + +local mod, config, util = word.mod, word.config, word.util + +local M = mod.create("user.example", { + --- @brief submodules + --- child directories containing + --- modules to load in tandem, relative + --- to this (parent) module. + --- "subexample", + --- "pre_example", + --- ... +}) + +M.setup = function() + return { + requires = { + ---@brief required modules + --- modules from builtin or custom + --- modules that can be loaded in (same as + --- if calling `require 'module'`) as a dependency + --- for the module. + --- "ui.popup", + --- "edit.link", + --- "integration.treesitter", + --- ... + }, + loaded = true, + } +end + +---@class (exact) example.Config +M.config.public = { + --- @brief module config + --- the public facing config for this module that can be + --- set by the user from its default values here. + --- ... +} + +---@class example.Data +M.data = { + --- @brief module data + --- the home of the module's internal data and methods + --- TODO: split up concerns + --- ... +} + +M.load = function() + --- @brief module load + --- a set of functions to run whenever the + --- module is fist loaded upon startup. + --- TODO: maybe just merge in with setup() + --- ... +end + +return M + +``` diff --git a/book/src/modules/intro.md b/book/src/modules/intro.md new file mode 100644 index 0000000..e69de29 diff --git a/lua/word/mod/edit/link/init.lua b/lua/word/mod/edit/link/init.lua index 5ff3606..a27b64c 100644 --- a/lua/word/mod/edit/link/init.lua +++ b/lua/word/mod/edit/link/init.lua @@ -473,7 +473,7 @@ link from the word under the cursor or a visual selection (if there is one). M.load = function() mod.await("cmd", function(cmd) cmd.add_commands_from_table({ - preview = { + link = { name = "link", subcommands = { update = { diff --git a/test/config/init.lua b/test/config/init.lua deleted file mode 100644 index 6130feb..0000000 --- a/test/config/init.lua +++ /dev/null @@ -1,24 +0,0 @@ -vim.cmd [[ - set rtp+=./ - set rtp+=~/.local/share/nvim/lazy/nvim-nio - set rtp+=~/.local/share/nvim/lazy/nvim-treesitter - set rtp+=~/.local/share/nvim/lazy/pathlib.nvim - set rtp+=~/.local/share/nvim/lazy/nui.nvim - set rtp+=~/.local/share/nvim/lazy/plenary.nvim -]] - -local word = require("word") -word.setup( - { - mods = { - config = {}, - workspace = { - config = { - workspaces = { - book = "./book/src" - } - } - }, - } - } -)