diff --git a/.gitignore b/.gitignore index ca6bcbd..6bf9216 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,6 @@ **ext/ext **.ropeproject/ **notes/ -**note/ /luarocks /lua_modules /.luarocks diff --git a/Justfile b/Justfile index ee20499..6808e17 100644 --- a/Justfile +++ b/Justfile @@ -3,19 +3,19 @@ # nvimf="--headless -u ./test/config/minit.lua --noplugin -c ''" w: - ./scripts/bin/word + ./scripts/bin/down wl: - ./scripts/bin/wordls + ./scripts/bin/downls lnw: - ln -s ./scripts/bin/word ./word + ln -s ./scripts/bin/down ./down lnwl: - ln -s ./scripts/bin/word-lsp ./word-lsp + ln -s ./scripts/bin/down-lsp ./down-lsp iw: lnw - cp -r ./scripts/bin/word ${HOME}/.local/bin/ + cp -r ./scripts/bin/down ${HOME}/.local/bin/ iwl: lnwl - cp -r ./scripts/bin/word-lsp ${HOME}/.local/bin/ + cp -r ./scripts/bin/down-lsp ${HOME}/.local/bin/ i: iw iwl diff --git a/README.md b/README.md index 2358dbd..db88042 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,18 @@ -# word.lua - the _familiar_, organized future for neovim +# down.lua - the _familiar_, organized future for neovim ![Neovim](https://img.shields.io/badge/Neovim%200.10+-brightgreen?style=for-the-badge) ![License](https://img.shields.io/badge/license-GPL%20v3-brightgreen?style=for-the-badge) -![LuaRocks](https://img.shields.io/luarocks/v/clpi/word.lua) +![LuaRocks](https://img.shields.io/luarocks/v/clpi/down.lua) --- > [!Important] > -> `word.lua` is **BEGINNING DEVELOPMENT** +> `down.lua` is **BEGINNING DEVELOPMENT** -- [word - the _familiar_, organized future for neovim](#word-the-familiar-organized-future-for-neovim) +- [down - the _familiar_, organized future for neovim](#down-the-familiar-organized-future-for-neovim) - [Introduction](#introduction) - [Requirements](#requirements) - [Quickstart](#quickstart) @@ -25,9 +25,9 @@ ## Introduction -- `word.lua` is a [neovim](#) plugin intended to bring the extensibility of [org-mode](#) or [neorg](github.com/nvim-neorg/neorg) with the **comfort** of [markdown](#). +- `down.lua` is a [neovim](#) plugin intended to bring the extensibility of [org-mode](#) or [neorg](github.com/nvim-neorg/neorg) with the **comfort** of [markdown](#). -- In its [current state](#), `word.lua` is in the beginning stages of development, currently functionining as a markdown-based version of [neorg](#), with many planned features to come +- In its [current state](#), `down.lua` is in the beginning stages of development, currently functionining as a markdown-based version of [neorg](#), with many planned features to come - we want to be able to take notes like developers, without leaving behind all the ecosystem benefits of markdown. @@ -37,7 +37,7 @@ > [!Note] > -> `word.lua` must have at least [neovim 0.10+](https://neovim.io) +> `down.lua` must have at least [neovim 0.10+](https://neovim.io) ## Quickstart @@ -48,18 +48,18 @@ ```lua { - "clpi/word.lua", + "clpi/down.lua", lazy = false, version = "*" branch = "master", config = function(_, opts) - require("word").setup({ + require("down").setup({ mod = { config = {}, workspace = { config = { workspaces = { - default = "~/word", + default = "~/down", notes = "~/notes" } } @@ -96,9 +96,9 @@ Plug "nvim-treesitter/treesitter.nvim" Plug "nvim-lua/plenary.nvim", Plug "MunifTanjim/nui.nvim", Plug "pysan3/pathlib.nvim" -Plug "clpi/word.lua", { +Plug "clpi/down.lua", { \ "branch" : "master", - \ "do" : ':lua require([[word]]).setup({ + \ "do" : ':lua require([[down]]).setup({ \ mod = { \ config = {}, \ workspace = { @@ -130,7 +130,7 @@ Plugin "pysan3/pathlib.nvim" Plugin 'nvim-telescope/telescope.nvim' Plugin "nvim-lua/plenary.nvim", Plugin "MunifTanjim/nui.nvim", -Plugin 'clpi/word.lua' +Plugin 'clpi/down.lua' ``` @@ -152,7 +152,7 @@ call dein#add("nvim-lua/plenary.nvim") call dein#add("MunifTanjim/nui.nvim") call dein#add('pysan3/pathlib.nvim') call dein#add('nvim-telescope/telescope.nvim') -call dein#add('clpi/word.lua') +call dein#add('clpi/down.lua') ``` @@ -171,7 +171,7 @@ call dein#add('clpi/word.lua') ```lua use { - "clp/word.lua", + "clp/down.lua", requires = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim", @@ -181,7 +181,7 @@ use { tag = "*", branch = 'master', config = function() - require("word").setup({ + require("down").setup({ mod = { config = {}, workspace = { @@ -213,7 +213,7 @@ use { ```lua { - "clp/word.lua", + "clp/down.lua", } ``` @@ -243,7 +243,7 @@ use { -- Setup the initial config -- with workspace 'home' at ~/home -- and make it default -require("word").setup({ ---@type word.mod.Config +require("down").setup({ ---@type down.mod.Config mod = { config = {}, workspace = { @@ -287,7 +287,7 @@ require("word").setup({ ---@type word.mod.Config ## Credits -`word.lua` is a project by [clpi](github.com/clpi) and is licensed under the [MIT](./LICENSE) license. For information about **contributing**, please consult the [CONTRIBUTING.md](./CONTRIBUTING.md) file. +`down.lua` is a project by [clpi](github.com/clpi) and is licensed under the [MIT](./LICENSE) license. For information about **contributing**, please consult the [CONTRIBUTING.md](./CONTRIBUTING.md) file. special thanks goes to [nvim-neorg/neorg](https://github.com/nvim-neorg/neorg) for providing the inspiration and basis of this project. @@ -295,10 +295,10 @@ special thanks goes to [nvim-neorg/neorg](https://github.com/nvim-neorg/neorg) f thank you and keep updated! -- [The `word.lua` book](https://word.cli.st) -- [The `word.lua` wiki](https://github.com/clpi/word.lua/wiki) -- [`word.lua` on luarocks](https://luarocks.org/inits/clpi/word.lua) -- [`word.lua` on dotfyle](https://dotfyle.com/plugins/clpi/word.lua) +- [The `down.lua` book](https://down.cli.st) +- [The `down.lua` wiki](https://github.com/clpi/down.lua/wiki) +- [`down.lua` on luarocks](https://luarocks.org/inits/clpi/down.lua) +- [`down.lua` on dotfyle](https://dotfyle.com/plugins/clpi/down.lua)

(back to top)

@@ -306,6 +306,6 @@ thank you and keep updated! ```lua ----@type word.mod.Config +---@type down.mod.Config ``` diff --git a/TODO.md b/TODO.md index ef19911..23fbab1 100644 --- a/TODO.md +++ b/TODO.md @@ -4,9 +4,9 @@ - [ ] Fix the calendar UI element when pulled up with notes or "calendar" command - [ ] Fix and conform types across the board -- [ ] Remove `wordinc` and `worddec` commands -- [ ] Make word autocmd markdown load only when in recognized workspace -- [ ] Make the following commands only load on word workspace markdown autocmd: +- [ ] Remove `downinc` and `downdec` commands +- [ ] Make down autocmd markdown load only when in recognized workspace +- [ ] Make the following commands only load on down workspace markdown autocmd: - [ ] `link` - [ ] `sync` - [ ] `rename` @@ -16,7 +16,7 @@ - [ ] `tag` - [ ] Consider not having `config` be a quasi-necessary default loader for all other builtin modules, instead load them by default and allow some way for this behavior to not be invoked. - [ ] (easy) Change schema of modules so config is under module's schema itself, - instead of having it under `[module].config` - [ ] If necessary, then make inter-module config accessibility under `[module].config` instead of `module.config.public` + instead of having it under `[module].config` - [ ] If necessary, then make inter-module config accessibility under `[module].config` instead of `module.config` - [ ] (easy) Change config to be under - [ ] (easy) Consider removing `[module].load` `[module].maps` `[module].opts` `[module].cmds` and merge all into `[module].setup` due to redundancy - [ ] (easy) Remove all lingering instances of `[module].data.data` and merge into `[module].data` @@ -181,4 +181,4 @@ require("nvim-treesitter.configs").setup({ - [ ] `...` - [ ] Scope indentation? -- [ ] `.wd` [word] syntax support/hl +- [ ] `.wd` [down] syntax support/hl diff --git a/book/book.toml b/book/book.toml index 2e0d03f..c33a9bd 100644 --- a/book/book.toml +++ b/book/book.toml @@ -1,6 +1,6 @@ [book] -title = "The word.lua book" -description = "Goes over the word.lua extension for neovim" +title = "The down.lua book" +description = "Goes over the down.lua extension for neovim" authors = ["Chris Pecunies"] language = "en" multilingual = false @@ -27,8 +27,8 @@ copy-fonts = true # additional-js = "book.js" smart-punctuation = true no-section-label = false -git-repository-url = 'github.com/clpi/word.lua' -edit-url-template = "https://github.com/clpi/word.lua/edit/master/book/{path}" +git-repository-url = 'github.com/clpi/down.lua' +edit-url-template = "https://github.com/clpi/down.lua/edit/master/book/{path}" git-repository-icon = "fa-github" input-404 = "404.md" diff --git a/book/lua/module/example.lua b/book/lua/module/example.lua index 67f2cc9..b98ced1 100644 --- a/book/lua/module/example.lua +++ b/book/lua/module/example.lua @@ -1,6 +1,6 @@ -local word = require("word") +local down = require("down") -local mod, config, util = word.mod, word.config, word.util +local mod, config, util = down.mod, down.config, down.util local M = mod.create("user.example", { --- @brief submodules @@ -30,7 +30,7 @@ M.setup = function() end ---@class (exact) example.Config -M.config.public = { +M.config = { --- @brief module config --- the public facing config for this module that can be --- set by the user from its default values here. diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index 7eebe11..de6434f 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -1,6 +1,6 @@ # Summary -Welcome -- to the `word.lua` book. I hope this helps! +Welcome -- to the `down.lua` book. I hope this helps! - [Intro](./intro.md) - [Philosophy](./philosophy.md) diff --git a/book/src/index.md b/book/src/index.md index 00a2f50..97fba81 100644 --- a/book/src/index.md +++ b/book/src/index.md @@ -1,4 +1,4 @@ -# `word.lua` Book Index +# `down.lua` Book Index ## About diff --git a/book/src/intro.md b/book/src/intro.md index a609523..355e421 100644 --- a/book/src/intro.md +++ b/book/src/intro.md @@ -1,8 +1,8 @@ -# word.lua +# down.lua ## Intro -`word.lua` is a simple ORM for Lua. It is designed to be simple to use and +`down.lua` is a simple ORM for Lua. It is designed to be simple to use and ## Is it for you? @@ -14,7 +14,7 @@ ## Other resources -- [GitHub](https://github.com/clpi/word.lua) -- [Sourcehut](https://git.sr.ht/~clpi/word.lua) -- [Luarocks](https://luarocks.org/modules/clpi/word.lua) -- [Dotfyle](https://dotfyle.com/plugins/clpi/word.lua) +- [GitHub](https://github.com/clpi/down.lua) +- [Sourcehut](https://git.sr.ht/~clpi/down.lua) +- [Luarocks](https://luarocks.org/modules/clpi/down.lua) +- [Dotfyle](https://dotfyle.com/plugins/clpi/down.lua) diff --git a/book/src/modules/example.md b/book/src/modules/example.md index 450b6a1..cbe17da 100644 --- a/book/src/modules/example.md +++ b/book/src/modules/example.md @@ -1,9 +1,9 @@ ## Example custom module ```lua -local word = require("word") +local down = require("down") -local mod, config, util = word.mod, word.config, word.util +local mod, config, util = down.mod, down.config, down.util local M = mod.create("user.example", { --- @brief submodules @@ -33,7 +33,7 @@ M.setup = function() end ---@class (exact) example.Config -M.config.public = { +M.config = { --- @brief module config --- the public facing config for this module that can be --- set by the user from its default values here. diff --git a/book/src/modules/index.md b/book/src/modules/index.md index c8a10a1..6a0b326 100644 --- a/book/src/modules/index.md +++ b/book/src/modules/index.md @@ -3,9 +3,9 @@ ## Example custom module ```lua -local word = require("word") +local down = require("down") -local mod, config, util = word.mod, word.config, word.util +local mod, config, util = down.mod, down.config, down.util local M = mod.create("user.example", { --- @brief submodules @@ -35,7 +35,7 @@ M.setup = function() end ---@class (exact) example.Config -M.config.public = { +M.config = { --- @brief module config --- the public facing config for this module that can be --- set by the user from its default values here. diff --git a/doc/word-hl.txt b/book/src/note/2024/12/15.md similarity index 100% rename from doc/word-hl.txt rename to book/src/note/2024/12/15.md diff --git a/doc/word-lsp.txt b/doc/down-hl.txt similarity index 100% rename from doc/word-lsp.txt rename to doc/down-hl.txt diff --git a/doc/word-ui.txt b/doc/down-lsp.txt similarity index 100% rename from doc/word-ui.txt rename to doc/down-lsp.txt diff --git a/doc/word.lua.txt b/doc/down-ui.txt similarity index 100% rename from doc/word.lua.txt rename to doc/down-ui.txt diff --git a/lua/word/mod/cmd/README.md b/doc/down.txt similarity index 100% rename from lua/word/mod/cmd/README.md rename to doc/down.txt diff --git a/word-scm-1.rockspec b/down-scm-1.rockspec similarity index 92% rename from word-scm-1.rockspec rename to down-scm-1.rockspec index 124fa19..7e090e1 100644 --- a/word-scm-1.rockspec +++ b/down-scm-1.rockspec @@ -26,7 +26,7 @@ rockspec_format = "3.0" version = MODREV .. SPECREV branch = "master" tag = "v0.1.1-alpha" -package_name = "word.lua" +package_name = "down.lua" github_url = "https://github.com/" .. maintainer .. "/" @@ -49,7 +49,7 @@ github_git_url = "git://github.com/" .. ".git" maintainer_url = "https://github.com/" .. maintainer_user maintainer_email = "clp@clp.is" -homepage = "https://word.cli.st" +homepage = "https://down.cli.st" maintainer = "Chris Pecunies <" .. maintainer_email .. ">" source = { @@ -111,9 +111,9 @@ build = { modules = {}, install = { bin = { - wordls = "scripts/bin/wordls", - word_lsp = "scripts/bin/word-lsp", - word = "scripts/bin/word", + downls = "scripts/bin/downls", + down_lsp = "scripts/bin/down-lsp", + down = "scripts/bin/down", }, }, copy_directories = { diff --git a/lua/word.lua b/lua/down.lua similarity index 63% rename from lua/word.lua rename to lua/down.lua index bb1d58e..06879ac 100644 --- a/lua/word.lua +++ b/lua/down.lua @@ -1,42 +1,42 @@ ---@author clpi ----@file word.lua 0.1.0 +---@file down.lua 0.1.0 ---@license MIT ----@package word.lua ----@mle "word" +---@package down.lua +---@mle "down" ---@version JIT ---@brief neovim note-taking plugin with the ---@brief comfort of mmarkdown and the power of org ---TODO: make variety of commands on autocmd load markdown only ----@class word.word +---@class down.down local W = { - cfg = require("word.config").config, - mod = require("word.mod"), - config = require("word.config"), - callbacks = require("word.util.event.callback"), - log = require("word.util.log"), - types = require("word.types"), - health = require("word.health"), - core = require("word.core"), + cfg = require("down.config").config, + mod = require("down.mod"), + config = require("down.config"), + callbacks = require("down.util.event.callback"), + log = require("down.util.log"), + types = require("down.types"), + health = require("down.health"), + core = require("down.core"), util = { - util = require("word.util"), - log = require("word.util.log"), - buf = require("word.util.buf"), - -- cb = require("word.event.cb"), + util = require("down.util"), + log = require("down.util.log"), + buf = require("down.util.buf"), + -- cb = require("down.event.cb"), }, - utils = require("word.util"), - lib = require("word.util.lib"), + utils = require("down.util"), + lib = require("down.util.lib"), } --- local e = require("word") -local con, log, m, utils = require("word.config").config, W.log, W.mod, W.utils +-- local e = require("down") +local con, log, m, utils = require("down.config").config, W.log, W.mod, W.utils local a, f, ext = vim.api, vim.fn, vim.tbl_deep_extend ---- @init "word.config" +--- @init "down.config" ---- Initializes word. Parses the supplied user config, initializes all selected mod and adds filetype checking for `.word`. ---- @param conf word.config.UserMod? A table that reflects the structure of `config.user`. +--- Initializes down. Parses the supplied user config, initializes all selected mod and adds filetype checking for `.down`. +--- @param conf down.config.UserMod? A table that reflects the structure of `config.user`. function W.setup(conf) conf = conf or { mod = {} } if conf.mod == nil then @@ -44,14 +44,14 @@ function W.setup(conf) end con.user = utils.extend(con.user, conf) -- log.new(con.user.logger or log.get_base_config(), true) - require("word.config").setup_maps() - require("word.config").setup_opts() + require("down.config").setup_maps() + require("down.config").setup_opts() if W.util.buf.check_md() or not con.user.lazy then W.enter(false) else - -- a.nvim_create_user_command("wordInit", function() - -- vim.cmd.delcommand("wordInit") + -- a.nvim_create_user_command("downInit", function() + -- vim.cmd.delcommand("downInit") -- W.enter(true) -- end, {}) @@ -112,9 +112,9 @@ function W.enter(manual, args) mode = f.mode(), }) vim.api.nvim_exec_autocmds("User", { - pattern = "WordLoaded", -- + pattern = "downLoaded", -- }) end --- require("telescope").setup_extension("word") +-- require("telescope").setup_extension("down") return W diff --git a/lua/word/config.lua b/lua/down/config.lua similarity index 76% rename from lua/word/config.lua rename to lua/down/config.lua index a654212..e64da04 100644 --- a/lua/word/config.lua +++ b/lua/down/config.lua @@ -1,24 +1,24 @@ local C = {} -local osi = require("word.util").get_os_info() +local osi = require("down.util").get_os_info() local f = vim.fn ---- @type word.Config +--- @type down.Config C.config = { - ---@type word.config.UserMod + ---@type down.config.UserMod user = { mod = { config = {}, }, }, - -- data = f.stdpath("data") .. "/word.mpack", + -- data = f.stdpath("data") .. "/down.mpack", - ---@type word.config.Ft + ---@type down.config.Ft ft = { md = true, mdx = true, markdown = true, - word = true, + down = true, }, mod = { @@ -46,13 +46,13 @@ C.setup_maps = function() vim.api.nvim_set_keymap( "n", ",wl", - "Word lsp lens", + "down lsp lens", { silent = true } ) vim.api.nvim_set_keymap( "n", ",wa", - "Word lsp action", + "down lsp action", { silent = true } ) end diff --git a/lua/word/core/data/cache.lua b/lua/down/core/data/cache.lua similarity index 95% rename from lua/word/core/data/cache.lua rename to lua/down/core/data/cache.lua index 84ac59a..007066a 100644 --- a/lua/word/core/data/cache.lua +++ b/lua/down/core/data/cache.lua @@ -1,4 +1,4 @@ ----@class word.core.data.cache.Cache +---@class down.core.data.cache.Cache ---@field public head any ---@field public tail any ---@field public len integer diff --git a/lua/down/core/data/init.lua b/lua/down/core/data/init.lua new file mode 100644 index 0000000..ce31b5f --- /dev/null +++ b/lua/down/core/data/init.lua @@ -0,0 +1,10 @@ +---@class down.core.data.Data +local D = {} + +---@type down.core.data.cache.Cache +D.cache = require("down.core.data.cache") + +---@type down.core.data.store.Store +D.store = require("down.core.data.store") + +return D diff --git a/lua/down/core/data/store.lua b/lua/down/core/data/store.lua new file mode 100644 index 0000000..8bfa72f --- /dev/null +++ b/lua/down/core/data/store.lua @@ -0,0 +1,4 @@ +---@class down.core.data.store.Store +local S = {} + +return S diff --git a/lua/word/core/graph/edge/init.lua b/lua/down/core/graph/edge/init.lua similarity index 85% rename from lua/word/core/graph/edge/init.lua rename to lua/down/core/graph/edge/init.lua index cb816b1..d14ef66 100644 --- a/lua/word/core/graph/edge/init.lua +++ b/lua/down/core/graph/edge/init.lua @@ -1,5 +1,5 @@ ---@generic E ----@class word.core.graph.edge.EdgeInit +---@class down.core.graph.edge.EdgeInit ---@field public data table|nil ---@field public id string ---@field public kind string: the datatype kind @@ -7,7 +7,7 @@ ---@field public b string: node id from --- ---@generic E ----@class word.core.graph.edge.Edge +---@class down.core.graph.edge.Edge ---@field public data table|nil ---@field public id string ---@field public a string: node id from @@ -16,7 +16,7 @@ local Edge = { } ----@alias word.core.graph.Edge word.core.graph.edge.Edge +---@alias down.core.graph.Edge down.core.graph.edge.Edge ---@generic E any ---@param a string: node id from @@ -24,14 +24,14 @@ local Edge = { ---@param id string: the id ---@param kind string: the datatype kind ---@param data table|nil: The data to be stored in the edge. ----@return word.core.graph.edge.Edge +---@return down.core.graph.edge.Edge function Edge.new(a, b, id, kind, data) - ---@type word.core.graph.edge.EdgeInit + ---@type down.core.graph.edge.EdgeInit local edge = { a = a, b = b, data = data or nil, kind = kind, id = id } - ---@type word.core.graph.edge.Edge + ---@type down.core.graph.edge.Edge return setmetatable(edge, { __index = edge, __pairs = function(self) diff --git a/lua/word/core/graph/init.lua b/lua/down/core/graph/init.lua similarity index 58% rename from lua/word/core/graph/init.lua rename to lua/down/core/graph/init.lua index 4a47d5a..8ef3ad4 100644 --- a/lua/word/core/graph/init.lua +++ b/lua/down/core/graph/init.lua @@ -1,13 +1,13 @@ ---@generic N : any ----@type word.core.graph.Node -local _node = require("word.core.graph.node") +---@type down.core.graph.Node +local _node = require("down.core.graph.node") ---@generic E : any ----@type word.core.graph.Edge -local _edge = require("word.core.graph.edge") +---@type down.core.graph.Edge +local _edge = require("down.core.graph.edge") ----@class word.core.graph.Graph ----@field public nodes word.core.graph.node.Node[] ----@field public edges word.core.graph.edge.Edge[] +---@class down.core.graph.Graph +---@field public nodes down.core.graph.node.Node[] +---@field public edges down.core.graph.edge.Edge[] ---@field public directed? boolean: directed ---@field public weighted? boolean: directed ---@field public N any @@ -23,15 +23,15 @@ local G = { ---@generic N : table | nil ---@generic E : table | nil ----@class word.core.graph.GraphInit : word.core.graph.Graph +---@class down.core.graph.GraphInit : down.core.graph.Graph ---@generic N : table | nil ---@generic E : table | nil ----@return word.core.graph.Graph +---@return down.core.graph.Graph function G.new() ---@generic N ---@generic E - ---@type word.core.graph.GraphInit + ---@type down.core.graph.GraphInit local g = { } return setmetatable(g, { diff --git a/lua/word/core/graph/node/init.lua b/lua/down/core/graph/node/init.lua similarity index 82% rename from lua/word/core/graph/node/init.lua rename to lua/down/core/graph/node/init.lua index e71ea3a..c4b0d0f 100644 --- a/lua/word/core/graph/node/init.lua +++ b/lua/down/core/graph/node/init.lua @@ -1,28 +1,28 @@ ---@generic N ----@class word.core.graph.node.NodeInit +---@class down.core.graph.node.NodeInit ---@field public data table|nil ---@field public id string ---@field public kind string: the datatype kind --- ---@generic N ----@class word.core.graph.node.Node +---@class down.core.graph.node.Node ---@field public data? table ---@field public id string ---@field public kind string: the datatype kind local Node = { } ----@alias word.core.graph.Node word.core.graph.node.Node +---@alias down.core.graph.Node down.core.graph.node.Node ---@generic N any ---@param id string: the id ---@param kind string: the datatype kind ---@param data? table: The data to be stored in the node. ----@return word.core.graph.node.Node +---@return down.core.graph.node.Node function Node.new(id, kind, data) - ---@type word.core.graph.node.NodeInit + ---@type down.core.graph.node.NodeInit local node = { data = data or nil, kind = kind, id = id } - ---@type word.core.graph.node.Node + ---@type down.core.graph.node.Node return setmetatable(node, { __index = node, __pairs = function(self) diff --git a/lua/down/core/init.lua b/lua/down/core/init.lua new file mode 100644 index 0000000..828422e --- /dev/null +++ b/lua/down/core/init.lua @@ -0,0 +1,22 @@ +local C = {} + + +---@type down.core.parse.Parse +C.parse = require("down.core.parse") + +---@type down.core.graph.Graph +C.graph = require("down.core.graph") + +---@type down.core.graph.node.Node +C.node = require("down.core.graph.node") + +---@type down.core.graph.edge.Edge +C.edge = require("down.core.graph.edge") + +---@type down.core.data.Data +C.data = require("down.core.data") + +---@type down.core.data.cache.Cache +C.cache = require("down.core.data.cache") + +return C diff --git a/lua/down/core/parse/init.lua b/lua/down/core/parse/init.lua new file mode 100644 index 0000000..0548699 --- /dev/null +++ b/lua/down/core/parse/init.lua @@ -0,0 +1,6 @@ +---@class down.core.parse.Parse +local P = {} + + + +return P diff --git a/lua/word/health.lua b/lua/down/health.lua similarity index 83% rename from lua/word/health.lua rename to lua/down/health.lua index 48ed2ed..61211fc 100644 --- a/lua/word/health.lua +++ b/lua/down/health.lua @@ -5,7 +5,7 @@ local ok,err,warn=h.ok,h.error,h.warn H.check = function() h.start "checking config" - local c = require "word.mod.config".config + local c = require "down.mod.config".config if c == nil then err "config is nil" else diff --git a/lua/word/mod.lua b/lua/down/mod.lua similarity index 80% rename from lua/word/mod.lua rename to lua/down/mod.lua index 1b4999d..2bd1639 100644 --- a/lua/word/mod.lua +++ b/lua/down/mod.lua @@ -1,20 +1,20 @@ local uv, lu, fn = vim.loop or vim.uv, vim.lsp.util, vim.fn -local cb = require("word.util.event.callback") -local config = require("word.config").config -local log = require("word.util.log") -local utils = require("word.util") +local cb = require("down.util.event.callback") +local config = require("down.config").config +local log = require("down.util.log") +local utils = require("down.util") -- TODO: remove global ----@class word.Mod +---@class down.Mod Mod = setmetatable({}, { __index = Mod, - ---@param self word.Mod - ---@param other word.Mod + ---@param self down.Mod + ---@param other down.Mod __eq = function(self, other) return self.name == other.name end, - ---@param self word.Mod + ---@param self down.Mod __tostring = function(self) return self.name end, @@ -23,7 +23,7 @@ Mod = setmetatable({}, { Mod.default = function(name) return { setup = function() - ---@type word.mod.Setup + ---@type down.mod.Setup return { loaded = true, requires = {}, @@ -42,24 +42,24 @@ Mod.default = function(name) end, maps = function() -- TODO: obviously inefficient - local Map = require("word.util.maps") - Map.nmap(",wi", "Word index") - Map.nmap(",wp", "Word note template") - Map.nmap(",wc", "Word note calendar") - Map.nmap(",wn", "Word note index") - Map.nmap(",w.", "Word note tomorrow") - Map.nmap(",w,", "Word note yesterday") - Map.nmap(",wm", "Word note month") - Map.nmap(",wt", "Word note today") - Map.nmap(",wy", "Word note year") + local Map = require("down.util.maps") + Map.nmap(",wi", "Down index") + Map.nmap(",wp", "Down note template") + Map.nmap(",wc", "Down note calendar") + Map.nmap(",wn", "Down note index") + Map.nmap(",w.", "Down note tomorrow") + Map.nmap(",w,", "Down note yesterday") + Map.nmap(",wm", "Down note month") + Map.nmap(",wt", "Down note today") + Map.nmap(",wy", "Down note year") end, load = function() end, on = function() end, post_load = function() end, name = "config", - namespace = "word." .. name, + namespace = "down." .. name, path = "mod.config", - version = require("word").config.version, + version = require("down").config.version, data = { --TODO: remove data = {}, @@ -72,20 +72,20 @@ Mod.default = function(name) events = { subscribed = { -- The events that the init is subscribed to }, - defined = { -- The events that the init itself has defined + defined = { -- The events that the init itself has defined }, }, required = {}, import = {}, } end --- local cmd = require("word.cmd") +-- local cmd = require("down.cmd") --- @param name string The name of the new init. Modake sure this is unique. The recommended naming convention is `category.modn` or `category.subcategory.modn`. --- @param imports? string[] A list of imports to attach to the init. Import data is requestable via `init.required`. Use paths relative to the current init. ---- @return word.Mod +--- @return down.Mod function Mod.create(name, imports) - ---@type word.Mod + ---@type down.Mod local new = Mod.default(name) if imports then for _, imp in ipairs(imports) do @@ -93,8 +93,8 @@ function Mod.create(name, imports) if not Mod.load_mod(fullpath) then log.error( "Unable to load import '" - .. fullpath - .. "'! An error (see traceback below):" + .. fullpath + .. "'! An error (see traceback below):" ) assert(false) end @@ -105,7 +105,7 @@ function Mod.create(name, imports) if name then new.name = name new.path = "mod." .. name - new.namespace = "word.mod." .. name + new.namespace = "down.mod." .. name vim.api.nvim_create_namespace(new.namespace) end return new @@ -114,12 +114,12 @@ end --- Constructs a default array of modules --- @param name string The name of the new metainit. Modake sure this is unique. The recommended naming convention is `category.modn` or `category.subcategory.modn`. --- @param ... string A list of init names to load. ---- @return word.Mod +--- @return down.Mod Mod.modules = function(name, ...) - ---@type word.Mod + ---@type down.Mod local m = Mod.create(name) - m.config.public.enable = { ... } + m.config.enable = { ... } -- print(ms[0]) -- print(m.config.enable[0]) @@ -137,15 +137,15 @@ Mod.modules = function(name, ...) end m.load = function() - m.config.public.enable = (function() - if not m.config.public.disable then - return m.config.public.enable + m.config.enable = (function() + if not m.config.disable then + return m.config.enable end -- local ret = {} - for _, mname in ipairs(m.config.public.enable) do - if not vim.tbl_contains(m.config.public.disable, mname) then + for _, mname in ipairs(m.config.enable) do + if not vim.tbl_contains(m.config.disable, mname) then table.insert(ret, mname) end end @@ -153,7 +153,7 @@ Mod.modules = function(name, ...) return ret end)() - for _, mname in ipairs(m.config.public.enable) do + for _, mname in ipairs(m.config.enable) do Mod.load_mod(mname) end end @@ -167,12 +167,12 @@ end Mod.loaded_mod_count = 0 --- The table of currently loaded mod ---- @type { [string]: word.Mod } +--- @type { [string]: down.Mod } Mod.loaded_mod = {} --- Loads and enables a init --- Loads a specified init. If the init subscribes to any events then they will be activated too. ---- @param m word.Mod The actual init to load. +--- @param m down.Mod The actual init to load. --- @return boolean # Whether the init successfully loaded. function Mod.load_mod_from_table(m) log.info("Loading init with name" .. m.name) @@ -184,22 +184,22 @@ function Mod.load_mod_from_table(m) end -- Invoke the setup function. This function returns whether or not the loading of the init was successful and some metadata. - ---@type word.mod.Setup + ---@type down.mod.Setup local mod_load = m.setup and m.setup() - or { - loaded = true, - replaces = {}, - merge = false, - requires = {}, - wants = {}, - } + or { + loaded = true, + replaces = {}, + merge = false, + requires = {}, + wants = {}, + } -- We do not expect init.setup() to ever return nil, that's why this check is in place if not mod_load then log.error( "init" - .. m.name - .. "does not handle init loading correctly; init.setup() returned nil. Omitting..." + .. m.name + .. "does not handle init loading correctly; init.setup() returned nil. Omitting..." ) return false end @@ -231,15 +231,15 @@ function Mod.load_mod_from_table(m) if config.user.mod[req_mod] then log.trace( "Wanted init" - .. req_mod - .. "isn't loaded but can be as it's defined in the user's config. Loading..." + .. req_mod + .. "isn't loaded but can be as it's defined in the user's config. Loading..." ) if not Mod.load_mod(req_mod) then - require("word.util.log").error( + require("down.util.log").error( "Unable to load wanted init for" - .. m.name - .. "- the init didn't load successfully" + .. m.name + .. "- the init didn't load successfully" ) -- Modake sure to clean up after ourselves if the init failed to load @@ -248,7 +248,8 @@ function Mod.load_mod_from_table(m) end else log.error( - ("Unable to load init %s, wanted dependency %s was not satisfied. Be sure to load the init and its appropriate config too!"):format( + ("Unable to load init %s, wanted dependency %s was not satisfied. Be sure to load the init and its appropriate config too!") + :format( m.name, req_mod ) @@ -307,7 +308,8 @@ function Mod.load_mod_from_table(m) -- If this flag has already been set before, then throw an error - there is no way for us to know which hotswapped init should take priority. if mod_to_replace.replaced then log.error( - ("Unable to replace init %s - init replacement clashing detected. This error triggers when a init tries to be replaced more than two times - word doesn't know which replacement to prioritize."):format( + ("Unable to replace init %s - init replacement clashing detected. This error triggers when a init tries to be replaced more than two times - down doesn't know which replacement to prioritize.") + :format( mod_to_replace.name ) ) @@ -374,20 +376,20 @@ end --- Unlike `load_mod_from_table()`, which loads a init from memory, `load_mod()` tries to find the corresponding init file on disk and loads it into memory. --- If the init cannot not be found, attempt to load it off of github (unimplemented). This function also applies user-defined config and keys to the mod themselves. ---- This is the recommended way of loading mod - `load_mod_from_table()` should only really be used by word itself. ---- @param modn string A path to a init on disk. A path in word is '.', not '/'. ---- @param cfg table? A config that reflects the structure of `word.config.user.setup["init.name"].config`. +--- This is the recommended way of loading mod - `load_mod_from_table()` should only really be used by down itself. +--- @param modn string A path to a init on disk. A path in down is '.', not '/'. +--- @param cfg table? A config that reflects the structure of `down.config.user.setup["init.name"].config`. --- @return boolean # Whether the init was successfully loaded. function Mod.load_mod(modn, cfg) if Mod.is_mod_loaded(modn) then return true end - local modl = require("word.mod." .. modn) + local modl = require("down.mod." .. modn) if not modl then log.error( "Unable to load init" - .. modn - .. "- loaded file returned nil. Be sure to return the table created by mod.create() at the end of your init.lua file!" + .. modn + .. "- loaded file returned nil. Be sure to return the table created by mod.create() at the end of your init.lua file!" ) return false end @@ -395,8 +397,9 @@ function Mod.load_mod(modn, cfg) if modl == true then log.error( "An error has occurred when loading" - .. modn - .. "- loaded file didn't return anything meaningful. Be sure to return the table created by mod.create() at the end of your init.lua file!" + .. modn + .. + "- loaded file didn't return anything meaningful. Be sure to return the table created by mod.create() at the end of your init.lua file!" ) return false end @@ -404,13 +407,13 @@ function Mod.load_mod(modn, cfg) -- modl.config = {} if cfg and not vim.tbl_isempty(cfg) then modl.config.custom = cfg - modl.config.public = utils.extend(modl.config.public, cfg) + modl.config = utils.extend(modl.config, cfg) else - -- print(modl.config.custom, modl.config.public, config.mod[modn]) + -- print(modl.config.custom, modl.config, config.mod[modn]) modl.config.custom = config.mod[modn] - modl.config.public = - -- vim.tbl_extend("force", modl.config.public, modl.config.custom or {}) - utils.extend(modl.config.public, modl.config.custom or {}) + modl.config = + -- vim.tbl_extend("force", modl.config, modl.config.custom or {}) + utils.extend(modl.config, modl.config.custom or {}) end -- Pass execution onto load_mod_from_table() and let it handle the rest @@ -418,8 +421,8 @@ function Mod.load_mod(modn, cfg) end --- Has the same principle of operation as load_mod_from_table(), except it then sets up the parent init's "required" table, allowing the parent to access the child as if it were a dependency. ---- @param md word.Mod A valid table as returned by mod.create() ---- @param parent_mod string|word.Mod If a string, then the parent is searched for in the loaded mod. If a table, then the init is treated as a valid init as returned by mod.create() +--- @param md down.Mod A valid table as returned by mod.create() +--- @param parent_mod string|down.Mod If a string, then the parent is searched for in the loaded mod. If a table, then the init is treated as a valid init as returned by mod.create() function Mod.load_mod_as_dependency_from_table(md, parent_mod) if Mod.load_mod_from_table(md) then if type(parent_mod) == "string" then @@ -431,9 +434,9 @@ function Mod.load_mod_as_dependency_from_table(md, parent_mod) end --- Normally loads a init, but then sets up the parent init's "required" table, allowing the parent init to access the child as if it were a dependency. ---- @param modn string A path to a init on disk. A path in word is '.', not '/' +--- @param modn string A path to a init on disk. A path in down is '.', not '/' --- @param parent_mod string The name of the parent init. This is the init which the dependency will be attached to. ---- @param cfg? table A config that reflects the structure of word.config.user.setup["init.name"].config +--- @param cfg? table A config that reflects the structure of down.config.user.setup["init.name"].config function Mod.load_mod_as_dependency(modn, parent_mod, cfg) if Mod.load_mod(modn, cfg) and Mod.is_mod_loaded(parent_mod) then Mod.loaded_mod[parent_mod].required[modn] = Mod.get_mod_config(modn) @@ -462,13 +465,13 @@ function Mod.get_mod_config(modn) if not Mod.is_mod_loaded(modn) then log.trace( "Attempt to get init config with name" - .. modn - .. "failed - init is not loaded." + .. modn + .. "failed - init is not loaded." ) return end - return Mod.loaded_mod[modn].config.public + return Mod.loaded_mod[modn].config end --- Returns true if init with name modn is loaded, false otherwise @@ -486,8 +489,8 @@ function Mod.get_mod_version(modn) if not Mod.is_mod_loaded(modn) then log.trace( "Attempt to get init version with name" - .. modn - .. "failed - init is not loaded." + .. modn + .. "failed - init is not loaded." ) return end @@ -499,8 +502,8 @@ function Mod.get_mod_version(modn) if not version then log.trace( "Attempt to get init version with name" - .. modn - .. "failed - version variable not present." + .. modn + .. "failed - version variable not present." ) return end @@ -540,9 +543,9 @@ function Mod.split_event_type(type) end --- Returns an event template defined in `init.events.defined`. ---- @param m word.Mod A reference to the init invoking the function +--- @param m down.Mod A reference to the init invoking the function --- @param type string A full path to a valid event type (e.g. `init.events.some_event`) ---- @return word.Event? +--- @return down.Event? function Mod.get_event_template(m, type) -- You can't get the event template of a type if the type isn't loaded if not Mod.is_mod_loaded(m.name) then @@ -566,13 +569,13 @@ function Mod.get_event_template(m, type) end --- Creates a deep copy of the `mod.base_event` event and returns it with a custom type and referrer. ---- @param m word.Mod A reference to the init invoking the function. +--- @param m down.Mod A reference to the init invoking the function. --- @param name string A relative path to a valid event template. ---- @return word.Event +--- @return down.Event function Mod.define_event(m, name) -- Create a copy of the base event and override the values with ones specified by the user - ---@type word.Event + ---@type down.Event local new_event = { payload = nil, topic = "base_event", @@ -598,18 +601,18 @@ function Mod.define_event(m, name) end --- Returns a copy of the event template provided by a init. ---- @param init word.Mod A reference to the init invoking the function +--- @param init down.Mod A reference to the init invoking the function --- @param type string A full path to a valid .vent type (e.g. `init.events.some_event`) --- @param content table|any? The content of the event, can be anything from a string to a table to whatever you please. --- @param ev? table The original event data. ---- @return word.Event? # New event. +--- @return down.Event? # New event. function Mod.create_event(m, type, content, ev) -- Get the init that contains the event local modn = Mod.split_event_type(type)[1] -- Retrieve the template from init.events.defined local event_template = - Mod.get_event_template(Mod.loaded_mod[modn] or { name = "" }, type) + Mod.get_event_template(Mod.loaded_mod[modn] or { name = "" }, type) if not event_template then log.warn("Unable to create event of type" .. type .. ". Returning nil...") @@ -635,7 +638,7 @@ function Mod.create_event(m, type, content, ev) new_event.cursor_position = vim.api.nvim_win_get_cursor(winid) local row_1b = new_event.cursor_position[1] new_event.line_content = - vim.api.nvim_buf_get_lines(bufid, row_1b - 1, row_1b, true)[1] + vim.api.nvim_buf_get_lines(bufid, row_1b - 1, row_1b, true)[1] new_event.referrer = m.name new_event.broadcast = true new_event.buffer = bufid @@ -646,15 +649,15 @@ function Mod.create_event(m, type, content, ev) end --- Sends an event to all subscribed mod. The event contains the filename, filehead, cursor position and line content as a bonus. ---- @param event word.Event An event, usually created by `mod.create_event()`. +--- @param event down.Event An event, usually created by `mod.create_event()`. --- @param callback function? A callback to be invoked after all events have been asynchronously broadcast function Mod.broadcast(event, callback) -- Broadcast the event to all mod if not event.split_type then log.error( "Unable to broadcast event of type" - .. event.type - .. "- invalid event name" + .. event.type + .. "- invalid event name" ) return end @@ -676,7 +679,7 @@ function Mod.broadcast(event, callback) end --- @param recv string The name of a loaded init that will be the recipient of the event. ---- @param ev word.Event An event, usually created by `mod.create_event()`. +--- @param ev down.Event An event, usually created by `mod.create_event()`. --- @return nil function Mod.send_event(recv, ev) if not Mod.is_mod_loaded(recv) then diff --git a/lua/word/mod/README.md b/lua/down/mod/README.md similarity index 100% rename from lua/word/mod/README.md rename to lua/down/mod/README.md diff --git a/lua/word/mod/cmd/back/README.md b/lua/down/mod/cmd/README.md similarity index 100% rename from lua/word/mod/cmd/back/README.md rename to lua/down/mod/cmd/README.md diff --git a/lua/word/mod/cmd/find/README.md b/lua/down/mod/cmd/back/README.md similarity index 100% rename from lua/word/mod/cmd/find/README.md rename to lua/down/mod/cmd/back/README.md diff --git a/lua/word/mod/cmd/back/init.lua b/lua/down/mod/cmd/back/init.lua similarity index 78% rename from lua/word/mod/cmd/back/init.lua rename to lua/down/mod/cmd/back/init.lua index 76c71f8..a42b58a 100644 --- a/lua/word/mod/cmd/back/init.lua +++ b/lua/down/mod/cmd/back/init.lua @@ -1,15 +1,15 @@ --[[ file: cmd-return - title: Provides the `:word return` Command - summary: Return to last location before entering word. + title: Provides the `:down return` Command + summary: Return to last location before entering down. internal: true --- -When executed (`:word return`), all currently open `.word` files are deleted from +When executed (`:down return`), all currently open `.down` files are deleted from the buffer list, and the current workspace is set to "config". --]] -local word = require("word") -local mod = word.mod +local down = require("down") +local mod = down.mod local init = mod.create("cmd.back") @@ -34,7 +34,7 @@ init.on = function(event) local to_delete = {} for buffer in vim.iter(buffers):rev() do if vim.fn.buflisted(buffer) == 1 then - -- If the listed buffer we're working with has a .word extension then remove it (not forcibly) + -- If the listed buffer we're working with has a .down extension then remove it (not forcibly) if not vim.endswith(vim.api.nvim_buf_get_name(buffer), ".md") then vim.api.nvim_win_set_buf(0, buffer) break diff --git a/lua/word/mod/cmd/mod/README.md b/lua/down/mod/cmd/find/README.md similarity index 100% rename from lua/word/mod/cmd/mod/README.md rename to lua/down/mod/cmd/find/README.md diff --git a/lua/down/mod/cmd/find/init.lua b/lua/down/mod/cmd/find/init.lua new file mode 100644 index 0000000..8838a7d --- /dev/null +++ b/lua/down/mod/cmd/find/init.lua @@ -0,0 +1,15 @@ +local M = require("down.mod").create("cmd.find") + +---@class down.find.Config +M.config = {} + +---@class down.find.Data +M.data = {} + +M.setup = function() + return { + loaded = true, + } +end + +return M diff --git a/lua/word/mod/cmd/init.lua b/lua/down/mod/cmd/init.lua similarity index 82% rename from lua/word/mod/cmd/init.lua rename to lua/down/mod/cmd/init.lua index c65af1f..0a49488 100644 --- a/lua/word/mod/cmd/init.lua +++ b/lua/down/mod/cmd/init.lua @@ -1,11 +1,11 @@ -local word = require("word") -local log, mod, util = word.log, word.mod, word.utils +local down = require("down") +local log, mod, util = down.log, down.mod, down.utils local M = mod.create("cmd") M.maps = function() - Map.nmap(",wml", "Word mod list") - Map.nmap(",wmL", "Word mod load") + Map.nmap(",wml", "Down mod list") + Map.nmap(",wmL", "Down mod load") end M.setup = function() return { loaded = true, requires = {} } @@ -14,23 +14,23 @@ M.data = { data = { --- Handles the calling of the appropriate function based on the command the user entered - word_callback = function(data) + down_callback = function(data) local args = data.fargs local current_buf = vim.api.nvim_get_current_buf() - local is_word = vim.bo[current_buf].filetype == "markdown" + local is_down = vim.bo[current_buf].filetype == "markdown" local function check_condition(condition) if condition == nil then return true end - if condition == "markdown" and not is_word then + if condition == "markdown" and not is_down then return false end if type(condition) == "function" then - return condition(current_buf, is_word) + return condition(current_buf, is_down) end return condition @@ -50,14 +50,15 @@ M.data = { if not ref then log.error( - ("Error when executing `:Word %s` - such a command does not exist!"):format( + ("Error when executing `:Down %s` - such a command does not exist!"):format( table.concat(vim.list_slice(args, 1, i), " ") ) ) return elseif not check_condition(ref.condition) then log.error( - ("Error when executing `:Word %s` - the command is currently disabled. Some commands will only become available under certain conditions, e.g. being within a `.Word` file!"):format( + ("Error when executing `:Down %s` - the command is currently disabled. Some commands will only become available under certain conditions, e.g. being within a `.down` file!") + :format( table.concat(vim.list_slice(args, 1, i), " ") ) ) @@ -82,13 +83,13 @@ M.data = { if #args == 0 or argument_count < ref.min_args then local completions = M.data.data.generate_completions( _, - table.concat({ "Word ", data.args, " " }) + table.concat({ "down ", data.args, " " }) ) M.data.data.select_next_cmd_arg(data.args, completions) return elseif argument_count > ref.max_args then log.error( - ("Error when executing `:Word %s` - too many arguments supplied! The command expects %s argument%s."):format( + ("Error when executing `:down %s` - too many arguments supplied! The command expects %s argument%s."):format( data.args, ref.max_args == 0 and "no" or ref.max_args, ref.max_args == 1 and "" or "s" @@ -99,7 +100,8 @@ M.data = { if not ref.name then log.error( - ("Error when executing `:Word %s` - the ending command didn't have a `name` variable associated with it! This is an implementation error on the developer's side, so file a report to the author of the mod."):format( + ("Error when executing `:down %s` - the ending command didn't have a `name` variable associated with it! This is an implementation error on the developer's side, so file a report to the author of the mod.") + :format( data.args ) ) @@ -121,25 +123,25 @@ M.data = { ) end, - --- This function returns all available commands to be used for the :Word command + --- This function returns all available commands to be used for the :down command ---@param _ nil #Placeholder variable ---@param command string #Supplied by nvim itself; the full typed out command generate_completions = function(_, command) local current_buf = vim.api.nvim_get_current_buf() - local is_word = vim.api.nvim_buf_get_option(current_buf, "filetype") - == "markdown" + local is_down = vim.api.nvim_buf_get_option(current_buf, "filetype") + == "markdown" local function check_condition(condition) if condition == nil then return true end - if condition == "markdown" and not is_word then + if condition == "markdown" and not is_down then return false end if type(condition) == "function" then - return condition(current_buf, is_word) + return condition(current_buf, is_down) end return condition @@ -178,24 +180,24 @@ M.data = { if not last_valid_ref.subcommands and last_valid_ref.complete then if type(last_valid_ref.complete) == "function" then last_valid_ref.complete = - last_valid_ref.complete(current_buf, is_word) + last_valid_ref.complete(current_buf, is_down) end if vim.endswith(command, " ") then local completions = last_valid_ref.complete[#splitcmd - last_completion_level + 1] - or {} + or {} if type(completions) == "function" then - completions = completions(current_buf, is_word) or {} + completions = completions(current_buf, is_down) or {} end return completions else local completions = last_valid_ref.complete[#splitcmd - last_completion_level] - or {} + or {} if type(completions) == "function" then - completions = completions(current_buf, is_word) or {} + completions = completions(current_buf, is_down) or {} end return vim.tbl_filter(function(key) @@ -204,13 +206,13 @@ M.data = { end end - -- TODO: Fix `:Word m ` giving invalid completions + -- TODO: Fix `:down m ` giving invalid completions local keys = ref and vim.tbl_keys(ref.subcommands or {}) - or ( - vim.tbl_filter(function(key) - return key:find(splitcmd[#splitcmd]) - end, vim.tbl_keys(last_valid_ref.subcommands or {})) - ) + or ( + vim.tbl_filter(function(key) + return key:find(splitcmd[#splitcmd]) + end, vim.tbl_keys(last_valid_ref.subcommands or {})) + ) table.sort(keys) do @@ -225,10 +227,10 @@ M.data = { end, --- Queries the user to select next argument - ---@param qargs table #A string of arguments previously supplied to the word command + ---@param qargs table #A string of arguments previously supplied to the down command ---@param choices table #all possible choices for the next argument select_next_cmd_arg = function(qargs, choices) - local current = table.concat({ "Word ", qargs }) + local current = table.concat({ "down ", qargs }) local query @@ -282,7 +284,7 @@ M.data = { end M.data.commands = - vim.tbl_extend("force", M.data.commands, mod_config.commands) + vim.tbl_extend("force", M.data.commands, mod_config.commands) end, -- add = function(cmd, cb) @@ -307,14 +309,14 @@ M.data = { ---@param name string #The relative path of the init we want to load add_commands_from_file = function(name) -- Attempt to require the file - local err, ret = pcall(require, "word.mod.cmd." .. name .. "init") + local err, ret = pcall(require, "down.mod.cmd." .. name .. "init") -- If we've failed bail out if not err then log.warn( "Could not load command" - .. name - .. "for init base.cmd - the corresponding mod.lua file does not exist." + .. name + .. "for init base.cmd - the corresponding mod.lua file does not exist." ) return end @@ -334,16 +336,16 @@ M.data = { end, --- Defines a custom completion function to use for `base.cmd`. - ---@param callback function The same function format as you would receive by being called by `:command -completion=customlist,v:lua.callback word`. + ---@param callback function The same function format as you would receive by being called by `:command -completion=customlist,v:lua.callback down`. set_completion_callback = function(callback) M.data.data.generate_completions = callback end, } M.load = function() - -- Define the :word command with autocompletion taking any number of arguments (-nargs=*) + -- Define the :down command with autocompletion taking any number of arguments (-nargs=*) -- If the user passes no arguments or too few, we'll query them for the remainder using select_next_cmd_arg. - vim.api.nvim_create_user_command("Word", M.data.data.word_callback, { - desc = "The word command", + vim.api.nvim_create_user_command("Down", M.data.data.down_callback, { + desc = "The down command", range = 2, force = true, -- bang = true, @@ -352,16 +354,16 @@ M.load = function() }) -- Loop through all the command mod we want to load and load them - for _, command in ipairs(M.config.public.load) do + for _, command in ipairs(M.config.load) do if command == "default" then - for _, base_command in ipairs(M.config.public.base) do + for _, base_command in ipairs(M.config.base) do M.data.add_commands_from_file(base_command) end end end end -M.config.public = { +M.config = { -- A list of cmd mod to load automatically. -- This feature will soon be deprecated, so it is not recommended to touch it. load = { @@ -428,7 +430,7 @@ M.on = function(event) local lines = {} - for name, _ in pairs(word.mod.loaded_mod) do + for name, _ in pairs(down.mod.loaded_mod) do table.insert(lines, "- `" .. name .. "`") end diff --git a/lua/word/mod/cmd/rename/README.md b/lua/down/mod/cmd/mod/README.md similarity index 100% rename from lua/word/mod/cmd/rename/README.md rename to lua/down/mod/cmd/mod/README.md diff --git a/lua/word/mod/cmd/mod/init.lua b/lua/down/mod/cmd/mod/init.lua similarity index 94% rename from lua/word/mod/cmd/mod/init.lua rename to lua/down/mod/cmd/mod/init.lua index 3b5f31d..c7253e9 100644 --- a/lua/word/mod/cmd/mod/init.lua +++ b/lua/down/mod/cmd/mod/init.lua @@ -1,5 +1,5 @@ -local word = require("word") -local mod = word.mod +local down = require("down") +local mod = down.mod local M = mod.create("cmd.mod") @@ -71,7 +71,7 @@ M.on = function(event) local lines = {} - for name, _ in pairs(word.mod.loaded_mod) do + for name, _ in pairs(down.mod.loaded_mod) do table.insert(lines, "- `"..name.."`") end diff --git a/lua/word/mod/data/README.md b/lua/down/mod/cmd/rename/README.md similarity index 100% rename from lua/word/mod/data/README.md rename to lua/down/mod/cmd/rename/README.md diff --git a/lua/word/mod/cmd/rename/init.lua b/lua/down/mod/cmd/rename/init.lua similarity index 78% rename from lua/word/mod/cmd/rename/init.lua rename to lua/down/mod/cmd/rename/init.lua index 99a684c..29b72c5 100644 --- a/lua/word/mod/cmd/rename/init.lua +++ b/lua/down/mod/cmd/rename/init.lua @@ -1,14 +1,14 @@ --[[ file: cmd-rename - title: Provides the `:word rename` Command - summary: rename to last location before entering word. + title: Provides the `:down rename` Command + summary: rename to last location before entering down. internal: true --- -When executed (`:word rename`), all currently open `.word` files are deleted from +When executed (`:down rename`), all currently open `.down` files are deleted from the buffer list, and the current workspace is set to "config". --]] -local word = require("word") -local mod = word.mod +local down = require("down") +local mod = down.mod local init = mod.create("cmd.rename") @@ -33,7 +33,7 @@ init.on = function(event) local to_delete = {} for buffer in vim.iter(buffers):rev() do if vim.fn.buflisted(buffer) == 1 then - -- If the listed buffer we're working with has a .word extension then remove it (not forcibly) + -- If the listed buffer we're working with has a .down extension then remove it (not forcibly) if not vim.endswith(vim.api.nvim_buf_get_name(buffer), ".md") then vim.api.nvim_win_set_buf(0, buffer) break diff --git a/lua/word/mod/config.lua b/lua/down/mod/config.lua similarity index 85% rename from lua/word/mod/config.lua rename to lua/down/mod/config.lua index 8f28725..a9ace6c 100644 --- a/lua/word/mod/config.lua +++ b/lua/down/mod/config.lua @@ -1,4 +1,4 @@ -local M = require("word.mod").modules( +local M = require("down.mod").modules( ---@type string: name of config created "config", ---@brief rest of modules are loaded diff --git a/lua/word/mod/data/clipboard/README.md b/lua/down/mod/data/README.md similarity index 100% rename from lua/word/mod/data/clipboard/README.md rename to lua/down/mod/data/README.md diff --git a/lua/word/mod/data/code/README.md b/lua/down/mod/data/clipboard/README.md similarity index 100% rename from lua/word/mod/data/code/README.md rename to lua/down/mod/data/clipboard/README.md diff --git a/lua/down/mod/data/clipboard/init.lua b/lua/down/mod/data/clipboard/init.lua new file mode 100644 index 0000000..2bc5e72 --- /dev/null +++ b/lua/down/mod/data/clipboard/init.lua @@ -0,0 +1,15 @@ +local C = require("down.mod").create("data.clipboard") + +C.setup = function() + return { + loaded = true, + } +end + +---@class down.data.clipboard.Data +C.config = {} + +---@class down.data.clipboard.Data +C.data = {} + +return C diff --git a/lua/word/mod/data/code/run/README.md b/lua/down/mod/data/code/README.md similarity index 100% rename from lua/word/mod/data/code/run/README.md rename to lua/down/mod/data/code/README.md diff --git a/lua/word/mod/data/code/init.lua b/lua/down/mod/data/code/init.lua similarity index 95% rename from lua/word/mod/data/code/init.lua rename to lua/down/mod/data/code/init.lua index fefa8ec..80d6b31 100644 --- a/lua/word/mod/data/code/init.lua +++ b/lua/down/mod/data/code/init.lua @@ -1,5 +1,5 @@ -local word = require("word") -local lib, mod, utils, log = word.lib, word.mod, word.utils, word.log +local down = require("down") +local lib, mod, utils, log = down.lib, down.mod, down.utils, down.log local M = Mod.create("data.code", { "run", "snippet" }) local Path = require("pathlib") @@ -25,14 +25,14 @@ M.setup = function() }) end) - if M.config.public.code_on_write then + if M.config.code_on_write then local augroup = - vim.api.nvim_create_augroup("word_auto_code", { clear = true }) + vim.api.nvim_create_augroup("down_auto_code", { clear = true }) vim.api.nvim_create_autocmd("BufWritePost", { desc = "code the current file on write", pattern = "*.markdown", group = augroup, - command = "word code current-file", + command = "down code current-file", }) end return { @@ -55,7 +55,7 @@ local function get_comment_string(language) return commentstring end ----@class word.data.code.Data +---@class down.data.code.Data M.data = { code = function(buffer) ---@type base.treesitter @@ -122,7 +122,7 @@ M.data = { if capture == "tag" then local ok, parsed_tag = pcall(treesitter.get_tag_info, node, true) if not ok then - if M.config.public.public.indent_errors == "print" then + if M.config.public.indent_errors == "print" then -- print(parsed_tag) else log.error(parsed_tag) @@ -134,7 +134,7 @@ M.data = { local declared_filetype = parsed_tag.parameters[1] local block_content = parsed_tag.content - if parsed_tag.parameters[1] == "word" then + if parsed_tag.parameters[1] == "down" then for i, line in ipairs(block_content) do local new_line, _ = line:gsub("\\(.?)", "%1") block_content[i] = new_line or "" @@ -320,15 +320,15 @@ M.data = { return true end, } ----@class word.data.code.Config -M.config.public = { +---@class down.data.code.Config +M.config = { -- Notify when there is nothing to code (INFO) or when the content is empty (WARN). report_on_empty = true, - -- code all code blocks in the current word file on file write. + -- code all code blocks in the current down file on file write. code_on_write = false, - -- When text in a code block is less indented than the block itself, word will not code that + -- When text in a code block is less indented than the block itself, down will not code that -- block to a file. Instead it can either print or vim.notify error. By base, vim.notify is -- loud and is more likely to create a press enter message. -- - "notify" - Throw a normal looking error @@ -341,7 +341,7 @@ M.on = function(event) local codes = M.data.code(event.buffer) if not codes or vim.tbl_isempty(codes) then - if M.config.public.report_on_empty then + if M.config.report_on_empty then utils.notify("Nothing to code!", vim.log.levels.INFO) end return @@ -375,7 +375,7 @@ M.on = function(event) ) local write_content = table.concat(content, "\n") - if M.config.public.report_on_empty and write_content:len() == 0 then + if M.config.report_on_empty and write_content:len() == 0 then vim.schedule(function() utils.notify( string.format("coded content for %s is empty.", file), diff --git a/lua/word/mod/data/code/snippet/README.md b/lua/down/mod/data/code/run/README.md similarity index 100% rename from lua/word/mod/data/code/snippet/README.md rename to lua/down/mod/data/code/run/README.md diff --git a/lua/down/mod/data/code/run/init.lua b/lua/down/mod/data/code/run/init.lua new file mode 100644 index 0000000..d1071f9 --- /dev/null +++ b/lua/down/mod/data/code/run/init.lua @@ -0,0 +1,18 @@ +local down = require("down") +local lib, mod, utils, log = down.lib, down.mod, down.utils, down.log + +local M = down.mod.create("data.code.run") + +M.setup = function() + return { + loaded = true, + } +end + +---@class down.data.code.run.Config +M.config = {} + +---@class down.data.code.run.Data +M.data = {} + +return M diff --git a/lua/word/mod/data/dirs/README.md b/lua/down/mod/data/code/snippet/README.md similarity index 100% rename from lua/word/mod/data/dirs/README.md rename to lua/down/mod/data/code/snippet/README.md diff --git a/lua/word/mod/data/code/snippet/init.lua b/lua/down/mod/data/code/snippet/init.lua similarity index 84% rename from lua/word/mod/data/code/snippet/init.lua rename to lua/down/mod/data/code/snippet/init.lua index af4ecf3..744b027 100644 --- a/lua/word/mod/data/code/snippet/init.lua +++ b/lua/down/mod/data/code/snippet/init.lua @@ -1,4 +1,4 @@ -local mod = require("word.mod") +local mod = require("down.mod") local M = mod.create("data.code.snippet") M.setup = function() @@ -25,10 +25,10 @@ M.setup = function() } end ----@class word.data.code.snippet.Config -M.config.public = {} +---@class down.data.code.snippet.Config +M.config = {} ----@class word.data.code.snippet.Data +---@class down.data.code.snippet.Data M.data = {} M.events.subscribed = { diff --git a/lua/word/mod/data/encrypt/README.md b/lua/down/mod/data/dirs/README.md similarity index 100% rename from lua/word/mod/data/encrypt/README.md rename to lua/down/mod/data/dirs/README.md diff --git a/lua/word/mod/data/dirs/init.lua b/lua/down/mod/data/dirs/init.lua similarity index 93% rename from lua/word/mod/data/dirs/init.lua rename to lua/down/mod/data/dirs/init.lua index ec3c0c6..4b33e34 100644 --- a/lua/word/mod/data/dirs/init.lua +++ b/lua/down/mod/data/dirs/init.lua @@ -15,8 +15,8 @@ D.setup = function() } end ----@class word.data.dirs.Config -D.config.public = { +---@class down.data.dirs.Config +D.config = { vim = { data = vim.fn.stdpath("data"), config = vim.fn.stdpath("config"), @@ -27,10 +27,10 @@ D.config.public = { }, } ----@class word.data.dirs.Data +---@class down.data.dirs.Data D.data = { user = {}, - word = { + down = { config = { data = vim.fn.stdpath("data"), config = vim.fn.stdpath("config"), diff --git a/lua/word/mod/data/export/README.md b/lua/down/mod/data/encrypt/README.md similarity index 100% rename from lua/word/mod/data/export/README.md rename to lua/down/mod/data/encrypt/README.md diff --git a/lua/word/mod/data/encrypt/init.lua b/lua/down/mod/data/encrypt/init.lua similarity index 86% rename from lua/word/mod/data/encrypt/init.lua rename to lua/down/mod/data/encrypt/init.lua index adce930..e7eb135 100644 --- a/lua/word/mod/data/encrypt/init.lua +++ b/lua/down/mod/data/encrypt/init.lua @@ -1,4 +1,4 @@ -local mod = require("word.mod") +local mod = require("down.mod") local E = mod.create("data.encrypt") E.setup = function() @@ -29,10 +29,10 @@ E.setup = function() } end ----@class word.data.encrypt.Config -E.config.public = {} +---@class down.data.encrypt.Config +E.config = {} ----@class word.data.encrypt.Data +---@class down.data.encrypt.Data E.data = {} E.on = function(e) end diff --git a/lua/word/mod/data/log/README.md b/lua/down/mod/data/export/README.md similarity index 100% rename from lua/word/mod/data/log/README.md rename to lua/down/mod/data/export/README.md diff --git a/lua/word/mod/data/export/init.lua b/lua/down/mod/data/export/init.lua similarity index 85% rename from lua/word/mod/data/export/init.lua rename to lua/down/mod/data/export/init.lua index ce946be..79204d8 100644 --- a/lua/word/mod/data/export/init.lua +++ b/lua/down/mod/data/export/init.lua @@ -1,4 +1,4 @@ -local mod = require("word.mod") +local mod = require("down.mod") local E = Mod.create("data.export") E.setup = function() @@ -29,10 +29,10 @@ E.setup = function() } end ----@class word.data.export.Config -E.config.public = {} +---@class down.data.export.Config +E.config = {} ----@class word.data.export.Data +---@class down.data.export.Data E.data = {} E.on = function(e) end diff --git a/lua/word/mod/data/init.lua b/lua/down/mod/data/init.lua similarity index 92% rename from lua/word/mod/data/init.lua rename to lua/down/mod/data/init.lua index a9d5d86..56a716b 100644 --- a/lua/word/mod/data/init.lua +++ b/lua/down/mod/data/init.lua @@ -2,7 +2,7 @@ --- load on `data` load also require the data module --- for generic function, maybe implement in separate --- util.lua file that is required for submodules -local M = require("word.mod").create("data", { +local M = require("down.mod").create("data", { "log", "mod", "sync", @@ -25,7 +25,7 @@ M.setup = function() }) M.data.sync() - ---@type word.mod.Setup + ---@type down.mod.Setup return { loaded = true, requires = { @@ -34,12 +34,12 @@ M.setup = function() } end ----@class word.data.Config -M.config.public = { - path = vim.fn.stdpath("data") .. "/word.mpack", +---@class down.data.Config +M.config = { + path = vim.fn.stdpath("data") .. "/down.mpack", } ----@class word.data.Data +---@class down.data.Data M.data = { data = { data = {}, @@ -93,7 +93,7 @@ M.data = { end, --- Grabs the data present on disk and overwrites it with the data present in memory sync = function() - local file = io.open(M.config.public.path, "r") + local file = io.open(M.config.path, "r") if not file then return end @@ -125,7 +125,7 @@ M.data = { --- Flushes the contents in memory to the location specified flush = function() - local file = io.open(M.config.public.path, "w") + local file = io.open(M.config.path, "w") if not file then return diff --git a/lua/word/mod/data/media/README.md b/lua/down/mod/data/log/README.md similarity index 100% rename from lua/word/mod/data/media/README.md rename to lua/down/mod/data/log/README.md diff --git a/lua/word/mod/data/log/init.lua b/lua/down/mod/data/log/init.lua similarity index 89% rename from lua/word/mod/data/log/init.lua rename to lua/down/mod/data/log/init.lua index 65030ef..df22df5 100644 --- a/lua/word/mod/data/log/init.lua +++ b/lua/down/mod/data/log/init.lua @@ -1,12 +1,12 @@ -local word = require("word") -local config, lib, log, mod = word.cfg, word.lib, word.log, word.mod +local down = require("down") +local config, lib, log, mod = down.cfg, down.lib, down.log, down.mod local M = mod.create("data.log") M.setup = function() - if M.config.public.strategies[M.config.public.strategy] then - M.config.public.strategy = - M.config.public.strategies[M.config.public.strategy] + if M.config.strategies[M.config.strategy] then + M.config.strategy = + M.config.strategies[M.config.strategy] end -- mod.await("cmd", function(cmd) @@ -51,7 +51,7 @@ end -- M.set = M.data.set ---@class data.log.Config -M.config.public = { +M.config = { -- Which workspace to use for the log files, the base behaviour -- is to use the current workspace. -- @@ -63,12 +63,12 @@ M.config.public = { log_folder = "log", -- The strategy to use to create directories. - -- May be "flat" (`2022-03-02.word`), "nested" (`2022/03/02.word`), + -- May be "flat" (`2022-03-02.down`), "nested" (`2022/03/02.down`), -- a lua string with the format given to `os.date()` or a lua function -- that returns a lua string with the same format. strategy = "nested", - -- The name of the template file to use when running `:word log template`. + -- The name of the template file to use when running `:down log template`. template_name = "template.md", -- Whether to apply the template file to new log entries. @@ -81,7 +81,7 @@ M.config.public = { toc_format = nil, } -M.config.public.strategies = { +M.config.strategies = { flat = "%Y-%m-%d.md", nested = "%Y" .. config.pathsep .. "%m" .. config.pathsep .. "%d.md", } @@ -100,12 +100,12 @@ M.data = { ---@param time? number #The time to open the log entry at as returned by `os.time()` ---@param custom_date? string #A YYYY-mm-dd string that specifies a date to open the log at instead open_log = function(time, custom_date) - -- TODO(vhyrro): Change this to use word dates! - local workspace = M.config.public.workspace + -- TODO(vhyrro): Change this to use down dates! + local workspace = M.config.workspace or M.required["workspace"].get_current_workspace()[1] local workspace_path = M.required["workspace"].get_workspace(workspace) - local folder_name = M.config.public.log_folder - local template_name = M.config.public.template_name + local folder_name = M.config.log_folder + local template_name = M.config.template_name if custom_date then local year, month, day = custom_date:match("^(%d%d%d%d)-(%d%d)-(%d%d)$") @@ -123,9 +123,9 @@ M.data = { end local path = os.date( - type(M.config.public.strategy) == "function" - and M.config.public.strategy(os.date("*t", time)) - or M.config.public.strategy, + type(M.config.strategy) == "function" + and M.config.strategy(os.date("*t", time)) + or M.config.strategy, time ) @@ -145,7 +145,7 @@ M.data = { if not log_file_exists - and M.config.public.use_template + and M.config.use_template and M.required["workspace"].file_exists( workspace_path .. "/" .. folder_name .. "/" .. template_name ) @@ -188,9 +188,9 @@ M.data = { --- Creates a template file create_template = function() - local workspace = M.config.public.workspace - local folder_name = M.config.public.log_folder - local template_name = M.config.public.template_name + local workspace = M.config.workspace + local folder_name = M.config.log_folder + local template_name = M.config.template_name M.required["workspace"].create_file( folder_name .. config.pathsep .. template_name, @@ -200,10 +200,10 @@ M.data = { --- Opens the toc file open_toc = function() - local workspace = M.config.public.workspace + local workspace = M.config.workspace or M.required["workspace"].get_current_workspace()[1] local index = mod.get_mod_config("workspace").index - local folder_name = M.config.public.log_folder + local folder_name = M.config.log_folder -- If the toc exists, open it, if not, create it if @@ -222,12 +222,12 @@ M.data = { --- Creates or updates the toc file create_toc = function() - local workspace = M.config.public.workspace + local workspace = M.config.workspace or M.required["workspace"].get_current_workspace()[1] local index = mod.get_mod_config("workspace").index local workspace_path = M.required["workspace"].get_workspace(workspace) - local workspace_name_for_link = M.config.public.workspace or "" - local folder_name = M.config.public.log_folder + local workspace_name_for_link = M.config.workspace or "" + local folder_name = M.config.log_folder -- Each entry is a table that contains tables like { yy, mm, dd, link, title } local toc_entries = {} @@ -286,7 +286,7 @@ M.data = { ) while true do - -- Name corresponds to either a YYYY-mm-dd.word file, or just the year ("nested" strategy) + -- Name corresponds to either a YYYY-mm-dd.down file, or just the year ("nested" strategy) local name, type = vim.loop.fs_scandir_next(handle) ---@diagnostic disable-line -- TODO: type error workaround if not name then @@ -315,7 +315,7 @@ M.data = { break end - -- If it's a .word file, also ensure it is a day entry + -- If it's a .down file, also ensure it is a day entry if dtype == "file" and string.match(dname, "%d%d%.md") then -- Split the file name local file = vim.split(dname, ".", { plain = true }) @@ -338,7 +338,7 @@ M.data = { "{:$" .. workspace_name_for_link .. config.pathsep - .. M.config.public.log_folder + .. M.config.log_folder .. config.pathsep .. name .. config.pathsep @@ -356,7 +356,7 @@ M.data = { end -- Handles flat entries - -- If it is a .word file, but it's not any user generated file. + -- If it is a .down file, but it's not any user generated file. -- The match is here to avoid handling files made by the user, like a template file, or -- the toc file if type == "file" and string.match(name, "%d+-%d+-%d+%.md") then @@ -381,7 +381,7 @@ M.data = { "{:$" .. workspace_name_for_link .. config.pathsep - .. M.config.public.log_folder + .. M.config.log_folder .. config.pathsep .. file[1] .. ":}", @@ -393,7 +393,7 @@ M.data = { vim.schedule(function() -- Gets a base format for the entries - local format = M.config.public.toc_format + local format = M.config.toc_format or function(entries) local months_text = M.data.months -- Convert the entries into a certain format to be written diff --git a/lua/word/mod/data/metadata/README.md b/lua/down/mod/data/media/README.md similarity index 100% rename from lua/word/mod/data/metadata/README.md rename to lua/down/mod/data/media/README.md diff --git a/lua/word/mod/data/media/init.lua b/lua/down/mod/data/media/init.lua similarity index 76% rename from lua/word/mod/data/media/init.lua rename to lua/down/mod/data/media/init.lua index 596f335..d944f47 100644 --- a/lua/word/mod/data/media/init.lua +++ b/lua/down/mod/data/media/init.lua @@ -1,4 +1,4 @@ -local mod = require("word.mod") +local mod = require("down.mod") local M = mod.create("data.media") M.setup = function() @@ -10,6 +10,6 @@ end M.data = {} ---@class data.media.Config -M.config.public = {} +M.config = {} return M diff --git a/lua/word/mod/data/mod/README.md b/lua/down/mod/data/metadata/README.md similarity index 100% rename from lua/word/mod/data/mod/README.md rename to lua/down/mod/data/metadata/README.md diff --git a/lua/word/mod/data/metadata/init.lua b/lua/down/mod/data/metadata/init.lua similarity index 90% rename from lua/word/mod/data/metadata/init.lua rename to lua/down/mod/data/metadata/init.lua index 87b214e..8d253d9 100644 --- a/lua/word/mod/data/metadata/init.lua +++ b/lua/down/mod/data/metadata/init.lua @@ -1,4 +1,4 @@ -local mod = require("word.mod") +local mod = require("down.mod") local M = mod.create("data.metadata") @@ -33,12 +33,12 @@ M.setup = function() } end ----@class word.data.metadata.Config -M.config.public = { +---@class down.data.metadata.Config +M.config = { fields = {}, } ----@class word.data.metadata.Data +---@class down.data.metadata.Data M.data = { buf_inject_frontmatter = function() local id = "" diff --git a/lua/word/mod/data/sync/README.md b/lua/down/mod/data/mod/README.md similarity index 100% rename from lua/word/mod/data/sync/README.md rename to lua/down/mod/data/mod/README.md diff --git a/lua/down/mod/data/mod/init.lua b/lua/down/mod/data/mod/init.lua new file mode 100644 index 0000000..768c0cb --- /dev/null +++ b/lua/down/mod/data/mod/init.lua @@ -0,0 +1,16 @@ +---@type down.Mod +local M = require("down.mod").create("data.mod") + +M.setup = function() + return { + loaded = true, + } +end + +---@class down.data.mod.Config +M.config = {} + +---@class down.data.mod.Data +M.data = {} + +return M diff --git a/lua/word/mod/data/save/README.md b/lua/down/mod/data/save/README.md similarity index 68% rename from lua/word/mod/data/save/README.md rename to lua/down/mod/data/save/README.md index 706c4b4..c0abd11 100644 --- a/lua/word/mod/data/save/README.md +++ b/lua/down/mod/data/save/README.md @@ -1,4 +1,4 @@ -# `word.mod.data.save` +# `down.mod.data.save` ## about diff --git a/lua/word/mod/data/save/init.lua b/lua/down/mod/data/save/init.lua similarity index 85% rename from lua/word/mod/data/save/init.lua rename to lua/down/mod/data/save/init.lua index 71db098..764b0f6 100644 --- a/lua/word/mod/data/save/init.lua +++ b/lua/down/mod/data/save/init.lua @@ -1,4 +1,4 @@ -local mod = require("word.mod") +local mod = require("down.mod") local M = mod.create("data.save") M.setup = function() @@ -28,10 +28,10 @@ M.setup = function() } end ----@class word.data.save.Config -M.config.public = {} +---@class down.data.save.Config +M.config = {} ----@class word.data.save.Data +---@class down.data.save.Data M.data = {} M.events.subscribed = { diff --git a/lua/word/mod/data/tag/README.md b/lua/down/mod/data/sync/README.md similarity index 100% rename from lua/word/mod/data/tag/README.md rename to lua/down/mod/data/sync/README.md diff --git a/lua/word/mod/data/sync/init.lua b/lua/down/mod/data/sync/init.lua similarity index 85% rename from lua/word/mod/data/sync/init.lua rename to lua/down/mod/data/sync/init.lua index fa53e00..bfd2e72 100644 --- a/lua/word/mod/data/sync/init.lua +++ b/lua/down/mod/data/sync/init.lua @@ -1,4 +1,4 @@ -local mod = require("word.mod") +local mod = require("down.mod") local M = mod.create("data.sync") @@ -29,11 +29,11 @@ M.setup = function() } end ----@class word.data.sync.Data +---@class down.data.sync.Data M.data = {} ----@class word.data.sync.Config -M.config.public = {} +---@class down.data.sync.Config +M.config = {} M.events.subscribed = { cmd = { diff --git a/lua/word/mod/data/template/README.md b/lua/down/mod/data/tag/README.md similarity index 100% rename from lua/word/mod/data/template/README.md rename to lua/down/mod/data/tag/README.md diff --git a/lua/word/mod/data/tag/init.lua b/lua/down/mod/data/tag/init.lua similarity index 87% rename from lua/word/mod/data/tag/init.lua rename to lua/down/mod/data/tag/init.lua index 438546c..d2f12fa 100644 --- a/lua/word/mod/data/tag/init.lua +++ b/lua/down/mod/data/tag/init.lua @@ -1,4 +1,4 @@ -local mod = require("word.mod") +local mod = require("down.mod") local M = mod.create("data.tag") M.setup = function() @@ -29,11 +29,11 @@ M.setup = function() } end ----@class word.data.tag.Data +---@class down.data.tag.Data M.data = {} ----@class word.data.tag.Config -M.config.public = {} +---@class down.data.tag.Config +M.config = {} M.events.subscribed = { cmd = { diff --git a/lua/word/mod/data/time/README.md b/lua/down/mod/data/template/README.md similarity index 100% rename from lua/word/mod/data/time/README.md rename to lua/down/mod/data/template/README.md diff --git a/lua/word/mod/data/template/init.lua b/lua/down/mod/data/template/init.lua similarity index 89% rename from lua/word/mod/data/template/init.lua rename to lua/down/mod/data/template/init.lua index 253b35c..a18993e 100644 --- a/lua/word/mod/data/template/init.lua +++ b/lua/down/mod/data/template/init.lua @@ -1,12 +1,12 @@ -local word = require("word") -local config, lib, log, mod = word.cfg, word.lib, word.log, word.mod +local down = require("down") +local config, lib, log, mod = down.cfg, down.lib, down.log, down.mod local M = mod.create("data.template") M.setup = function() - if M.config.public.strategies[M.config.public.strategy] then - M.config.public.strategy = - M.config.public.strategies[M.config.public.strategy] + if M.config.strategies[M.config.strategy] then + M.config.strategy = + M.config.strategies[M.config.strategy] end -- mod.await("cmd", function(cmd) @@ -43,7 +43,7 @@ M.setup = function() } end -M.config.public = { +M.config = { strategies = { flat = "%Y-%m-%d.md", @@ -60,12 +60,12 @@ M.config.public = { template_folder = "data.template", -- The strategy to use to create directories. - -- May be "flat" (`2022-03-02.word`), "nested" (`2022/03/02.word`), + -- May be "flat" (`2022-03-02.down`), "nested" (`2022/03/02.down`), -- a lua string with the format given to `os.date()` or a lua function -- that returns a lua string with the same format. strategy = "nested", - -- The name of the template file to use when running `:word template template`. + -- The name of the template file to use when running `:down template template`. template_name = "data.template.md", -- Whether to apply the template file to new template entries. @@ -88,12 +88,12 @@ M.data = { ---@param time? number #The time to open the template entry at as returned by `os.time()` ---@param custom_date? string #A YYYY-mm-dd string that specifies a date to open the template at instead open_template = function(time, custom_date) - -- TODO(vhyrro): Change this to use word dates! - local workspace = M.config.public.workspace + -- TODO(vhyrro): Change this to use down dates! + local workspace = M.config.workspace or M.required["workspace"].get_current_workspace()[1] local workspace_path = M.required["workspace"].get_workspace(workspace) - local folder_name = M.config.public.template_folder - local template_name = M.config.public.template_name + local folder_name = M.config.template_folder + local template_name = M.config.template_name if custom_date then local year, month, day = custom_date:match("^(%d%d%d%d)-(%d%d)-(%d%d)$") @@ -111,9 +111,9 @@ M.data = { end local path = os.date( - type(M.config.public.strategy) == "function" - and M.config.public.strategy(os.date("*t", time)) - or M.config.public.strategy, + type(M.config.strategy) == "function" + and M.config.strategy(os.date("*t", time)) + or M.config.strategy, time ) @@ -133,7 +133,7 @@ M.data = { if not template_file_exists - and M.config.public.use_template + and M.config.use_template and M.required["workspace"].file_exists( workspace_path .. "/" .. folder_name .. "/" .. template_name ) @@ -167,9 +167,9 @@ M.data = { --- Creates a template file create_template = function() - local workspace = M.config.public.workspace - local folder_name = M.config.public.template_folder - local template_name = M.config.public.template_name + local workspace = M.config.workspace + local folder_name = M.config.template_folder + local template_name = M.config.template_name M.required.workspace.create_file( folder_name .. config.pathsep .. template_name, @@ -179,10 +179,10 @@ M.data = { --- Opens the toc file open_toc = function() - local workspace = M.config.public.workspace + local workspace = M.config.workspace or M.required["workspace"].get_current_workspace()[1] local index = mod.get_mod_config("workspace").index - local folder_name = M.config.public.template_folder + local folder_name = M.config.template_folder -- If the toc exists, open it, if not, create it if @@ -199,12 +199,12 @@ M.data = { --- Creates or updates the toc file create_toc = function() - local workspace = M.config.public.workspace + local workspace = M.config.workspace or M.required["workspace"].get_current_workspace()[1] local index = mod.get_mod_config("workspace").index local workspace_path = M.required["workspace"].get_workspace(workspace) - local workspace_name_for_link = M.config.public.workspace or "" - local folder_name = M.config.public.template_folder + local workspace_name_for_link = M.config.workspace or "" + local folder_name = M.config.template_folder -- Each entry is a table that contains tables like { yy, mm, dd, link, title } local toc_entries = {} @@ -263,7 +263,7 @@ M.data = { ) while true do - -- Name corresponds to either a YYYY-mm-dd.word file, or just the year ("nested" strategy) + -- Name corresponds to either a YYYY-mm-dd.down file, or just the year ("nested" strategy) local name, type = vim.loop.fs_scandir_next(handle) ---@diagnostic disable-line -- TODO: type error workaround if not name then @@ -292,7 +292,7 @@ M.data = { break end - -- If it's a .word file, also ensure it is a day entry + -- If it's a .down file, also ensure it is a day entry if dtype == "file" and string.match(dname, "%d%d%.md") then -- Split the file name local file = vim.split(dname, ".", { plain = true }) @@ -315,7 +315,7 @@ M.data = { "{:$" .. workspace_name_for_link .. config.pathsep - .. M.config.public.template_folder + .. M.config.template_folder .. config.pathsep .. name .. config.pathsep @@ -333,7 +333,7 @@ M.data = { end -- Handles flat entries - -- If it is a .word file, but it's not any user generated file. + -- If it is a .down file, but it's not any user generated file. -- The match is here to avoid handling files made by the user, like a template file, or -- the toc file if type == "file" and string.match(name, "%d+-%d+-%d+%.md") then @@ -358,7 +358,7 @@ M.data = { "{:$" .. workspace_name_for_link .. config.pathsep - .. M.config.public.template_folder + .. M.config.template_folder .. config.pathsep .. file[1] .. ":}", @@ -370,10 +370,10 @@ M.data = { vim.schedule(function() -- Gets a base format for the entries - local format = M.config.public.toc_format + local format = M.config.toc_format or function(entries) local months_text = - require("word.mod.data.template.util").months + require("down.mod.data.template.util").months -- Convert the entries into a certain format to be written local output = {} local current_year diff --git a/lua/word/mod/data/todo/README.md b/lua/down/mod/data/time/README.md similarity index 100% rename from lua/word/mod/data/todo/README.md rename to lua/down/mod/data/time/README.md diff --git a/lua/word/mod/data/time/init.lua b/lua/down/mod/data/time/init.lua similarity index 89% rename from lua/word/mod/data/time/init.lua rename to lua/down/mod/data/time/init.lua index fb6f910..5986c86 100644 --- a/lua/word/mod/data/time/init.lua +++ b/lua/down/mod/data/time/init.lua @@ -1,6 +1,6 @@ -local d = require("word") +local d = require("down") local lib, Mod, utils = d.lib, d.mod, d.utils -local u = require("word.mod.data.time.util") +local u = require("down.mod.data.time.util") local M = Mod.create("data.time") @@ -10,7 +10,7 @@ local _, time_regex = ---@alias Date {weekday: {name: string, number: number}?, day: number?, month: {name: string, number: number}?, year: number?, timezone: string?, time: {hour: number, minute: number, second: number?}?} ----@class word.data.time.Data +---@class down.data.time.Data M.data = { tostringable_date = function(date_table) return setmetatable(date_table, { @@ -46,7 +46,7 @@ M.data = { return os.date("*t", parsed) --[[@as osdate]] end, - --- Converts a lua `osdate` to a word date. + --- Converts a lua `osdate` to a down date. ---@param osdate osdate #The date to convert ---@param include_time boolean? #Whether to include the time (hh::mm.ss) in the output. ---@return Date #The converted date @@ -103,7 +103,7 @@ M.data = { end, --- Parses a date and returns a table representing the date - ---@param input string #The input which should follow the date specification found in the word spec. + ---@param input string #The input which should follow the date specification found in the down spec. ---@return Date|string #The data extracted from the input or an error message parse_date = function(input) local weekdays = {} @@ -124,20 +124,20 @@ M.data = { local output = {} - for word in vim.gsplit(input, "%s+") do - if word:len() == 0 then + for down in vim.gsplit(input, "%s+") do + if down:len() == 0 then goto continue end - if word:match("^-?%d%d%d%d+$") then - output.year = tonumber(word) - elseif word:match("^%d+%w*$") then - output.day = tonumber(word:match("%d+")) - elseif vim.list_contains(u.tz, word:upper()) then - output.timezone = word:upper() + if down:match("^-?%d%d%d%d+$") then + output.year = tonumber(down) + elseif down:match("^%d+%w*$") then + output.day = tonumber(down:match("%d+")) + elseif vim.list_contains(u.tz, down:upper()) then + output.timezone = down:upper() else do - local hour, minute, second = vim.re.match(word, time_regex) + local hour, minute, second = vim.re.match(down, time_regex) if hour and minute then output.time = setmetatable({ @@ -146,7 +146,7 @@ M.data = { second = second and tonumber(second) or nil, }, { __tostring = function() - return word + return down end, }) @@ -159,7 +159,7 @@ M.data = { -- Check for month abbreviation for i, month in ipairs(months) do - if vim.startswith(month, word:lower()) then + if vim.startswith(month, down:lower()) then valid_months[month] = i end end @@ -181,13 +181,13 @@ M.data = { end do - word = word:match("^([^,]+),?$") + down = down:match("^([^,]+),?$") local valid_weekdays = {} -- Check for weekday abbreviation for i, weekday in ipairs(weekdays) do - if vim.startswith(weekday, word:lower()) then + if vim.startswith(weekday, down:lower()) then valid_weekdays[weekday] = i end end @@ -210,7 +210,7 @@ M.data = { end return "Unidentified string: `" - .. word + .. down .. "` - make sure your locale and language are set correctly if you are using a language other than English!" end @@ -269,12 +269,12 @@ M.data = { M.maps = function() vim.keymap.set( "", - "(word.time.insert-date)", + "(down.time.insert-date)", lib.wrap(M.data.insert_date, false) ) vim.keymap.set( "i", - "(word.time.insert-date.insert-mode)", + "(down.time.insert-date.insert-mode)", lib.wrap(M.data.insert_date, true) ) end diff --git a/lua/word/mod/data/time/util.lua b/lua/down/mod/data/time/util.lua similarity index 100% rename from lua/word/mod/data/time/util.lua rename to lua/down/mod/data/time/util.lua diff --git a/lua/word/mod/edit/README.md b/lua/down/mod/data/todo/README.md similarity index 100% rename from lua/word/mod/edit/README.md rename to lua/down/mod/data/todo/README.md diff --git a/lua/word/mod/data/todo/init.lua b/lua/down/mod/data/todo/init.lua similarity index 87% rename from lua/word/mod/data/todo/init.lua rename to lua/down/mod/data/todo/init.lua index 2feb952..1d23fad 100644 --- a/lua/word/mod/data/todo/init.lua +++ b/lua/down/mod/data/todo/init.lua @@ -1,20 +1,20 @@ -local mod, map = require("word.mod"), require("word.util.maps") +local mod, map = require("down.mod"), require("down.util.maps") local M = mod.create("data.todo") M.maps = function() - map.nmap(",wt", "Telescope word todo") + map.nmap(",wt", "Telescope down todo") end ----@class word.data.todo.Data +---@class down.data.todo.Data M.data = { - namespace = vim.api.nvim_create_namespace("word.data.todo"), + namespace = vim.api.nvim_create_namespace("down.data.todo"), --- List of active buffers buffers = {}, } ----@class word.data.todo.Config -M.config.public = { +---@class down.data.todo.Config +M.config = { highlight_group = "Normal", @@ -49,7 +49,7 @@ end M.load = function() vim.api.nvim_create_autocmd("Filetype", { pattern = "markdown", - desc = "Attaches the TODO introspector to any word buffer.", + desc = "Attaches the TODO introspector to any down buffer.", callback = function(ev) local buf = ev.buf @@ -63,8 +63,8 @@ M.load = function() }) end ---- Attaches the introspector to a given word buffer. ---- Errors if the target buffer is not a word buffer. +--- Attaches the introspector to a given down buffer. +--- Errors if the target buffer is not a down buffer. ---@param buffer number #The buffer ID to attach to. function M.data.attach_introspector(buffer) if @@ -73,7 +73,7 @@ function M.data.attach_introspector(buffer) then error( string.format( - "Could not attach to buffer %d, buffer is not a word file!", + "Could not attach to buffer %d, buffer is not a down file!", buffer ) ) @@ -164,7 +164,7 @@ end ---@return number total Total number of counted tasks function M.data.calculate_items(node) local counts = {} - for _, status in ipairs(M.config.public.counted_statuses) do + for _, status in ipairs(M.config.counted_statuses) do counts[status] = 0 end @@ -192,7 +192,7 @@ function M.data.calculate_items(node) end local completed = 0 - for _, status in ipairs(M.config.public.completed_statuses) do + for _, status in ipairs(M.config.completed_statuses) do if counts[status] then completed = completed + counts[status] end @@ -218,8 +218,8 @@ function M.data.perform_introspection(buffer, node) vim.api.nvim_buf_set_extmark(buffer, M.data.namespace, line, col, { virt_text = { { - M.config.public.format(completed, total), - M.config.public.highlight_group, + M.config.format(completed, total), + M.config.highlight_group, }, }, invalidate = true, diff --git a/lua/word/mod/edit/conceal/README.md b/lua/down/mod/edit/README.md similarity index 100% rename from lua/word/mod/edit/conceal/README.md rename to lua/down/mod/edit/README.md diff --git a/lua/word/mod/edit/cursor/README.md b/lua/down/mod/edit/conceal/README.md similarity index 100% rename from lua/word/mod/edit/cursor/README.md rename to lua/down/mod/edit/conceal/README.md diff --git a/lua/word/mod/edit/conceal/border.lua b/lua/down/mod/edit/conceal/border.lua similarity index 100% rename from lua/word/mod/edit/conceal/border.lua rename to lua/down/mod/edit/conceal/border.lua diff --git a/lua/word/mod/edit/conceal/chars.lua b/lua/down/mod/edit/conceal/chars.lua similarity index 100% rename from lua/word/mod/edit/conceal/chars.lua rename to lua/down/mod/edit/conceal/chars.lua diff --git a/lua/word/mod/edit/conceal/init.lua b/lua/down/mod/edit/conceal/init.lua similarity index 90% rename from lua/word/mod/edit/conceal/init.lua rename to lua/down/mod/edit/conceal/init.lua index f10210e..d543626 100644 --- a/lua/word/mod/edit/conceal/init.lua +++ b/lua/down/mod/edit/conceal/init.lua @@ -1,10 +1,10 @@ -local word = require("word") -local mod, config = word.mod, word.cfg +local down = require("down") +local mod, config = down.mod, down.cfg local M = mod.create("edit.conceal") local fn, a, madd = vim.fn, vim.api, vim.fn.matchadd -M.chars = require("word.mod.edit.conceal.chars") -M.math = require("word.mod.edit.conceal.math") -M.border = require("word.mod.edit.conceal.border") +M.chars = require("down.mod.edit.conceal.chars") +M.math = require("down.mod.edit.conceal.math") +M.border = require("down.mod.edit.conceal.border") M.setup = function() return { @@ -16,11 +16,11 @@ end M.data.math = M.math.data M.data.border = M.border.data M.data.chars = M.chars.data -M.config.public = { +M.config = { link_style = "markdown", } M.data.data.start_link_concealing = function() - if M.config.public == "markdown" then + if M.config == "markdown" then madd( "Conceal", "\\[[^[]\\{-}\\]\\zs([^(]\\{-})\\ze", diff --git a/lua/word/mod/edit/conceal/math.lua b/lua/down/mod/edit/conceal/math.lua similarity index 100% rename from lua/word/mod/edit/conceal/math.lua rename to lua/down/mod/edit/conceal/math.lua diff --git a/lua/word/mod/edit/find/README.md b/lua/down/mod/edit/cursor/README.md similarity index 100% rename from lua/word/mod/edit/find/README.md rename to lua/down/mod/edit/cursor/README.md diff --git a/lua/word/mod/edit/cursor/init.lua b/lua/down/mod/edit/cursor/init.lua similarity index 99% rename from lua/word/mod/edit/cursor/init.lua rename to lua/down/mod/edit/cursor/init.lua index aee4d83..e085788 100644 --- a/lua/word/mod/edit/cursor/init.lua +++ b/lua/down/mod/edit/cursor/init.lua @@ -12,7 +12,7 @@ function L.setup() end ---@class edit.cursor.Config -L.config.public = {} +L.config = {} ---@class edit.cursor.Data ---@field public node TSNode|nil diff --git a/lua/word/mod/edit/fold/README.md b/lua/down/mod/edit/find/README.md similarity index 100% rename from lua/word/mod/edit/fold/README.md rename to lua/down/mod/edit/find/README.md diff --git a/lua/word/mod/edit/find/init.lua b/lua/down/mod/edit/find/init.lua similarity index 94% rename from lua/word/mod/edit/find/init.lua rename to lua/down/mod/edit/find/init.lua index f46f5de..83bfb69 100644 --- a/lua/word/mod/edit/find/init.lua +++ b/lua/down/mod/edit/find/init.lua @@ -1,7 +1,7 @@ local uv = vim.uv local e = vim.lpeg -local d = require("word") +local d = require("down") local lib, mod = d.lib, d.mod local M = mod.create("edit.find") @@ -37,7 +37,7 @@ end M.data = {} -M.config.public = {} +M.config = {} M.data.data = {} M.events = {} diff --git a/lua/word/mod/edit/hl/README.md b/lua/down/mod/edit/fold/README.md similarity index 100% rename from lua/word/mod/edit/hl/README.md rename to lua/down/mod/edit/fold/README.md diff --git a/lua/down/mod/edit/fold/init.lua b/lua/down/mod/edit/fold/init.lua new file mode 100644 index 0000000..2acf3ab --- /dev/null +++ b/lua/down/mod/edit/fold/init.lua @@ -0,0 +1,20 @@ +local mod = require 'down.mod' + +local F = mod.create('edit.fold') + +F.setup = function() + return { + loaded = true + } +end + +---@class down.edit.fold.Config +F.config = { + +} +---@class down.edit.fold.Data +F.data = { + +} + +return F diff --git a/lua/word/mod/edit/indent/README.md b/lua/down/mod/edit/hl/README.md similarity index 100% rename from lua/word/mod/edit/indent/README.md rename to lua/down/mod/edit/hl/README.md diff --git a/lua/word/mod/edit/hl/init.lua b/lua/down/mod/edit/hl/init.lua similarity index 88% rename from lua/word/mod/edit/hl/init.lua rename to lua/down/mod/edit/hl/init.lua index 74adcff..8c172b8 100644 --- a/lua/word/mod/edit/hl/init.lua +++ b/lua/down/mod/edit/hl/init.lua @@ -1,15 +1,15 @@ -local word = require("word") -local lib, log, mod = word.lib, word.log, word.mod +local down = require("down") +local lib, log, mod = down.lib, down.log, down.mod local M = mod.create("edit.hl") --[[ --]] -M.config.public = { - -- The TS highlight for each word type. +M.config = { + -- The TS highlight for each down type. -- -- The `highlight` table is a large collection of nested trees. At the leaves of each of these - -- trees is the final highighlightight to apply to that tree. For example: `"+@comment"` tells word to + -- trees is the final highighlightight to apply to that tree. For example: `"+@comment"` tells down to -- link to an existing highighlightight group `@comment` (denoted by the `+` prefix). When no prefix is -- found, the string is treated as arguments passed to `:highighlightight`, for example: `gui=bold -- fg=#000000`. @@ -24,14 +24,14 @@ M.config.public = { -- ``` -- matches the highighlightight group: -- ```lua - -- @word.tags.ranged_verbatim.begin + -- @down.tags.ranged_verbatim.begin -- ``` -- and converts into the following command: -- ```vim - -- highighlightight! link @word.tags.ranged_verbatim.begin @comment + -- highighlightight! link @down.tags.ranged_verbatim.begin @comment -- ``` highlight = { - -- highlight displayed in word selection window popups. + -- highlight displayed in down selection window popups. selection_window = { heading = "+@annotation", arrow = "+@none", @@ -46,14 +46,14 @@ M.config.public = { tags = { -- highlight for the `@` verbatim tags. ranged_verbatim = { - begin = "+@keyword", + begin = "+@keydown", - ["end"] = "+@keyword", + ["end"] = "+@keydown", name = { [""] = "+@none", delimiter = "+@none", - word = "+@keyword", + down = "+@keydown", }, parameters = "+@type", @@ -62,11 +62,11 @@ M.config.public = { key = "+@variable.member", value = "+@string", number = "+@number", - trailing = "+@keyword.repeat", + trailing = "+@keydown.repeat", title = "+@markup.heading", description = "+@label", authors = "+@annotation", - categories = "+@keyword", + categories = "+@keydown", created = "+@number.float", updated = "+@number.float", version = "+@number.float", @@ -88,7 +88,7 @@ M.config.public = { name = { [""] = "+@none", - word = "+@label", + down = "+@label", delimiter = "+@none", }, @@ -152,7 +152,7 @@ M.config.public = { -- highlight for TODO items. -- - -- This strictly covers the `( )` component of any detached modifier. In other words, these + -- This strictly covers the `( )` component of any detached modifier. In other downs, these -- highlight only bother with highighlightighting the brackets and the content within, but not the -- object containing the TODO item itself. todo_items = { @@ -163,14 +163,14 @@ M.config.public = { cancelled = "+NonText", urgent = "+@comment.error", uncertain = "+@boolean", - recurring = "+@keyword.repeat", + recurring = "+@keydown.repeat", }, -- highlight for all the possible levels of ordered and unordered lists. lists = { unordered = { prefix = "+@markup.list" }, - ordered = { prefix = "+@keyword.repeat" }, + ordered = { prefix = "+@keydown.repeat" }, }, -- highlight for all the possible levels of quotes. @@ -239,49 +239,49 @@ M.config.public = { }, marker = { - [""] = "+@word.markers.title", - prefix = "+@word.markers.prefix", + [""] = "+@down.markers.title", + prefix = "+@down.markers.prefix", }, defMion = { - [""] = "+@word.defMions.title", - prefix = "+@word.defMions.prefix", + [""] = "+@down.defMions.title", + prefix = "+@down.defMions.prefix", }, footnote = { - [""] = "+@word.footnotes.title", - prefix = "+@word.footnotes.prefix", + [""] = "+@down.footnotes.title", + prefix = "+@down.footnotes.prefix", }, heading = { ["1"] = { - [""] = "+@word.headings.1.title", - prefix = "+@word.headings.1.prefix", + [""] = "+@down.headings.1.title", + prefix = "+@down.headings.1.prefix", }, ["2"] = { - [""] = "+@word.headings.2.title", - prefix = "+@word.headings.2.prefix", + [""] = "+@down.headings.2.title", + prefix = "+@down.headings.2.prefix", }, ["3"] = { - [""] = "+@word.headings.3.title", - prefix = "+@word.headings.3.prefix", + [""] = "+@down.headings.3.title", + prefix = "+@down.headings.3.prefix", }, ["4"] = { - [""] = "+@word.headings.4.title", - prefix = "+@word.headings.4.prefix", + [""] = "+@down.headings.4.title", + prefix = "+@down.headings.4.prefix", }, ["5"] = { - [""] = "+@word.headings.5.title", - prefix = "+@word.headings.5.prefix", + [""] = "+@down.headings.5.title", + prefix = "+@down.headings.5.prefix", }, ["6"] = { - [""] = "+@word.headings.6.title", - prefix = "+@word.headings.6.prefix", + [""] = "+@down.headings.6.title", + prefix = "+@down.headings.6.prefix", }, }, }, @@ -428,18 +428,18 @@ M.data = { -- do -- local query = require("nvim-treesitter.query") - -- if not query.has_highlight("word") then + -- if not query.has_highlight("down") then -- query.invalidate_query_cache() - -- if not query.has_highlight("word") then + -- if not query.has_highlight("down") then -- log.error( - -- "nvim-treesitter has no available highlight for word! Ensure treesitter is properly loaded in your config." + -- "nvim-treesitter has no available highlight for down! Ensure treesitter is properly loaded in your config." -- ) -- end -- end - -- if vim.bo.filetype == "word" then - -- require("nvim-treesitter.highighlightight").attach(vim.api.nvim_get_current_buf(), "word") + -- if vim.bo.filetype == "down" then + -- require("nvim-treesitter.highighlightight").attach(vim.api.nvim_get_current_buf(), "down") -- end -- end @@ -458,7 +458,7 @@ M.data = { -- Begin the descent down the public highlight configuration table descend( - M.config.public.highlight, + M.config.highlight, function(highlight_name, highighlightight, prefix) -- If the type of highighlightight we have encountered is a table -- then recursively descend down it as well @@ -473,7 +473,7 @@ M.data = { -- by checking for the existence of the + sign at the front local is_link = highighlightight:sub(1, 1) == "+" - local full_highighlightight_name = "@word" + local full_highighlightight_name = "@down" .. prefix .. (highlight_name:len() > 0 and ("." .. highlight_name) or "") local does_highlight_exist = lib.inline_pcall( @@ -517,14 +517,14 @@ M.data = { -- Begin the descent down the dimming configuration table descend( - M.config.public.dim, + M.config.dim, function(highlight_name, highighlightight, prefix) -- If we don't have a percentage value then keep traversing down the table tree if not highighlightight.percentage then return true end - local full_highighlightight_name = "@word" + local full_highighlightight_name = "@down" .. prefix .. (highlight_name:len() > 0 and ("." .. highlight_name) or "") local does_highlight_exist = lib.inline_pcall( @@ -561,20 +561,20 @@ M.data = { --- Takes in a table of highlight and applies them to the current buffer ---@param highlight table #A table of highlight add_highlight = function(highlight) - M.config.public.highlight = - vim.tbl_deep_extend("force", M.config.public.highlight, highlight or {}) + M.config.highlight = + vim.tbl_deep_extend("force", M.config.highlight, highlight or {}) M.data.trigger_highlight() end, --- Takes in a table of items to dim and applies the dimming to them ---@param dim table #A table of items to dim add_dim = function(dim) - M.config.public.dim = - vim.tbl_deep_extend("force", M.config.public.dim, dim or {}) + M.config.dim = + vim.tbl_deep_extend("force", M.config.dim, dim or {}) M.data.trigger_highlight() end, - --- Assigns all word* highlight to `clear` + --- Assigns all down* highlight to `clear` clear_highlight = function() --- Recursively descends down the highighlightight configuration and clears every highighlightight accordingly ---@param highlight table #The table of highlight to descend down @@ -586,13 +586,13 @@ M.data = { if type(hl) == "table" then descend(hl, highlight_name) else - vim.cmd("hl! clear word" .. prefix .. highlight_name) + vim.cmd("hl! clear down" .. prefix .. highlight_name) end end end -- Begin the descent - descend(M.config.public.highlight, "") + descend(M.config.highlight, "") end, get_attribute = function(name, attribute) diff --git a/lua/word/mod/edit/inline/README.md b/lua/down/mod/edit/indent/README.md similarity index 100% rename from lua/word/mod/edit/inline/README.md rename to lua/down/mod/edit/indent/README.md diff --git a/lua/word/mod/edit/indent/init.lua b/lua/down/mod/edit/indent/init.lua similarity index 83% rename from lua/word/mod/edit/indent/init.lua rename to lua/down/mod/edit/indent/init.lua index 150f131..f8467c7 100644 --- a/lua/word/mod/edit/indent/init.lua +++ b/lua/down/mod/edit/indent/init.lua @@ -1,4 +1,5 @@ -local M = Mod.create("edit.indent") +local mod = require "down.mod" +local M = mod.create("edit.indent") local ts = vim.treesitter M.maps = function() @@ -12,24 +13,28 @@ end M.cmds = function() -- NOTE: temporary - vim.api.nvim_create_user_command("WordInc", function() + vim.api.nvim_create_user_command("DownInc", function() M.data.head.inc() end, { desc = "incs heading level", }) - vim.api.nvim_create_user_command("WordDec", function() + vim.api.nvim_create_user_command("DownDec", function() M.data.head.dec() end, { desc = "decs heading level", }) end +---@class down.edit.indent.Config +M.config = { +} +---@class down.edit.indent.Data M.data = { head = { atx = { inc = function(node) local text = - vim.treesitter.get_node_text(node, vim.api.nvim_get_current_buf()) + vim.treesitter.get_node_text(node, vim.api.nvim_get_current_buf()) local markers = text:match("^([#]+)") local range = { node:range() } @@ -51,7 +56,7 @@ M.data = { end, dec = function(node) local text = - vim.treesitter.get_node_text(node, vim.api.nvim_get_current_buf()) + vim.treesitter.get_node_text(node, vim.api.nvim_get_current_buf()) local markers = text:match("^([#]+)") local range = { node:range() } @@ -85,7 +90,7 @@ M.data = { end local text = - vim.treesitter.get_node_text(marker, vim.api.nvim_get_current_buf()) + vim.treesitter.get_node_text(marker, vim.api.nvim_get_current_buf()) local range = { marker:range() } if text:match("^([-]+)$") then @@ -112,7 +117,7 @@ M.data = { end local text = - vim.treesitter.get_node_text(marker, vim.api.nvim_get_current_buf()) + vim.treesitter.get_node_text(marker, vim.api.nvim_get_current_buf()) local range = { marker:range() } if text:match("^([=]+)$") then @@ -167,10 +172,10 @@ M.data = { while node:parent() do if - vim.list_contains({ - "atx_heading", - "setext_heading", - }, node:type()) + vim.list_contains({ + "atx_heading", + "setext_heading", + }, node:type()) then return true, node:type(), node end diff --git a/lua/word/mod/edit/init.lua b/lua/down/mod/edit/init.lua similarity index 93% rename from lua/word/mod/edit/init.lua rename to lua/down/mod/edit/init.lua index 550935f..c9219fc 100644 --- a/lua/word/mod/edit/init.lua +++ b/lua/down/mod/edit/init.lua @@ -1,4 +1,4 @@ -local M = require("word.mod").create("edit", { +local M = require("down.mod").create("edit", { "toc", "parse", "find", @@ -10,8 +10,8 @@ local M = require("word.mod").create("edit", { "indent", "link", }) -local word = require("word") -local config, lib, log, mod = word.cfg, word.lib, word.log, word.mod +local down = require("down") +local config, lib, log, mod = down.cfg, down.lib, down.log, down.mod M.setup = function() return { @@ -20,7 +20,7 @@ M.setup = function() } end -M.config.public = { +M.config = { silent = false, wrap = false, continue = true, ---@type boolean | nil @@ -77,8 +77,8 @@ M.data.jump = function(pattern, reverse) -- Get the line's contents line = vim.api.nvim_buf_get_lines(0, row - 1, row, false)[1] line_len = #line - if M.config.public.context > 0 and line_len > 0 then - for i = 1, M.config.public.context, 1 do + if M.config.context > 0 and line_len > 0 then + for i = 1, M.config.context, 1 do local following_line = vim.api.nvim_buf_get_lines(0, row, row + 1, false)[1] line = (following_line and line .. following_line) or line @@ -111,14 +111,14 @@ M.data.jump = function(pattern, reverse) else -- If there's not a match on the current line, keep checking line-by-line -- Update row to search next line row = (reverse and row - 1) or row + 1 - -- Get the content of the next line (if any), appending M.config.public.contextual lines if M.config.public.context > 0 + -- Get the content of the next line (if any), appending M.config.contextual lines if M.config.context > 0 line = vim.api.nvim_buf_get_lines(0, row - 1, row, false)[1] line_len = line and #line -- Since we're on the next line, cursor position no longer matters and we want to make -- sure that `col` is always < left (or > if reverse == true) col = reverse and line_len or -1 - if line and M.config.public.context > 0 and line_len > 0 then - for i = 1, M.config.public.context, 1 do + if line and M.config.context > 0 and line_len > 0 then + for i = 1, M.config.context, 1 do local following_line = vim.api.nvim_buf_get_lines(0, row, row + 1, false)[1] line = (following_line and line .. following_line) or line @@ -128,15 +128,15 @@ M.data.jump = function(pattern, reverse) left, right = M.data.find_patterns(line, pattern, reverse) else -- If the line is nil, there is no next line and the loop should stop (unless wrapping is on) - if M.config.public.wrap == true then -- If searching backwards & user wants search to wrap, go to last line in file + if M.config.wrap == true then -- If searching backwards & user wants search to wrap, go to last line in file if not already_wrapped then row = (reverse and vim.api.nvim_buf_line_count(0) + 1) or 0 already_wrapped = true else - M.config.public.continue = nil + M.config.continue = nil end else -- Otherwise, search is done - M.config.public.continue = nil + M.config.continue = nil end end end @@ -187,17 +187,17 @@ M.data.go_to_heading = function(anchor_text, reverse) end row = (reverse and row - 1) or row + 1 if row == starting_row + 1 then - M.config.public.continue = nil + M.config.continue = nil if anchor_text == nil then local message = "⬇️ Couldn't find a heading to go to!" - if not M.config.public.silent then + if not M.config.silent then vim.api.nvim_echo({ { message, "WarningMsg" } }, true, {}) end else local message = "⬇️ Couldn't find a heading matching " .. anchor_text .. "!" - if not M.config.public.silent then + if not M.config.silent then vim.api.nvim_echo({ { message, "WarningMsg" } }, true, {}) end end @@ -208,7 +208,7 @@ M.data.go_to_heading = function(anchor_text, reverse) row = (reverse and vim.api.nvim_buf_line_count(0)) or 1 in_fenced_code_block = false else - M.config.public.continue = nil + M.config.continue = nil local place = (reverse and "beginning") or "end" local preposition = (reverse and "after") or "before" local message = "⬇️ There are no more headings " @@ -288,7 +288,7 @@ M.data.changeHeadingLevel = function(change) -- Remove a hash, but only if there's more than one if not string.find(line[1], "^##") then local message = "⬇️ Can't increase this heading any more!" - if not M.config.public.silent then + if not M.config.silent then vim.api.nvim_echo({ { message, "WarningMsg" } }, true, {}) end else @@ -371,7 +371,7 @@ M.data.yankAsAnchorLink = function(full_path) else local message = "⬇️ The current line is not a heading or bracketed span!" - if not M.config.public.silent then + if not M.config.silent then vim.api.nvim_echo({ { message, "WarningMsg" } }, true, {}) end end diff --git a/lua/word/mod/edit/link/README.md b/lua/down/mod/edit/inline/README.md similarity index 100% rename from lua/word/mod/edit/link/README.md rename to lua/down/mod/edit/inline/README.md diff --git a/lua/down/mod/edit/inline/init.lua b/lua/down/mod/edit/inline/init.lua new file mode 100644 index 0000000..2309fc1 --- /dev/null +++ b/lua/down/mod/edit/inline/init.lua @@ -0,0 +1,20 @@ +local mod = require "down.mod" + +local M = mod.create("edit.inline") + +M.setup = function() + return { + loaded = true + } +end + +---@class down.edit.inline.Config +M.config = { + +} +---@class down.edit.inline.Data +M.data = { + +} + +return M diff --git a/lua/word/mod/edit/parse/README.md b/lua/down/mod/edit/link/README.md similarity index 100% rename from lua/word/mod/edit/parse/README.md rename to lua/down/mod/edit/link/README.md diff --git a/lua/word/mod/edit/link/init.lua b/lua/down/mod/edit/link/init.lua similarity index 88% rename from lua/word/mod/edit/link/init.lua rename to lua/down/mod/edit/link/init.lua index 0f12ab4..2a22ae5 100644 --- a/lua/word/mod/edit/link/init.lua +++ b/lua/down/mod/edit/link/init.lua @@ -1,7 +1,7 @@ -local word = require("word") -local lib, mod, util = word.lib, word.mod +local down = require("down") +local lib, mod, util = down.lib, down.mod -local M = Mod.create("edit.link") +local M = mod.create("edit.link") M.setup = function() return { loaded = true, @@ -12,7 +12,9 @@ M.setup = function() } end -M.config.public = { + +---@class down.edit.link.Config +M.config = { conceal = true, style = "markdown", implicit_extension = nil, @@ -27,7 +29,7 @@ M.config.public = { return text end, } ----@class link +---@class down.edit.link.Data M.data = { contains = function(start_row, start_col, end_row, end_col, cur_row, cur_col) local contained = cur_row > start_row and cur_row < end_row @@ -54,8 +56,8 @@ M.data = { local row = position[1] local lines = vim.api.nvim_buf_get_lines( 0, - row - 1 - M.config.public.context, - row + M.config.public.context, + row - 1 - M.config.context, + row + M.config.context, false ) -- Iterate through the patterns to see if there's a matching link under the cursor @@ -66,13 +68,13 @@ M.data = { -- Look for the pattern in the line(s) --link_start, link_finish, capture = string.find(lines, pattern, init) start_row, start_col, end_row, end_col, capture, match_lines = - utils.mFind( - lines, - pattern, - row - M.config.public.context, - init_row, - init_col - ) + utils.mFind( + lines, + pattern, + row - M.config.context, + init_row, + init_col + ) if start_row and link_type == "citation" then local possessor = string.gsub(capture, "'s$", "") -- Remove Saxon genitive if it's on the end of the citekey if #capture > #possessor then @@ -129,16 +131,16 @@ M.data = { if not path_text then return end - if not M.config.public.implicit_extension then + if not M.config.implicit_extension then path_text = path_text .. ".md" end else path_text = source end -- Format the replacement depending on the user's link style preference - if M.config.public.style == "wiki" then + if M.config.style == "wiki" then replacement = ( - M.config.public.name_as_source and { "[[" .. text .. "]]" } + M.config.name_as_source and { "[[" .. text .. "]]" } ) or { "[[" .. path_text .. "|" .. text .. "]]" } else replacement = { "[" .. text .. "]" .. "(" .. path_text .. ")" } @@ -231,7 +233,7 @@ M.data = { local position = vim.api.nvim_win_get_cursor(0) local row = position[1] local col = position[2] - -- If the current mode is 'normal', make link from word under cursor + -- If the current mode is 'normal', make link from down under cursor if mode == "n" and not range then -- Get the text of the line the cursor is on local line = vim.api.nvim_get_current_line() @@ -240,7 +242,7 @@ M.data = { -- Prepare the replacement local url = line:sub(url_start, url_end - 1) local replacement = ( - M.config.public.links.style == "wiki" and { "[[" .. url .. "|]]" } + M.config.links.style == "wiki" and { "[[" .. url .. "|]]" } ) or { "[]" .. "(" .. url .. ")" } -- Replace vim.api.nvim_buf_set_text( @@ -252,33 +254,33 @@ M.data = { replacement ) -- Move the cursor to the name part of the link and change mode - if M.config.public.links.style == "wiki" then + if M.config.links.style == "wiki" then vim.api.nvim_win_set_cursor(0, { row, url_end + 2 }) else vim.api.nvim_win_set_cursor(0, { row, url_start }) end vim.cmd("startinsert") else - -- Get the word under the cursor - local cursor_word = vim.fn.expand("") + -- Get the down under the cursor + local cursor_down = vim.fn.expand("") -- Make a markdown link out of the date and cursor local replacement if from_clipboard then - replacement = M.data.formatLink(cursor_word, vim.fn.getreg("+")) + replacement = M.data.formatLink(cursor_down, vim.fn.getreg("+")) else - replacement = M.data.formatLink(cursor_word) + replacement = M.data.formatLink(cursor_down) end -- If there's no replacement, stop here if not replacement then return end - -- Find the (first) position of the matched word in the line - local left, right = string.find(line, cursor_word, nil, true) - -- Make sure it's not a duplicate of the word under the cursor, and if it + -- Find the (first) position of the matched down in the line + local left, right = string.find(line, cursor_down, nil, true) + -- Make sure it's not a duplicate of the down under the cursor, and if it -- is, perform the search until a match is found whose right edge follows -- the cursor position - if cursor_word ~= "" then - for _left, _right in utils.gmatch(line, cursor_word) do + if cursor_down ~= "" then + for _left, _right in utils.gmatch(line, cursor_down) do if _right >= col then left = _left right = _right @@ -288,7 +290,7 @@ M.data = { else left, right = col + 1, col end - -- Replace the word under the cursor w/ the formatted link replacement + -- Replace the down under the cursor w/ the formatted link replacement vim.api.nvim_buf_set_text( 0, row - 1, @@ -315,9 +317,9 @@ M.data = { finish[1] = finish[1] - 1 else start = (inverted and { row - 1, col }) - or { vis[2] - 1, vis[3] - 1 + vis[4] } + or { vis[2] - 1, vis[3] - 1 + vis[4] } finish = (inverted and { vis[2] - 1, vis[3] - 1 + vis[4] }) - or { row - 1, col } + or { row - 1, col } end local start_row = (inverted and row - 1) or vis[2] - 1 local start_col = (inverted and col) or vis[3] - 1 @@ -328,7 +330,7 @@ M.data = { -- Make sure the selection is on a single line; otherwise, do nothing & throw a warning if start_row == end_row then local lines = - vim.api.nvim_buf_get_lines(0, start[1], finish[1] + 1, false) + vim.api.nvim_buf_get_lines(0, start[1], finish[1] + 1, false) -- Check if last byte is part of a multibyte character & adjust end index if so local is_multibyte_char = utils.isMultibyteChar({ @@ -352,7 +354,7 @@ M.data = { local text = table.concat(lines) local replacement = from_clipboard and M.data.formatLink(text, vim.fn.getreg("+")) - or M.data.formatLink(text) + or M.data.formatLink(text) -- If no replacement, end here if not replacement then return @@ -413,7 +415,7 @@ M.data = { followLink() passes a path and anchor (passed in or picked up from a link under the cursor) to handlePath from the paths module. If no path or anchor are passed in and there is no link under the cursor, createLink() is called to create a -link from the word under the cursor or a visual selection (if there is one). +link from the down under the cursor or a visual selection (if there is one). --]] followLink = function(args) args = args or {} @@ -425,7 +427,7 @@ link from the word under the cursor or a visual selection (if there is one). path, anchor = path, anchor else path, anchor, link_type = - M.data.getLinkPart(M.data.getLinkUnderCursor(), "source") + M.data.getLinkPart(M.data.getLinkUnderCursor(), "source") end if path then require("mkdnflow").paths.handlePath(path, anchor) @@ -433,18 +435,18 @@ link from the word under the cursor or a visual selection (if there is one). vim.api.nvim_echo({ { "⬇️ Couldn't find a matching reference label!", "WarningMsg" }, }, true, {}) - elseif M.config.public.links.create_on_follow_fail then + elseif M.config.links.create_on_follow_fail then M.data.createLink({ range = range }) end end, transformPath = function(text) if - type(M.config.public.links.transform_explicit) ~= "function" - or not M.config.public.links.transform_explicit + type(M.config.links.transform_explicit) ~= "function" + or not M.config.links.transform_explicit then return text else - return (M.config.public.links.transform_explicit(text)) + return (M.config.links.transform_explicit(text)) end end, get_ref = function(refnr, start_row) @@ -455,14 +457,14 @@ link from the word under the cursor or a visual selection (if there is one). while continue and row <= line_count do local line = vim.api.nvim_buf_get_lines(0, row - 1, row, false)[1] local start, finish, match = - string.find(line, "^(%[" .. refnr .. "%]: .*)") + string.find(line, "^(%[" .. refnr .. "%]: .*)") if match then local _, label_finish = string.find(match, "^%[.-%]: ") continue = false return string.sub(match, label_finish + 1), - row, - label_finish + 1, - finish + row, + label_finish + 1, + finish else row = row + 1 end diff --git a/lua/word/mod/edit/parse/datetime/README.md b/lua/down/mod/edit/parse/README.md similarity index 100% rename from lua/word/mod/edit/parse/datetime/README.md rename to lua/down/mod/edit/parse/README.md diff --git a/lua/word/mod/edit/parse/heading/README.md b/lua/down/mod/edit/parse/datetime/README.md similarity index 100% rename from lua/word/mod/edit/parse/heading/README.md rename to lua/down/mod/edit/parse/datetime/README.md diff --git a/lua/word/mod/edit/parse/datetime/init.lua b/lua/down/mod/edit/parse/datetime/init.lua similarity index 95% rename from lua/word/mod/edit/parse/datetime/init.lua rename to lua/down/mod/edit/parse/datetime/init.lua index b881681..b9fd621 100644 --- a/lua/word/mod/edit/parse/datetime/init.lua +++ b/lua/down/mod/edit/parse/datetime/init.lua @@ -9,7 +9,7 @@ M.setup = function() end ---@class parse.datetime.Config -M.config.public = {} +M.config = {} ---@class parse.datetime.Data ---@field date parse.datetime.Date ---@field grammar parse.datetime.Grammar diff --git a/lua/word/mod/edit/parse/link/README.md b/lua/down/mod/edit/parse/heading/README.md similarity index 100% rename from lua/word/mod/edit/parse/link/README.md rename to lua/down/mod/edit/parse/heading/README.md diff --git a/lua/word/mod/edit/parse/heading/init.lua b/lua/down/mod/edit/parse/heading/init.lua similarity index 100% rename from lua/word/mod/edit/parse/heading/init.lua rename to lua/down/mod/edit/parse/heading/init.lua diff --git a/lua/word/mod/edit/parse/init.lua b/lua/down/mod/edit/parse/init.lua similarity index 85% rename from lua/word/mod/edit/parse/init.lua rename to lua/down/mod/edit/parse/init.lua index 1fd81d7..dfadd56 100644 --- a/lua/word/mod/edit/parse/init.lua +++ b/lua/down/mod/edit/parse/init.lua @@ -1,14 +1,13 @@ ----@type word.mod +---@type down.mod local P = Mod.create("edit.parse", { "scan", "datetime", "heading" }) local p = vim.lpeg local R, V, S, C, Cc, Ct = p.R, p.V, p.S, p.C, p.Cc, p.Ct -P.config.public = {} +---@class down.edit.parse.Config +P.config = {} -P.data.data = {} - ----@class parse.public +---@class down.edit.parse.Data P.data = { header_html = function(n) pre = string.rep("#", n) @@ -31,8 +30,6 @@ P.setup = function() } end -P.load = function() end - P.maps = function() end -- local P, R, S, C, V = p.P, p.R, p.S, p.C, p.V diff --git a/lua/word/mod/edit/parse/scan/README.md b/lua/down/mod/edit/parse/link/README.md similarity index 100% rename from lua/word/mod/edit/parse/scan/README.md rename to lua/down/mod/edit/parse/link/README.md diff --git a/lua/word/mod/edit/parse/link/init.lua b/lua/down/mod/edit/parse/link/init.lua similarity index 100% rename from lua/word/mod/edit/parse/link/init.lua rename to lua/down/mod/edit/parse/link/init.lua diff --git a/lua/word/mod/edit/parse/tag/README.md b/lua/down/mod/edit/parse/scan/README.md similarity index 100% rename from lua/word/mod/edit/parse/tag/README.md rename to lua/down/mod/edit/parse/scan/README.md diff --git a/lua/word/mod/edit/parse/scan/init.lua b/lua/down/mod/edit/parse/scan/init.lua similarity index 85% rename from lua/word/mod/edit/parse/scan/init.lua rename to lua/down/mod/edit/parse/scan/init.lua index a2449f8..528b370 100644 --- a/lua/word/mod/edit/parse/scan/init.lua +++ b/lua/down/mod/edit/parse/scan/init.lua @@ -6,7 +6,7 @@ M.setup = function() } end -M.config.public = {} +M.config = {} M.data = {} diff --git a/lua/word/mod/edit/syntax/README.md b/lua/down/mod/edit/parse/tag/README.md similarity index 100% rename from lua/word/mod/edit/syntax/README.md rename to lua/down/mod/edit/parse/tag/README.md diff --git a/lua/word/mod/edit/parse/tag/init.lua b/lua/down/mod/edit/parse/tag/init.lua similarity index 100% rename from lua/word/mod/edit/parse/tag/init.lua rename to lua/down/mod/edit/parse/tag/init.lua diff --git a/lua/word/mod/edit/toc/README.md b/lua/down/mod/edit/syntax/README.md similarity index 100% rename from lua/word/mod/edit/toc/README.md rename to lua/down/mod/edit/syntax/README.md diff --git a/lua/word/mod/edit/syntax/init.lua b/lua/down/mod/edit/syntax/init.lua similarity index 99% rename from lua/word/mod/edit/syntax/init.lua rename to lua/down/mod/edit/syntax/init.lua index 7fbeaf5..63f54b0 100644 --- a/lua/word/mod/edit/syntax/init.lua +++ b/lua/down/mod/edit/syntax/init.lua @@ -1,5 +1,5 @@ -local word = require("word") -local mod, utils = word.mod, word.utils +local down = require("down") +local mod, utils = down.mod, down.utils local M = Mod.create("edit.syntax") @@ -261,7 +261,7 @@ M.data = { then -- absorb all syntax stuff -- potentially needs to be expanded upon as bad values come in - local is_keyword = vim.bo[buf].iskeyword + local is_keydown = vim.bo[buf].iskeydown local current_syntax = "" local foldmethod = vim.o.foldmethod local foldexpr = vim.o.foldexpr @@ -335,7 +335,7 @@ M.data = { end -- reset some values after including - vim.bo[buf].iskeyword = is_keyword + vim.bo[buf].iskeydown = is_keydown vim.b.current_syntax = current_syntax or "" ---@diagnostic disable-line has_syntax = string.format("syntax list %s", snip) @@ -466,7 +466,7 @@ M.data = { end, } -M.config.public = { +M.config = { -- Performance options for highlighting. -- -- These options exhibit the same behaviour as the [`concealer`](@concealer)'s. diff --git a/lua/word/mod/integration/README.md b/lua/down/mod/edit/toc/README.md similarity index 100% rename from lua/word/mod/integration/README.md rename to lua/down/mod/edit/toc/README.md diff --git a/lua/word/mod/edit/toc/init.lua b/lua/down/mod/edit/toc/init.lua similarity index 82% rename from lua/word/mod/edit/toc/init.lua rename to lua/down/mod/edit/toc/init.lua index b00beca..2447f28 100644 --- a/lua/word/mod/edit/toc/init.lua +++ b/lua/down/mod/edit/toc/init.lua @@ -1,11 +1,11 @@ -local word = require("word") -local mod, utils, log = word.mod, word.utils, word.log +local down = require("down") +local mod, utils, log = down.mod, down.utils, down.log local M = mod.create("edit.toc") M.setup = function() - -- mod.await("cmd", function(wordcmd) - -- wordcmd.add_commands_from_table({ + -- mod.await("cmd", function(downcmd) + -- downcmd.add_commands_from_table({ -- toc = { -- name = "toc", -- max_args = 1, @@ -17,14 +17,14 @@ M.setup = function() -- }) -- end) -- - -- if M.config.public.auto_toc.open then + -- if M.config.auto_toc.open then -- vim.api.nvim_create_autocmd("BufWinEnter", { -- pattern = "*.md", -- callback = function() -- vim.schedule(function() -- if vim.bo.filetype == "markdown" then -- next_open_is_auto = true - -- vim.cmd([[Word toc]]) + -- vim.cmd([[down toc]]) -- end -- end) -- end, @@ -38,7 +38,7 @@ end ---Track if the next TOC open was automatic. Used to determine if we should enter the TOC or not. local next_open_is_auto = false -M.config.public = { +M.config = { -- close the Table of Contents after an entry in the table is picked close_after_use = false, @@ -62,11 +62,11 @@ M.config.public = { -- options for automatically opening/entering the ToC window auto_toc = { - -- automatically open a ToC window when entering any `word` buffer + -- automatically open a ToC window when entering any `down` buffer open = false, -- enter an automatically opened ToC window enter = false, - -- automatically close the ToC window when there is no longer an open word buffer + -- automatically close the ToC window when there is no longer an open down buffer close = true, -- will exit nvim if the ToC is the last buffer on the screen, similar to help windows exit_nvim = true, @@ -74,7 +74,7 @@ M.config.public = { } local ui_data_of_tabpage = {} -local data_of_word_buf = {} +local data_of_down_buf = {} local toc_namespace local function upper_bound(array, v) @@ -100,14 +100,14 @@ local function get_target_location_under_cursor(ui_data) local curline = vim.api.nvim_win_get_cursor(ui_window)[1] local offset = ui_data.start_lines.offset local extmark_lookup = - data_of_word_buf[ui_data.word_buffer].extmarks[curline - offset] + data_of_down_buf[ui_data.down_buffer].extmarks[curline - offset] if not extmark_lookup then return end return vim.api.nvim_buf_get_extmark_by_id( - ui_data.word_buffer, + ui_data.down_buffer, toc_namespace, extmark_lookup, {} @@ -214,18 +214,18 @@ M.data = { return qflist_data end, - -- Update ui cursor according to word cursor + -- Update ui cursor according to down cursor update_cursor = function(ui_data) - local word_window = vim.fn.bufwinid(ui_data.word_buffer) - local word_data = data_of_word_buf[ui_data.word_buffer] + local down_window = vim.fn.bufwinid(ui_data.down_buffer) + local down_data = data_of_down_buf[ui_data.down_buffer] local ui_window = vim.fn.bufwinid(ui_data.buffer) assert(ui_window ~= -1) - local current_row_1b = vim.fn.line(".", word_window) - if word_data.last_row == current_row_1b then + local current_row_1b = vim.fn.line(".", down_window) + if down_data.last_row == current_row_1b then return end - word_data.last_row = current_row_1b + down_data.last_row = current_row_1b local start_lines = ui_data.start_lines assert(start_lines) @@ -239,9 +239,9 @@ M.data = { vim.api.nvim_win_set_cursor(ui_window, { current_toc_row, 0 }) end, - update_toc = function(toc_title, ui_data, word_buffer) + update_toc = function(toc_title, ui_data, down_buffer) local ui_buffer = ui_data.buffer - ui_data.word_buffer = word_buffer + ui_data.down_buffer = down_buffer if not vim.api.nvim_buf_is_valid(ui_buffer) then log.error("update_toc called with invalid ui buffer") @@ -249,16 +249,16 @@ M.data = { end vim.bo[ui_buffer].modifiable = true - vim.api.nvim_buf_clear_namespace(word_buffer, toc_namespace, 0, -1) + vim.api.nvim_buf_clear_namespace(down_buffer, toc_namespace, 0, -1) table.insert(toc_title, "") vim.api.nvim_buf_set_lines(ui_buffer, 0, -1, true, toc_title) - local word_data = {} - data_of_word_buf[word_buffer] = word_data + local down_data = {} + data_of_down_buf[down_buffer] = down_data local extmarks = {} - word_data.extmarks = extmarks + down_data.extmarks = extmarks local offset = vim.api.nvim_buf_line_count(ui_buffer) local start_lines = { offset = offset } @@ -266,7 +266,7 @@ M.data = { toc_query = toc_query or utils.ts_parse_query( - "word", + "down", [[ ( [(heading1_prefix)(heading2_prefix)(heading3_prefix)(heading4_prefix)(heading5_prefix)(heading6_prefix)]@prefix @@ -277,15 +277,15 @@ M.data = { )]] ) - local word_root = - M.required["integration.treesitter"].get_document_root(word_buffer) - if not word_root then + local down_root = + M.required["integration.treesitter"].get_document_root(down_buffer) + if not down_root then return end local current_capture local heading_nodes = {} - for id, node in toc_query:iter_captures(word_root, word_buffer) do + for id, node in toc_query:iter_captures(down_root, down_buffer) do local type = toc_query.captures[id] if type == "prefix" then current_capture = {} @@ -309,7 +309,7 @@ M.data = { table.insert( extmarks, vim.api.nvim_buf_set_extmark( - word_buffer, + down_buffer, toc_namespace, row_start_0b, col_start_0b, @@ -320,7 +320,7 @@ M.data = { for _, line in ipairs( vim.api.nvim_buf_get_text( - word_buffer, + down_buffer, row_start_0b, col_start_0b, row_end_0bin, @@ -346,8 +346,8 @@ M.data = { return end - local word_window = vim.fn.bufwinid(word_buffer) - if word_window == -1 then + local down_window = vim.fn.bufwinid(down_buffer) + if down_window == -1 then local toc_window = vim.fn.bufwinid(ui_data.buffer) local buf_width = nil if toc_window ~= -1 then @@ -357,27 +357,27 @@ M.data = { buf_width = nil end end - word_window = vim.api.nvim_open_win( - word_buffer, + down_window = vim.api.nvim_open_win( + down_buffer, true, { win = 0, vertical = true, width = buf_width } ) else - vim.api.nvim_set_current_win(word_window) - vim.api.nvim_set_current_buf(word_buffer) + vim.api.nvim_set_current_win(down_window) + vim.api.nvim_set_current_buf(down_buffer) end vim.api.nvim_win_set_cursor( - word_window, + down_window, { location[1] + 1, location[2] } ) - if M.config.public.close_after_use then + if M.config.close_after_use then vim.api.nvim_buf_delete(ui_buffer, { force = true }) end end, }) - if M.config.public.sync_cursorline then + if M.config.sync_cursorline then M.data.update_cursor(ui_data) end end, @@ -388,14 +388,14 @@ M.data.data = { ---@param ui_data table ---@return number get_toc_width = function(ui_data) - if type(M.config.public.fixed_width) == "number" then - return M.config.public.fixed_width + if type(M.config.fixed_width) == "number" then + return M.config.fixed_width end local max_virtcol_1bex = M.data.data.get_max_virtcol(ui_data.window) local current_winwidth = vim.api.nvim_win_get_width(ui_data.window) local new_winwidth = math.min( current_winwidth, - M.config.public.max_width, + M.config.max_width, max_virtcol_1bex - 1 ) return new_winwidth + 1 @@ -411,8 +411,8 @@ M.data.data = { end, } -local function get_word_ui(word_buffer) - local tabpage = vim.api.nvim_win_get_tabpage(vim.fn.bufwinid(word_buffer)) +local function get_down_ui(down_buffer) + local tabpage = vim.api.nvim_win_get_tabpage(vim.fn.bufwinid(down_buffer)) return ui_data_of_tabpage[tabpage] end @@ -425,13 +425,13 @@ local function unlisten_if_closed(listener) return true end - local word_buffer = ev.buf - local ui_data = get_word_ui(word_buffer) + local down_buffer = ev.buf + local ui_data = get_down_ui(down_buffer) if not ui_data or vim.fn.bufwinid(ui_data.buffer) == -1 then return end - return listener(word_buffer, ui_data) + return listener(down_buffer, ui_data) end end @@ -444,11 +444,11 @@ end local function create_ui(tabpage, split_dir, enter) assert(tabpage == vim.api.nvim_get_current_tabpage()) - toc_namespace = toc_namespace or vim.api.nvim_create_namespace("word/toc") + toc_namespace = toc_namespace or vim.api.nvim_create_namespace("down/toc") local ui_buffer, ui_window = M.required["core.ui"].create_vsplit( ("toc-%d"):format(tabpage), enter, - { ft = "word" }, + { ft = "down" }, { split = split_dir, win = 0, style = "minimal" } ) @@ -460,7 +460,7 @@ local function create_ui(tabpage, split_dir, enter) ui_wo.foldlevel = 99 ui_wo.winfixbuf = true - if M.config.public.sync_cursorline then + if M.config.sync_cursorline then ui_wo.cursorline = true end @@ -477,9 +477,9 @@ end --- should we enter the ToC window? local function enter_toc_win() - local do_enter = M.config.public.enter + local do_enter = M.config.enter if next_open_is_auto then - do_enter = M.config.public.auto_toc.enter + do_enter = M.config.auto_toc.enter end return do_enter end @@ -491,7 +491,7 @@ M.on = function(event) local toc_title = vim.split(M.data.parse_toc_macro(event.buffer) or "Table of Contents", "\n") - local word_buffer = event.buffer + local down_buffer = event.buffer if event.content and event.content[1] == "qflist" then local qflist = M.data.generate_qflist(event.buffer) @@ -511,12 +511,12 @@ M.on = function(event) return end - local tabpage = vim.api.nvim_win_get_tabpage(vim.fn.bufwinid(word_buffer)) + local tabpage = vim.api.nvim_win_get_tabpage(vim.fn.bufwinid(down_buffer)) if ui_data_of_tabpage[tabpage] then - if word_buffer == ui_data_of_tabpage[tabpage].buffer then + if down_buffer == ui_data_of_tabpage[tabpage].buffer then return end - M.data.update_toc(toc_title, ui_data_of_tabpage[tabpage], word_buffer) + M.data.update_toc(toc_title, ui_data_of_tabpage[tabpage], down_buffer) if enter_toc_win() then vim.api.nvim_set_current_win(ui_data_of_tabpage[tabpage].window) @@ -528,9 +528,9 @@ M.on = function(event) create_ui(tabpage, event.content[1] or "left", enter_toc_win()) next_open_is_auto = false - M.data.update_toc(toc_title, ui_data_of_tabpage[tabpage], word_buffer) + M.data.update_toc(toc_title, ui_data_of_tabpage[tabpage], down_buffer) - if M.config.public.fit_width then + if M.config.fit_width then vim.api.nvim_win_set_width( ui_data.window, M.data.data.get_toc_width(ui_data) @@ -554,19 +554,19 @@ M.on = function(event) }) vim.api.nvim_create_autocmd("BufWritePost", { - pattern = "*.word", + pattern = "*.down", callback = unlisten_if_closed(function(buf, ui) toc_title = vim.split(M.data.parse_toc_macro(buf) or "Table of Contents", "\n") - data_of_word_buf[buf].last_row = nil -- invalidate cursor cache + data_of_down_buf[buf].last_row = nil -- invalidate cursor cache M.data.update_toc(toc_title, ui, buf) end), }) vim.api.nvim_create_autocmd("BufEnter", { - pattern = "*.word", + pattern = "*.down", callback = unlisten_if_closed(function(buf, ui) - if buf == ui.buffer or buf == ui.word_buffer then + if buf == ui.buffer or buf == ui.down_buffer then return end @@ -577,7 +577,7 @@ M.on = function(event) }) -- Sync cursor: ToC -> content - if M.config.public.sync_cursorline then + if M.config.sync_cursorline then -- Ignore the first (fake) CursorMoved coming together with BufEnter of the ToC buffer vim.api.nvim_create_autocmd("BufEnter", { buffer = ui_data.buffer, @@ -591,7 +591,7 @@ M.on = function(event) callback = function(ev) assert(ev.buf == ui_data.buffer) - if vim.fn.bufwinid(ui_data.word_buffer) == -1 then + if vim.fn.bufwinid(ui_data.down_buffer) == -1 then return end @@ -599,12 +599,12 @@ M.on = function(event) if ui_data.cursor_start_moving then local location = get_target_location_under_cursor(ui_data) if location then - local word_window = vim.fn.bufwinid(ui_data.word_buffer) + local down_window = vim.fn.bufwinid(ui_data.down_buffer) vim.api.nvim_win_set_cursor( - word_window, + down_window, { location[1] + 1, location[2] } ) - vim.api.nvim_buf_call(ui_data.word_buffer, function() + vim.api.nvim_buf_call(ui_data.down_buffer, function() vim.cmd("normal! zz") end) end @@ -615,13 +615,13 @@ M.on = function(event) -- Sync cursor: content -> ToC vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, { - pattern = "*.word", + pattern = "*.down", callback = unlisten_if_closed(function(buf, ui) - if buf ~= ui.word_buffer then + if buf ~= ui.down_buffer then return end - if not data_of_word_buf[buf] then + if not data_of_down_buf[buf] then -- toc not yet created because BufEnter is not yet triggered return end @@ -632,14 +632,14 @@ M.on = function(event) -- When leaving the content buffer, add its last cursor position to jump list vim.api.nvim_create_autocmd("BufLeave", { - pattern = "*.word", - callback = unlisten_if_closed(function(_word_buffer, _ui_data) + pattern = "*.down", + callback = unlisten_if_closed(function(_down_buffer, _ui_data) vim.cmd("normal! m'") end), }) end - if M.config.public.auto_toc.exit_nvim then + if M.config.auto_toc.exit_nvim then vim.api.nvim_create_autocmd("WinEnter", { buffer = ui_data.buffer, callback = unlisten_if_closed(function(_, _) @@ -658,9 +658,9 @@ M.on = function(event) }) end - if M.config.public.auto_toc.close then + if M.config.auto_toc.close then vim.api.nvim_create_autocmd("BufWinLeave", { - pattern = "*.word", + pattern = "*.down", callback = unlisten_if_closed(function(_buf, ui) vim.schedule(function() if vim.fn.winnr("$") > 1 then @@ -677,7 +677,7 @@ M.on = function(event) end M.events.subscribed = { - ["core.wordcmd"] = { + ["core.downcmd"] = { [M.name] = true, }, } diff --git a/lua/word/mod/edit/todo/README.md b/lua/down/mod/edit/todo/README.md similarity index 100% rename from lua/word/mod/edit/todo/README.md rename to lua/down/mod/edit/todo/README.md diff --git a/lua/word/mod/edit/todo/init.lua b/lua/down/mod/edit/todo/init.lua similarity index 95% rename from lua/word/mod/edit/todo/init.lua rename to lua/down/mod/edit/todo/init.lua index c64be69..c964696 100644 --- a/lua/word/mod/edit/todo/init.lua +++ b/lua/down/mod/edit/todo/init.lua @@ -1,5 +1,5 @@ -local word = require("word") -local log, Ms = word.log, word.mod +local down = require("down") +local log, Ms = down.log, down.mod local M = Ms.create("edit.todo") @@ -22,13 +22,13 @@ M.load = function() }) do vim.keymap.set( "", - string.format("(word.insert.todo.todo.task-%s)", task), + string.format("(down.insert.todo.todo.task-%s)", task), M.data["task-" .. task] ) end end -M.config.public = { +M.config = { -- The default order of TODO item cycling when cycling via -- ``. -- @@ -95,7 +95,7 @@ M.config.public = { data = {} local function task_set(character, name) - return word.utils.wrap_dotrepeat(function() + return down.utils.wrap_dotrepeat(function() local buffer = vim.api.nvim_get_current_buf() local cursor = vim.api.nvim_win_get_cursor(0) @@ -212,14 +212,14 @@ M.data = { M.data.data.find_first_status_extension(item_at_cursor:named_child(1)) -- TODO(vhyrro): - -- Implement a toggleable behaviour where word can automatically convert this: + -- Implement a toggleable behaviour where down can automatically convert this: -- * (@ Mon 5th Feb) Test -- ** ( ) Test -- To this: -- * (x|@ Mon 5th Feb) Test -- ** (x) Test if not first_status_extension then - if not M.config.public.create_todo_parents then + if not M.config.create_todo_parents then return end @@ -341,7 +341,7 @@ M.data = { M.data.data.find_first_status_extension(node:named_child(1)) ---@diagnostic disable-line -- TODO: type error workaround if not first_status_extension then - if not M.config.public.create_todos then + if not M.config.create_todos then return end @@ -403,7 +403,7 @@ M.data = { end if not todo_type then - if not M.config.public.create_todos then + if not M.config.create_todos then return end @@ -443,8 +443,8 @@ M.data = { M.data.data.task_cycle( buffer, cursor[1], - M.config.public.order, - M.config.public.order_with_children + M.config.order, + M.config.order_with_children ) end, ["task-cycle-reverse"] = function() @@ -454,8 +454,8 @@ M.data = { M.data.data.task_cycle( buffer, cursor[1], - vim.fn.reverse(M.config.public.order), - vim.fn.reverse(M.config.public.order_with_children) + vim.fn.reverse(M.config.order), + vim.fn.reverse(M.config.order_with_children) ) end, } diff --git a/lua/word/mod/integration/blink/README.md b/lua/down/mod/integration/README.md similarity index 100% rename from lua/word/mod/integration/blink/README.md rename to lua/down/mod/integration/README.md diff --git a/lua/word/mod/integration/cmp/README.md b/lua/down/mod/integration/blink/README.md similarity index 100% rename from lua/word/mod/integration/cmp/README.md rename to lua/down/mod/integration/blink/README.md diff --git a/lua/word/mod/integration/blink/format.lua b/lua/down/mod/integration/blink/format.lua similarity index 100% rename from lua/word/mod/integration/blink/format.lua rename to lua/down/mod/integration/blink/format.lua diff --git a/lua/down/mod/integration/blink/init.lua b/lua/down/mod/integration/blink/init.lua new file mode 100644 index 0000000..94e954f --- /dev/null +++ b/lua/down/mod/integration/blink/init.lua @@ -0,0 +1,15 @@ +local mod = require("down.mod") + +---@type down.Mod +local M = mod.create("integration.blink") + +local has_blink, blink = pcall(require, "blink.cmp") + +---@class down.integration.blink.Config +M.config = {} +---@class down.integration.blink.Data +M.data = {} +M.data.source = require("down.mod.integration.blink.source") +M.data.format = require("down.mod.integration.blink.format") + +return M diff --git a/lua/word/mod/integration/blink/source/file.lua b/lua/down/mod/integration/blink/source/file.lua similarity index 83% rename from lua/word/mod/integration/blink/source/file.lua rename to lua/down/mod/integration/blink/source/file.lua index 8ee5446..502be5d 100644 --- a/lua/word/mod/integration/blink/source/file.lua +++ b/lua/down/mod/integration/blink/source/file.lua @@ -1,4 +1,4 @@ ----@class word.mod.integration.blink.source.FileOptions +---@class down.mod.integration.blink.source.FileOptions ---@field pre_min_len? number: min ---@field public cmd? fun(ctx: blink.cmp.Context, pre: string): string[] ---@field public pre? fun(ctx: blink.cmp.Context): string[] @@ -7,9 +7,9 @@ local vim = require("vim") local Fs = {} ---@return blink.cmp.Source ----@param opt word.mod.integration.blink.source.FileOptions +---@param opt down.mod.integration.blink.source.FileOptions function Fs:new(opt) - ---@type word.mod.integration.blink.source.FileOptions + ---@type down.mod.integration.blink.source.FileOptions opt = opt or {} return setmetatable({ pre_min_len = opt.pre_min_len or 3, @@ -18,7 +18,7 @@ function Fs:new(opt) "rg", "--no-config", "--json", - "--word-regexp", + "--down-regexp", "--ignore-case", "--", pre .. "[\\w_-]+", diff --git a/lua/word/mod/integration/blink/source/init.lua b/lua/down/mod/integration/blink/source/init.lua similarity index 94% rename from lua/word/mod/integration/blink/source/init.lua rename to lua/down/mod/integration/blink/source/init.lua index 865fdcc..7c0d1fd 100644 --- a/lua/word/mod/integration/blink/source/init.lua +++ b/lua/down/mod/integration/blink/source/init.lua @@ -48,15 +48,15 @@ function Src:get_completiosn(ctx, cb) label = completion.displayText, insertTextFormat = vim.lsp.protocol.InsertTextFormat.PlainText, insertText = completion.text, - description = "word suggestion", + description = "down suggestion", textEdit = completion.textEdit, filterText = completion.filterText, cursor_column = completion.cursor_column, - source_name = "word", + source_name = "down", documentation = completion.text, blink_render = { render_icon = "", - render_name = "Word", + render_name = "down", }, documentation = completion.text, } diff --git a/lua/word/mod/integration/coq/README.md b/lua/down/mod/integration/cmp/README.md similarity index 100% rename from lua/word/mod/integration/coq/README.md rename to lua/down/mod/integration/cmp/README.md diff --git a/lua/down/mod/integration/cmp/init.lua b/lua/down/mod/integration/cmp/init.lua new file mode 100644 index 0000000..b4a4e9a --- /dev/null +++ b/lua/down/mod/integration/cmp/init.lua @@ -0,0 +1,23 @@ +local mod = require "down.mod" + +local M = mod.create("integration.cmp") + +local has_cmp, cmp = pcall(require, "cmp") + +---@class down.integration.cmp.Data +M.data = { + +} +---@class down.integration.cmp.Config +M.config = { + +} + +M.setup = function() + return { + loaded = true + } +end + + +return M diff --git a/lua/word/mod/integration/fzf/README.md b/lua/down/mod/integration/coq/README.md similarity index 100% rename from lua/word/mod/integration/fzf/README.md rename to lua/down/mod/integration/coq/README.md diff --git a/lua/word/mod/integration/coq/init.lua b/lua/down/mod/integration/coq/init.lua similarity index 100% rename from lua/word/mod/integration/coq/init.lua rename to lua/down/mod/integration/coq/init.lua diff --git a/lua/word/mod/integration/lualine/README.md b/lua/down/mod/integration/fzf/README.md similarity index 100% rename from lua/word/mod/integration/lualine/README.md rename to lua/down/mod/integration/fzf/README.md diff --git a/lua/down/mod/integration/fzf/init.lua b/lua/down/mod/integration/fzf/init.lua new file mode 100644 index 0000000..2ad86e8 --- /dev/null +++ b/lua/down/mod/integration/fzf/init.lua @@ -0,0 +1,6 @@ +local mod = require("down.mod") + +---@type down.Mod +local F = mod.create("integration.fzf") + +return F diff --git a/lua/word/mod/integration/init.lua b/lua/down/mod/integration/init.lua similarity index 88% rename from lua/word/mod/integration/init.lua rename to lua/down/mod/integration/init.lua index 1126d78..cc7fcae 100644 --- a/lua/word/mod/integration/init.lua +++ b/lua/down/mod/integration/init.lua @@ -1,10 +1,10 @@ ---TODO: imelement -local E = require('word.mod').create('integration') +local E = require('down.mod').create('integration') --TODO: implement config to initialize sub integrations depending on user config ----@class word.integration.Config -E.config.public = { +---@class down.integration.Config +E.config = { ---@brief List of integrations to disable (relative to the integration dir) disabled = { @@ -16,7 +16,7 @@ E.config.public = { } } ----@class word.integration.Data +---@class down.integration.Data E.data = { } @@ -45,7 +45,7 @@ end --- Generic setup function for integration submodules --- @param ext string: the integration to setup --- @param req table: the modules required by the integration module ---- @return word.mod.Setup +--- @return down.mod.Setup E.data.setup = function(ext, req) local ok, e = E.data.has(ext) if ok then return { diff --git a/lua/word/mod/integration/telescope/README.md b/lua/down/mod/integration/lualine/README.md similarity index 100% rename from lua/word/mod/integration/telescope/README.md rename to lua/down/mod/integration/lualine/README.md diff --git a/lua/down/mod/integration/lualine/init.lua b/lua/down/mod/integration/lualine/init.lua new file mode 100644 index 0000000..45a838f --- /dev/null +++ b/lua/down/mod/integration/lualine/init.lua @@ -0,0 +1,5 @@ +local mod = require("down.mod") +---@type down.Mod +local L = mod.create("integration.lualine") + +return L diff --git a/lua/word/mod/integration/treesitter/README.md b/lua/down/mod/integration/telescope/README.md similarity index 100% rename from lua/word/mod/integration/treesitter/README.md rename to lua/down/mod/integration/telescope/README.md diff --git a/lua/down/mod/integration/telescope/init.lua b/lua/down/mod/integration/telescope/init.lua new file mode 100644 index 0000000..5ecf8ba --- /dev/null +++ b/lua/down/mod/integration/telescope/init.lua @@ -0,0 +1,96 @@ +local mod = require("down.mod") +local M = mod.create("integration.telescope") +local tok, t = pcall(require, "telescope") + +local k = vim.keymap.set + +M.setup = function() + if tok then + return { + loaded = true, + requires = { "cmd", "workspace" }, + } + else + return { + loaded = false, + } + end +end + +---@class down.integration.telescope.Data +M.data = { + picker_names = { + "linkable", + "files", + -- "insert_link", + -- "insert_file_link", + -- "search_headings", + -- "find_project_tasks", + -- "find_aof_project_tasks", + -- "find_aof_tasks", + -- "find_context_tasks", + "workspace", + -- "backlinks.file_backlinks", + -- "backlinks.header_backlinks", + }, +} +---@class down.integration.telescope.Config +M.config = {} +M.data.pickers = function() + local r = {} + for _, pic in ipairs(M.data.picker_names) do + local ht, te = pcall(require, "telescope._extensions.down.picker." .. pic) + if ht then + r[pic] = te + end + r[pic] = require("telescope._extensions.down.picker." .. pic) + end + return r +end +M.events.subscribed = { + cmd = { + ["integration.telescope.find.files"] = true, + ["integration.telescope.find.workspace"] = true, + }, +} +M.load = function() + if tok then + mod.await("cmd", function(cmd) + cmd.add_commands_from_table({ + find = { + args = 0, + name = "integration.telescope.find", + subcommands = { + files = { + name = "integration.telescope.find.files", + args = 0, + }, + workspace = { + name = "integration.telescope.find.workspace", + args = 0, + }, + }, + }, + }) + end) + assert(tok, t) + t.load_extension("down") + for _, pic in ipairs(M.data.picker_names) do + -- t.load_extension(pic) + k("n", "down.telescope." .. pic .. "", M.data.pickers()[pic]) + end + else + return + end +end + +M.on = function(event) + if event.type == "integration.telescope.find.files" then + vim.cmd([[Telescope down find_down]]) + elseif event.type == "integration.telescope.find.workspace" then + vim.cmd([[Telescope down workspace]]) + require("telescope._extensions.down.picker.workspace")() + end +end + +return M diff --git a/lua/word/mod/integration/telescope/new.lua b/lua/down/mod/integration/telescope/new.lua similarity index 82% rename from lua/word/mod/integration/telescope/new.lua rename to lua/down/mod/integration/telescope/new.lua index 1b073cf..88839cc 100644 --- a/lua/word/mod/integration/telescope/new.lua +++ b/lua/down/mod/integration/telescope/new.lua @@ -32,11 +32,11 @@ M.data.data = { M.pickers = function() local r = {} for _, pic in ipairs(M.data.data.picker_names) do - local ht, te = pcall(require, "telescope._extensions.word.picker."..pic) + local ht, te = pcall(require, "telescope._extensions.down.picker."..pic) if ht then r[pic] = te end - r[pic] = require("telescope._extensions.word.picker."..pic) + r[pic] = require("telescope._extensions.down.picker."..pic) end return r end @@ -114,33 +114,33 @@ M.load = function() end) local hast, t = pcall(require, "telescope") assert(hast, t) - t.load_extension("word") + t.load_extension("down") for _, pic in ipairs(M.data.data.picker_names) do -- t.load_extension(pic) - k("n", "word.telescope."..pic.."", M.pickers()[pic]) + k("n", "down.telescope."..pic.."", M.pickers()[pic]) end end M.on = function(event) if event.type == "integration.telescope" then elseif event.type == "integration.telescope.link" then - vim.cmd [[Telescope word find_word]] + vim.cmd [[Telescope down find_down]] elseif event.type == "integration.telescope.workspace" then - vim.cmd [[Telescope word find_word]] + vim.cmd [[Telescope down find_down]] elseif event.type == "integration.telescope.actions" then - vim.cmd [[Telescope word find_word]] + vim.cmd [[Telescope down find_down]] elseif event.type == "integration.telescope.commands" then - vim.cmd [[Telescope word find_word]] + vim.cmd [[Telescope down find_down]] elseif event.type == "integration.telescope.todo" then - vim.cmd [[Telescope word find_word]] + vim.cmd [[Telescope down find_down]] elseif event.type == "integration.telescope.lsp" then - vim.cmd [[Telescope word find_word]] + vim.cmd [[Telescope down find_down]] elseif event.type == "integration.telescope.files" then - vim.cmd [[Telescope word find_word]] - require("telescope._extensions.word.picker.files")() + vim.cmd [[Telescope down find_down]] + require("telescope._extensions.down.picker.files")() elseif event.type == "integration.telescope.workspace" then - vim.cmd [[Telescope word workspace]] - require("telescope._extensions.word.picker.workspace")() + vim.cmd [[Telescope down workspace]] + require("telescope._extensions.down.picker.workspace")() end end diff --git a/lua/word/mod/integration/trouble/README.md b/lua/down/mod/integration/treesitter/README.md similarity index 100% rename from lua/word/mod/integration/trouble/README.md rename to lua/down/mod/integration/treesitter/README.md diff --git a/lua/word/mod/integration/treesitter/init.lua b/lua/down/mod/integration/treesitter/init.lua similarity index 91% rename from lua/word/mod/integration/treesitter/init.lua rename to lua/down/mod/integration/treesitter/init.lua index a7c5dfc..26f612b 100644 --- a/lua/word/mod/integration/treesitter/init.lua +++ b/lua/down/mod/integration/treesitter/init.lua @@ -1,5 +1,5 @@ -local word = require("word") -local lib, log, mod, utils = word.lib, word.log, word.mod, word.utils +local down = require("down") +local lib, log, mod, utils = down.lib, down.log, down.mod, down.utils local vt = vim.treesitter local q = vt.query @@ -8,9 +8,10 @@ local u = require("nvim-treesitter.utils") local loc = require("nvim-treesitter.locals") local tsu = require("nvim-treesitter.ts_utils") -local M = Mod.create("integration.treesitter") +local M = mod.create("integration.treesitter") -M.data.data = { +---@class down.integration.treesitter.Data +M.data = { ts_utils = nil, heading = [[ [ @@ -64,6 +65,15 @@ M.data.data = { } M.setup = function() + -- mod.await("cmd", function(downcmd) + -- downcmd.add_commands_from_table({ + -- treesitter = { + -- args = 0, + -- name = "treesitter", + -- }, + -- }) + -- end) + return { loaded = true, requires = { "edit.hl" } } end @@ -77,30 +87,21 @@ M.load = function() local parser_configs = require("nvim-treesitter.parsers").get_parser_configs() - -- parser_configs.word = { - -- install_info = M.config.parser_configs.word, + -- parser_configs.down = { + -- install_info = M.config.parser_configs.down, -- } -- parser_configs.markdown_inline = { -- install_info = M.config.parser_configs.markdown_inline, -- } - Mod.await("cmd", function(wordcmd) - wordcmd.add_commands_from_table({ - treesitter = { - args = 0, - name = "treesitter", - }, - }) - end) - -- luacheck: pop -- vim.api.nvim_create_autocmd("BufEnter", { -- pattern = "*.md", -- once = true, -- callback = function() - -- M.data.parser_path = vim.api.nvim_get_runtime_file("parser/word.so", false)[1] + -- M.data.parser_path = vim.api.nvim_get_runtime_file("parser/down.so", false)[1] -- -- if M.data.parser_path then -- return @@ -108,11 +109,11 @@ M.load = function() -- -- if init.config.install_parsers then -- require("nvim-treesitter.install").commands.TSInstallSync["run!"]("markdown", "markdown_inilne") - -- init.public.parser_path = vim.api.nvim_get_runtime_file("parser/word.so", false)[1] + -- init.public.parser_path = vim.api.nvim_get_runtime_file("parser/down.so", false)[1] -- else -- assert( -- false, - -- "word's parser is not installed! Run `:word sync-parsers` to install it, then restart Neovim." + -- "down's parser is not installed! Run `:down sync-parsers` to install it, then restart Neovim." -- ) -- end -- end, @@ -122,39 +123,39 @@ M.load = function() vim.keymap.set( "", - "(word.treesitter.next.heading)", - lib.wrap(M.data.goto_next_query_match, M.data.data.oeading_query) + "(down.treesitter.next.heading)", + lib.wrap(M.data.goto_next_query_match, M.data.leading_query) ) vim.keymap.set( "", - "(word.treesitter.next.link)", - lib.wrap(M.data.goto_next_query_match, M.data.data.oink_query) + "(down.treesitter.next.link)", + lib.wrap(M.data.goto_next_query_match, M.data.link_query) ) vim.keymap.set( "", - "(word.treesitter.previous.heading)", - lib.wrap(M.data.goto_previous_query_match, M.data.data.oeading_query) + "(down.treesitter.previous.heading)", + lib.wrap(M.data.goto_previous_query_match, M.data.leading_query) ) vim.keymap.set( "", - "(word.treesitter.previous.link)", - lib.wrap(M.data.goto_previous_query_match, M.data.data.oink_query) + "(down.treesitter.previous.link)", + lib.wrap(M.data.goto_previous_query_match, M.data.link_query) ) end -M.config.public = { +M.config = { --- If true will auto-configure the parsers to use the recommended setup. -- Set to false only if you know what you're doing, or if the setting messes -- with your personal configuration. configure_parsers = true, - --- If true will automatically install word parsers if they are not present. + --- If true will automatically install down parsers if they are not present. -- install_parsers = true, --- Configurations for each parser as required by `nvim-treesitter`. -- If you would like to tweak your parser configs you may do so here. -- parser_configs = { - -- Configuration for the mainline word parser. - -- word = { - -- url = "https://github.com/nvim-word/tree-sitter-word", + -- Configuration for the mainline down parser. + -- down = { + -- url = "https://github.com/nvim-down/tree-sitter-down", -- files = { "src/parser.c", "src/scanner.cc" }, -- branch = "main", -- revision = "6348056b999f06c2c7f43bb0a5aa7cfde5302712", @@ -162,7 +163,7 @@ M.config.public = { -- Configuration for the metadata parser (used to parse the contents -- of `@document.meta` blocks). -- markdown_inline = { - -- url = "https://github.com/nvim-word/tree-sitter-word-meta", + -- url = "https://github.com/nvim-down/tree-sitter-down-meta", -- files = { "src/parser.c" }, -- branch = "main", -- revision = "a479d1ca05848d0b51dd25bc9f71a17e0108b240", @@ -207,7 +208,7 @@ M.data = { --- Gives back an instance of `nvim-treesitter.ts_utils` ---@return table #`nvim-treesitter.ts_utils` get_ts_utils = function() - return M.data.data.os_utils + return M.data.os_utils end, --- Jumps to the next match of a query in the current buffer ---@param query_string string Query with `@next-segment` captures @@ -234,7 +235,7 @@ M.data = { -- Find and go to the first matching node that starts after the current cursor position. if (start_line == line_number and start_col > col_number) or start_line > line_number then - M.data.data.os_utils.goto_node(node) ---@diagnostic disable-line -- TODO: type error workaround + M.data.os_utils.goto_node(node) ---@diagnostic disable-line -- TODO: type error workaround return end end @@ -276,7 +277,7 @@ M.data = { ::continue:: end if final_node then - M.data.data.os_utils.goto_node(final_node) ---@diagnostic disable-line -- TODO: type error workaround + M.data.os_utils.goto_node(final_node) ---@diagnostic disable-line -- TODO: type error workaround end end, --- Gets all nodes of a given type from the AST @@ -305,7 +306,7 @@ M.data = { ---Gets all nodes of a given type from the AST ---@param node_type string #The type of node to filter out ---@param path string path to the file to parse - ---@param filetype string? file type of the file or `word` if omitted + ---@param filetype string? file type of the file or `down` if omitted get_all_nodes_in_file = function(node_type, path, filetype) path = vim.fs.normalize(path) if not filetype then @@ -796,13 +797,13 @@ M.data = { get_document_metadata = function(source, no_trim) source = source or 0 - local word_parser, iter_src = M.data.get_ts_parser(source) - if not word_parser then + local down_parser, iter_src = M.data.get_ts_parser(source) + if not down_parser then return end - local word_tree = word_parser:parse()[1] - if not word_tree then + local down_tree = down_parser:parse()[1] + if not down_tree then return end @@ -861,7 +862,7 @@ M.data = { }) end - local word_query = utils.ts_parse_query( + local down_query = utils.ts_parse_query( "markdown", [[ (document @@ -886,8 +887,8 @@ M.data = { ) local meta_node - for id, node in word_query:iter_captures(word_tree:root(), iter_src) do - if word_query.captures[id] == "tag_name" then + for id, node in down_query:iter_captures(down_tree:root(), iter_src) do + if down_query.captures[id] == "tag_name" then local tag_name = trim(M.data.get_node_text(node, iter_src)) if tag_name == "document.meta" then meta_node = node:next_named_sibling() or vim.NIL @@ -928,7 +929,7 @@ M.data = { return result end, - --- Parses a query and automatically executes it for word + --- Parses a query and automatically executes it for down ---@param query_string string #The query string ---@param callback function #The callback to execute with all values returned by ---`Query:iter_captures()`. When callback returns true, this function returns early @@ -937,13 +938,13 @@ M.data = { ---@param finish number? #The end line for the query execute_query = function(query_string, callback, source, start, finish) local query = utils.ts_parse_query("markdown", query_string) - local word_parser, iter_src = M.data.get_ts_parser(source) + local down_parser, iter_src = M.data.get_ts_parser(source) - if not word_parser then + if not down_parser then return false end - local root = word_parser:parse()[1]:root() + local root = down_parser:parse()[1]:root() for id, node, metadata in query:iter_captures(root, iter_src, start, finish) do if callback(query, id, node, metadata) == true then return true @@ -953,13 +954,13 @@ M.data = { return true end, - ---Create a word TS parser from the given source + ---Create a down TS parser from the given source ---@param source string | number | PathlibPath file path or buf number or 0 for current buffer - ---@return vim.treesitter.LanguageTree? word_parser + ---@return vim.treesitter.LanguageTree? down_parser ---@return string | number iter_src the corresponding source that you must pass to ---`iter_query()`, either the full file text, or the buffer number get_ts_parser = function(source) - local word_parser + local down_parser local iter_src if type(source) ~= "string" and type(source) ~= "number" then source = tostring(source) @@ -970,27 +971,27 @@ M.data = { source = vim.uri_to_bufnr(vim.uri_from_fname(source)) else iter_src = io.open(source, "r"):read("*a") - word_parser = vim.treesitter.get_string_parser(iter_src, "markdown") + down_parser = vim.treesitter.get_string_parser(iter_src, "markdown") end end if type(source) == "number" then if source == 0 then source = vim.api.nvim_get_current_buf() end - word_parser = vim.treesitter.get_parser(source, "markdown") + down_parser = vim.treesitter.get_parser(source, "markdown") iter_src = source end - return word_parser, iter_src + return down_parser, iter_src end, } --- this fixes the problem of installing word ts parsers on macOS without resorting to using gcc -local function install_word_ts() +-- this fixes the problem of installing down ts parsers on macOS without resorting to using gcc +local function install_down_ts() local install = require("nvim-treesitter.install") if vim.fn.has("macunix") == 1 then - -- https://github.com/nvim-word/tree-sitter-word/issues/7 + -- https://github.com/nvim-down/tree-sitter-down/issues/7 -- (we have to force clang to c++11 mode on macOS manually) local shell = require("nvim-treesitter.shell_command_selectors") @@ -1009,7 +1010,7 @@ local function install_word_ts() end install.compilers = { cc } - -- install word parsers + -- install down parsers local ok, err = pcall(function() install.commands.TSInstallSync["run!"]("markdown") end) @@ -1029,10 +1030,10 @@ end M.on = function(event) if event.split_type[2] == "sync" then - local ok, err = pcall(install_word_ts) + local ok, err = pcall(install_down_ts) if not ok then - utils.notify(string.format([[Unable to auto-install word parser: %s]], err), vim.log.levels.WARN) + utils.notify(string.format([[Unable to auto-install down parser: %s]], err), vim.log.levels.WARN) end local install = require("nvim-treesitter.install") diff --git a/lua/word/mod/lsp/README.md b/lua/down/mod/integration/trouble/README.md similarity index 100% rename from lua/word/mod/lsp/README.md rename to lua/down/mod/integration/trouble/README.md diff --git a/lua/word/mod/integration/trouble/init.lua b/lua/down/mod/integration/trouble/init.lua similarity index 62% rename from lua/word/mod/integration/trouble/init.lua rename to lua/down/mod/integration/trouble/init.lua index e9ff6b7..8cf03b4 100644 --- a/lua/word/mod/integration/trouble/init.lua +++ b/lua/down/mod/integration/trouble/init.lua @@ -1,9 +1,9 @@ -local mod = require "word.mod" ----@alias word.integration.trouble.Trouble word.Mod +local mod = require "down.mod" +---@alias down.integration.trouble.Trouble down.Mod local T = mod.create("integration.trouble") local tok, t = pcall(require, "trouble") ----@class word.integration.trouble.Data +---@class down.integration.trouble.Data T.data = { } @@ -23,8 +23,8 @@ T.setup = function() end end ----@class word.integration.trouble.Config -T.config.public = { +---@class down.integration.trouble.Config +T.config = { } diff --git a/lua/word/mod/lsp/command/README.md b/lua/down/mod/lsp/README.md similarity index 100% rename from lua/word/mod/lsp/command/README.md rename to lua/down/mod/lsp/README.md diff --git a/lua/word/mod/lsp/completion/documentation/README.md b/lua/down/mod/lsp/command/README.md similarity index 100% rename from lua/word/mod/lsp/completion/documentation/README.md rename to lua/down/mod/lsp/command/README.md diff --git a/lua/word/mod/lsp/command/init.lua b/lua/down/mod/lsp/command/init.lua similarity index 96% rename from lua/word/mod/lsp/command/init.lua rename to lua/down/mod/lsp/command/init.lua index 651d704..023c443 100644 --- a/lua/word/mod/lsp/command/init.lua +++ b/lua/down/mod/lsp/command/init.lua @@ -10,7 +10,7 @@ function C.setup() end ---@class lsp.command.Config -C.config.public = { +C.config = { } ---@class lsp.command.Data @@ -73,7 +73,7 @@ C.data = { } end } -C.config.public = { +C.config = { enable = true, } diff --git a/lua/word/mod/lsp/completion/README.md b/lua/down/mod/lsp/completion/README.md similarity index 100% rename from lua/word/mod/lsp/completion/README.md rename to lua/down/mod/lsp/completion/README.md diff --git a/lua/word/mod/lsp/completion/signature/README.md b/lua/down/mod/lsp/completion/documentation/README.md similarity index 100% rename from lua/word/mod/lsp/completion/signature/README.md rename to lua/down/mod/lsp/completion/documentation/README.md diff --git a/lua/word/mod/lsp/completion/documentation/init.lua b/lua/down/mod/lsp/completion/documentation/init.lua similarity index 67% rename from lua/word/mod/lsp/completion/documentation/init.lua rename to lua/down/mod/lsp/completion/documentation/init.lua index b02d85d..bb11848 100644 --- a/lua/word/mod/lsp/completion/documentation/init.lua +++ b/lua/down/mod/lsp/completion/documentation/init.lua @@ -1,4 +1,4 @@ -local D = require("word.mod").create("lsp.completion.documentation") +local D = require("down.mod").create("lsp.completion.documentation") D.setup = function() return { diff --git a/lua/word/mod/lsp/completion/init.lua b/lua/down/mod/lsp/completion/init.lua similarity index 97% rename from lua/word/mod/lsp/completion/init.lua rename to lua/down/mod/lsp/completion/init.lua index c135d81..404684e 100644 --- a/lua/word/mod/lsp/completion/init.lua +++ b/lua/down/mod/lsp/completion/init.lua @@ -1,6 +1,6 @@ -local util = require("word.mod.lsp.completion.util") -local word = require("word") -local mod, utils, log = word.mod, word.utils, word.log +local util = require("down.mod.lsp.completion.util") +local down = require("down") +local mod, utils, log = down.mod, down.utils, down.log local ls = vim.lsp local Path = require("pathlib") @@ -11,7 +11,7 @@ local search local dirutils, dirman, link_utils, treesitter ---@class lsp.completion.Config -M.config.public = { +M.config = { enable = true } @@ -669,11 +669,11 @@ M.data = { end, } -M.config.public = { +M.config = { enable = true, engine = nil, - -- The identifier for the word source. + -- The identifier for the down source. name = "[wd]", } @@ -688,11 +688,11 @@ M.setup = function() } end ----@class word.completion_engine +---@class down.completion_engine ---@field create_source function M.data = { - ---@type word.completion_engine + ---@type down.completion_engine engine = nil, --- Get a list of all markdown files in current workspace. Returns { workspace_path, markdown_files } @@ -935,28 +935,28 @@ M.data = {} M.load = function() -- If we have not defined an engine then bail - if not M.config.public.engine then + if not M.config.engine then log.error("No engine specified, aborting...") return end -- check if a custom completion M is provided if - type(M.config.public.engine) == "table" - and M.config.public.engine["mod_name"] + type(M.config.engine) == "table" + and M.config.engine["mod_name"] then - local completion_mod = M.config.public.engine == "nvim-compe" + local completion_mod = M.config.engine == "nvim-compe" and Mod.load_mod("core.integrations.nvim-compe") mod.load_mod_as_dependency("core.integrations.nvim-compe", M.name, {}) M.data.engine = mod.get_mod("core.integrations.nvim-compe") elseif - M.config.public.engine == "nvim-cmp" + M.config.engine == "nvim-cmp" and mod.load_mod("core.integrations.nvim-cmp") then mod.load_mod_as_dependency("core.integrations.nvim-cmp", M.name, {}) M.data.engine = mod.get_mod("core.integrations.nvim-cmp") elseif - M.config.public.engine == "coq_nvim" + M.config.engine == "coq_nvim" and mod.load_mod("core.integrations.coq_nvim") then mod.load_mod_as_dependency("core.integrations.coq_nvim", M.name, {}) @@ -964,7 +964,7 @@ M.load = function() else log.error( "Unable to load completion M -", - M.config.public.engine, + M.config.engine, "is not a recognized engine." ) return @@ -982,13 +982,13 @@ M.load = function() -- Create the integration engine's source M.data.engine.create_source({ - completions = M.config.public.completions, + completions = M.config.completions, }) -- ts = mod.required["integration.treesitter"] end M.data = { - ---Query word SE for a list of categories, and format them into completion items + ---Query down SE for a list of categories, and format them into completion items make_category_suggestions = function() if not search then M.data.load_search() @@ -1010,7 +1010,7 @@ M.data = { end, } ----@class lsp.completion : word.completion_engine +---@class lsp.completion : down.completion_engine M.data = { create_source = function() -- these numbers come from: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionItemKind diff --git a/lua/word/mod/lsp/completion/inline/init.lua b/lua/down/mod/lsp/completion/inline/init.lua similarity index 100% rename from lua/word/mod/lsp/completion/inline/init.lua rename to lua/down/mod/lsp/completion/inline/init.lua diff --git a/lua/word/mod/lsp/completion/inline/value/init.lua b/lua/down/mod/lsp/completion/inline/value/init.lua similarity index 100% rename from lua/word/mod/lsp/completion/inline/value/init.lua rename to lua/down/mod/lsp/completion/inline/value/init.lua diff --git a/lua/word/mod/lsp/declaration/README.md b/lua/down/mod/lsp/completion/signature/README.md similarity index 100% rename from lua/word/mod/lsp/declaration/README.md rename to lua/down/mod/lsp/completion/signature/README.md diff --git a/lua/word/mod/lsp/completion/signature/init.lua b/lua/down/mod/lsp/completion/signature/init.lua similarity index 96% rename from lua/word/mod/lsp/completion/signature/init.lua rename to lua/down/mod/lsp/completion/signature/init.lua index 9766af1..85ef1ac 100644 --- a/lua/word/mod/lsp/completion/signature/init.lua +++ b/lua/down/mod/lsp/completion/signature/init.lua @@ -1,9 +1,9 @@ -local mod = require "word.mod" +local mod = require "down.mod" local M = mod.create("lsp.completion.signature") ---@class lsp.completion.signature.Config -M.config.public = { +M.config = { enable = true, } diff --git a/lua/word/mod/lsp/completion/util.lua b/lua/down/mod/lsp/completion/util.lua similarity index 100% rename from lua/word/mod/lsp/completion/util.lua rename to lua/down/mod/lsp/completion/util.lua diff --git a/lua/word/mod/lsp/definition/README.md b/lua/down/mod/lsp/declaration/README.md similarity index 100% rename from lua/word/mod/lsp/definition/README.md rename to lua/down/mod/lsp/declaration/README.md diff --git a/lua/word/mod/lsp/declaration/init.lua b/lua/down/mod/lsp/declaration/init.lua similarity index 90% rename from lua/word/mod/lsp/declaration/init.lua rename to lua/down/mod/lsp/declaration/init.lua index 9ca9eb1..d0ddca4 100644 --- a/lua/word/mod/lsp/declaration/init.lua +++ b/lua/down/mod/lsp/declaration/init.lua @@ -9,7 +9,7 @@ function I.setup() } end -I.config.public = { +I.config = { enable = true } diff --git a/lua/word/mod/lsp/document/README.md b/lua/down/mod/lsp/definition/README.md similarity index 100% rename from lua/word/mod/lsp/document/README.md rename to lua/down/mod/lsp/definition/README.md diff --git a/lua/word/mod/lsp/definition/init.lua b/lua/down/mod/lsp/definition/init.lua similarity index 88% rename from lua/word/mod/lsp/definition/init.lua rename to lua/down/mod/lsp/definition/init.lua index ed90701..4b8d048 100644 --- a/lua/word/mod/lsp/definition/init.lua +++ b/lua/down/mod/lsp/definition/init.lua @@ -9,7 +9,7 @@ function I.setup() } end -I.config.public = {} +I.config = {} I.data = {} diff --git a/lua/word/mod/lsp/document/action/README.md b/lua/down/mod/lsp/document/README.md similarity index 100% rename from lua/word/mod/lsp/document/action/README.md rename to lua/down/mod/lsp/document/README.md diff --git a/lua/word/mod/lsp/document/color/README.md b/lua/down/mod/lsp/document/action/README.md similarity index 100% rename from lua/word/mod/lsp/document/color/README.md rename to lua/down/mod/lsp/document/action/README.md diff --git a/lua/word/mod/lsp/document/action/init.lua b/lua/down/mod/lsp/document/action/init.lua similarity index 99% rename from lua/word/mod/lsp/document/action/init.lua rename to lua/down/mod/lsp/document/action/init.lua index a33985b..bb9f33d 100644 --- a/lua/word/mod/lsp/document/action/init.lua +++ b/lua/down/mod/lsp/document/action/init.lua @@ -10,7 +10,7 @@ function M.setup() end ---@class lsp.document.action.Config -M.config.public = { enable = true } +M.config = { enable = true } ---@class lsp.document.action.Data M.data = { diff --git a/lua/word/mod/lsp/document/fold/README.md b/lua/down/mod/lsp/document/color/README.md similarity index 100% rename from lua/word/mod/lsp/document/fold/README.md rename to lua/down/mod/lsp/document/color/README.md diff --git a/lua/word/mod/lsp/document/color/init.lua b/lua/down/mod/lsp/document/color/init.lua similarity index 100% rename from lua/word/mod/lsp/document/color/init.lua rename to lua/down/mod/lsp/document/color/init.lua diff --git a/lua/word/mod/lsp/document/diagnostic/README.md b/lua/down/mod/lsp/document/diagnostic/README.md similarity index 100% rename from lua/word/mod/lsp/document/diagnostic/README.md rename to lua/down/mod/lsp/document/diagnostic/README.md diff --git a/lua/word/mod/lsp/document/diagnostic/init.lua b/lua/down/mod/lsp/document/diagnostic/init.lua similarity index 98% rename from lua/word/mod/lsp/document/diagnostic/init.lua rename to lua/down/mod/lsp/document/diagnostic/init.lua index 69ea005..7fadb53 100644 --- a/lua/word/mod/lsp/document/diagnostic/init.lua +++ b/lua/down/mod/lsp/document/diagnostic/init.lua @@ -7,7 +7,7 @@ M.setup = function() end ---@class lsp.document.diagnostic.Config -M.config.public = { +M.config = { } diff --git a/lua/word/mod/lsp/document/format/README.md b/lua/down/mod/lsp/document/fold/README.md similarity index 100% rename from lua/word/mod/lsp/document/format/README.md rename to lua/down/mod/lsp/document/fold/README.md diff --git a/lua/word/mod/lsp/document/fold/init.lua b/lua/down/mod/lsp/document/fold/init.lua similarity index 100% rename from lua/word/mod/lsp/document/fold/init.lua rename to lua/down/mod/lsp/document/fold/init.lua diff --git a/lua/word/mod/lsp/document/highlight/README.md b/lua/down/mod/lsp/document/format/README.md similarity index 100% rename from lua/word/mod/lsp/document/highlight/README.md rename to lua/down/mod/lsp/document/format/README.md diff --git a/lua/word/mod/lsp/document/format/init.lua b/lua/down/mod/lsp/document/format/init.lua similarity index 98% rename from lua/word/mod/lsp/document/format/init.lua rename to lua/down/mod/lsp/document/format/init.lua index f3ecb80..223cdbd 100644 --- a/lua/word/mod/lsp/document/format/init.lua +++ b/lua/down/mod/lsp/document/format/init.lua @@ -1,7 +1,7 @@ local Path = require("plenary.path") -local word = require("word") -local mod = word.mod -local log = word.log +local down = require("down") +local mod = down.mod +local log = down.log local M = Mod.create("lsp.document.format") @@ -185,7 +185,7 @@ M.data = { vim.api.nvim_buf_delete(buf, {}) vim.lsp.util.apply_workspace_edit(wsEdit, "utf-8") vim.notify( - ("[word] renamed %s to %s\nChanged %d links across %d files."):format( + ("[down] renamed %s to %s\nChanged %d links across %d files."):format( current_path, new_path, total_changed.links, @@ -321,7 +321,7 @@ M.data = { vim.lsp.util.apply_workspace_edit(wsEdit, "utf-8") vim.notify( - ("[word] renamed %s to %s\nChanged %d links across %d files."):format( + ("[down] renamed %s to %s\nChanged %d links across %d files."):format( title_text, new_name, total_changed.links, diff --git a/lua/word/mod/lsp/document/hint/README.md b/lua/down/mod/lsp/document/highlight/README.md similarity index 100% rename from lua/word/mod/lsp/document/hint/README.md rename to lua/down/mod/lsp/document/highlight/README.md diff --git a/lua/word/mod/lsp/document/highlight/init.lua b/lua/down/mod/lsp/document/highlight/init.lua similarity index 100% rename from lua/word/mod/lsp/document/highlight/init.lua rename to lua/down/mod/lsp/document/highlight/init.lua diff --git a/lua/word/mod/lsp/document/hover/README.md b/lua/down/mod/lsp/document/hint/README.md similarity index 100% rename from lua/word/mod/lsp/document/hover/README.md rename to lua/down/mod/lsp/document/hint/README.md diff --git a/lua/word/mod/lsp/document/hint/init.lua b/lua/down/mod/lsp/document/hint/init.lua similarity index 100% rename from lua/word/mod/lsp/document/hint/init.lua rename to lua/down/mod/lsp/document/hint/init.lua diff --git a/lua/word/mod/lsp/document/lens/README.md b/lua/down/mod/lsp/document/hover/README.md similarity index 100% rename from lua/word/mod/lsp/document/lens/README.md rename to lua/down/mod/lsp/document/hover/README.md diff --git a/lua/word/mod/lsp/document/hover/init.lua b/lua/down/mod/lsp/document/hover/init.lua similarity index 100% rename from lua/word/mod/lsp/document/hover/init.lua rename to lua/down/mod/lsp/document/hover/init.lua diff --git a/lua/word/mod/lsp/document/init.lua b/lua/down/mod/lsp/document/init.lua similarity index 96% rename from lua/word/mod/lsp/document/init.lua rename to lua/down/mod/lsp/document/init.lua index 419a2ef..7f86e6d 100644 --- a/lua/word/mod/lsp/document/init.lua +++ b/lua/down/mod/lsp/document/init.lua @@ -1,4 +1,4 @@ -local config = require("word.config").config +local config = require("down.config").config local M = Mod.create("lsp.document", { "lens", "semantic", @@ -14,7 +14,7 @@ local M = Mod.create("lsp.document", { "link", }) ----@return word.mod.setup +---@return down.mod.setup M.setup = function() return { loaded = true, @@ -26,7 +26,7 @@ M.setup = function() end ---@class (exact) lsp.document.Config -M.config.public = {} +M.config = {} ---@class lsp.document.Data ---@field doc lsp.document.Doc diff --git a/lua/word/mod/lsp/document/link/README.md b/lua/down/mod/lsp/document/lens/README.md similarity index 100% rename from lua/word/mod/lsp/document/link/README.md rename to lua/down/mod/lsp/document/lens/README.md diff --git a/lua/word/mod/lsp/document/lens/init.lua b/lua/down/mod/lsp/document/lens/init.lua similarity index 88% rename from lua/word/mod/lsp/document/lens/init.lua rename to lua/down/mod/lsp/document/lens/init.lua index de76bb7..4aec5db 100644 --- a/lua/word/mod/lsp/document/lens/init.lua +++ b/lua/down/mod/lsp/document/lens/init.lua @@ -1,4 +1,4 @@ -local M = require("word.mod").create("lsp.document.lens") +local M = require("down.mod").create("lsp.document.lens") ---@class lsp.document.lens M.data = { diff --git a/lua/word/mod/lsp/document/semantic/README.md b/lua/down/mod/lsp/document/link/README.md similarity index 100% rename from lua/word/mod/lsp/document/semantic/README.md rename to lua/down/mod/lsp/document/link/README.md diff --git a/lua/word/mod/lsp/document/link/init.lua b/lua/down/mod/lsp/document/link/init.lua similarity index 100% rename from lua/word/mod/lsp/document/link/init.lua rename to lua/down/mod/lsp/document/link/init.lua diff --git a/lua/word/mod/lsp/document/symbol/README.md b/lua/down/mod/lsp/document/semantic/README.md similarity index 100% rename from lua/word/mod/lsp/document/symbol/README.md rename to lua/down/mod/lsp/document/semantic/README.md diff --git a/lua/word/mod/lsp/document/semantic/init.lua b/lua/down/mod/lsp/document/semantic/init.lua similarity index 100% rename from lua/word/mod/lsp/document/semantic/init.lua rename to lua/down/mod/lsp/document/semantic/init.lua diff --git a/lua/word/mod/lsp/implementation/README.md b/lua/down/mod/lsp/document/symbol/README.md similarity index 100% rename from lua/word/mod/lsp/implementation/README.md rename to lua/down/mod/lsp/document/symbol/README.md diff --git a/lua/word/mod/lsp/document/symbol/init.lua b/lua/down/mod/lsp/document/symbol/init.lua similarity index 100% rename from lua/word/mod/lsp/document/symbol/init.lua rename to lua/down/mod/lsp/document/symbol/init.lua diff --git a/lua/word/mod/lsp/handlers.lua b/lua/down/mod/lsp/handlers.lua similarity index 100% rename from lua/word/mod/lsp/handlers.lua rename to lua/down/mod/lsp/handlers.lua diff --git a/lua/word/mod/lsp/moniker/README.md b/lua/down/mod/lsp/implementation/README.md similarity index 100% rename from lua/word/mod/lsp/moniker/README.md rename to lua/down/mod/lsp/implementation/README.md diff --git a/lua/word/mod/lsp/implementation/init.lua b/lua/down/mod/lsp/implementation/init.lua similarity index 100% rename from lua/word/mod/lsp/implementation/init.lua rename to lua/down/mod/lsp/implementation/init.lua diff --git a/lua/word/mod/lsp/init.lua b/lua/down/mod/lsp/init.lua similarity index 97% rename from lua/word/mod/lsp/init.lua rename to lua/down/mod/lsp/init.lua index ca6a597..ef55b39 100644 --- a/lua/word/mod/lsp/init.lua +++ b/lua/down/mod/lsp/init.lua @@ -1,5 +1,5 @@ local Path = require("pathlib") -local mod, log = require("word.mod"), require("word.util.log") +local mod, log = require("down.mod"), require("down.util.log") local tsu = require("nvim-treesitter.ts_utils") local tq, vl = vim.treesitter.query, vim.lsp local ll, lu, lb = vl.log, vl.util, vl.buf @@ -24,7 +24,7 @@ local M = mod.create("lsp", { M.opts = function() end M.maps = function() - local bufnr = require("word.util.buf").buf() + local bufnr = require("down.util.buf").buf() local bufopts = { noremap = true, silent = true, buffer = bufnr } vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts) vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts) @@ -167,8 +167,8 @@ M.data = { ws_folders = Mod.get_mod("lsp.workspace.folders"), } ----@class word.lsp.config -M.config.public = { +---@class down.lsp.config +M.config = { diagnostic = { enable = true }, format = { enable = true }, actions = { @@ -185,7 +185,7 @@ M.config.public = { -- Enable or disable the completion provider enable = true, - -- Try to complete categories provided by word SE + -- Try to complete categories provided by down SE categories = false, }, } @@ -335,7 +335,7 @@ M.data.act = Mod.get_mod("lsp.document.actions") ---@type lsp._anonym1.serverInfo M.data.serverInfo = { - name = "word", + name = "down", version = "0.1.0-alpha.1", } ---@return lsp.InitializeResult @@ -345,15 +345,15 @@ M.data.initResult = function() -- ---@type lsp.ServerCapabilities -- local cap = initRes.capabilities - -- if not M.config.public.completion.enable then + -- if not M.config.completion.enable then -- cap.completionProvider = nil - -- elseif not M.config.public.format.enable then + -- elseif not M.config.format.enable then -- cap.documentFormattingProvider = nil - -- elseif not M.config.public.hover.enable then + -- elseif not M.config.hover.enable then -- cap.hoverProvider = nil - -- elseif not M.config.public.lens.enable then + -- elseif not M.config.lens.enable then -- cap.codeLensProvider = nil - -- elseif not M.config.public.actions.enable then + -- elseif not M.config.actions.enable then -- cap.codeActionProvider = nil -- else -- end @@ -486,11 +486,11 @@ M.data.handlers = { ["initialize"] = function(params, callback, notify_reply_callback) ---@type lsp.InitializeResult local ir = M.data.initializeResult - if not M.config.public.completion.enable then + if not M.config.completion.enable then ir.capabilities.completionProvider = nil - elseif not M.config.public.actions.enable then + elseif not M.config.actions.enable then ir.capabilities.codeActionProvider = nil - elseif not M.config.public.lens.enable then + elseif not M.config.lens.enable then ir.capabilities.codeLensProvider = nil end @@ -533,8 +533,8 @@ M.data.handlers = { end, ["textDocument/hover"] = function(params, callback, _notify_reply_callback) -- local buf = vim.uri_to_bufnr(params.textDocument.uri) - -- local b = require("word.util.buf").buf() - -- M.required["ui.win"].win("hi", "bro", "Word note today") + -- local b = require("down.util.buf").buf() + -- M.required["ui.win"].win("hi", "bro", "down note today") -- vim.lsp.buf.hover() -- local node = M.data.ts.get_first_node_on_line(b, params.position.line) @@ -675,7 +675,7 @@ M.data.handlers = { callback, notify_reply_callback ) - if M.config.public.completion.categories then + if M.config.completion.categories then local cats = cmp.category_completion() if cats and not vim.tbl_isempty(cats) then callback(nil, cmp.category_completion()) @@ -1015,13 +1015,13 @@ M.data.start_lsp = function() ---@type lsp.InitializeResult -- local ir = M.data.init_result() -- vim.lsp.start({ - -- name = "word-lsp", - -- cmd = { "word-lsp", "serve" }, + -- name = "down-lsp", + -- cmd = { "down-lsp", "serve" }, -- }) vim.lsp.start( ---@type vim.lsp.ClientConfig { - name = "word", + name = "down", -- workspace_folders = { -- Mod.get_mod("workspace").get_current_workspace() -- }, @@ -1122,7 +1122,7 @@ end M.data["lsp.stop"] = function(e) vim.lsp.stop_client(vim.lsp.get_clients({ bufnr = vim.api.nvim_get_current_buf(), - name = "word", + name = "down", })) end M.data["lsp.rename.file"] = function(event) @@ -1208,10 +1208,10 @@ M.data["rename.heading"] = function(event) end) end -M.data.word_lsp = function() +M.data.down_lsp = function() vim.lsp.start({ - name = "word-lsp", - cmd = { "word-lsp" }, + name = "down-lsp", + cmd = { "down-lsp" }, -- workspace_folders = M.required.workspace.get_dirs(), -- root_dir = tostring(M.required.workspace.get_current_workspace()[2]), }) diff --git a/lua/word/mod/lsp/notebook/README.md b/lua/down/mod/lsp/moniker/README.md similarity index 100% rename from lua/word/mod/lsp/notebook/README.md rename to lua/down/mod/lsp/moniker/README.md diff --git a/lua/word/mod/lsp/moniker/init.lua b/lua/down/mod/lsp/moniker/init.lua similarity index 100% rename from lua/word/mod/lsp/moniker/init.lua rename to lua/down/mod/lsp/moniker/init.lua diff --git a/lua/word/mod/lsp/refactor/README.md b/lua/down/mod/lsp/notebook/README.md similarity index 100% rename from lua/word/mod/lsp/refactor/README.md rename to lua/down/mod/lsp/notebook/README.md diff --git a/lua/word/mod/lsp/notebook/init.lua b/lua/down/mod/lsp/notebook/init.lua similarity index 100% rename from lua/word/mod/lsp/notebook/init.lua rename to lua/down/mod/lsp/notebook/init.lua diff --git a/lua/word/mod/lsp/reference/README.md b/lua/down/mod/lsp/refactor/README.md similarity index 100% rename from lua/word/mod/lsp/reference/README.md rename to lua/down/mod/lsp/refactor/README.md diff --git a/lua/word/mod/lsp/refactor/init.lua b/lua/down/mod/lsp/refactor/init.lua similarity index 98% rename from lua/word/mod/lsp/refactor/init.lua rename to lua/down/mod/lsp/refactor/init.lua index 3cc4a9d..bba31d1 100644 --- a/lua/word/mod/lsp/refactor/init.lua +++ b/lua/down/mod/lsp/refactor/init.lua @@ -1,7 +1,7 @@ local Path = require("pathlib") -local word = require("word") -local mod = word.mod -local log = word.log +local down = require("down") +local mod = down.mod +local log = down.log local M = mod.create("lsp.refactor") @@ -170,7 +170,7 @@ M.data = { vim.api.nvim_buf_delete(buf, {}) vim.lsp.util.apply_workspace_edit(wsEdit, "utf-8") vim.notify( - ("[word] renamed %s to %s\nChanged %d links across %d files."):format( + ("[down] renamed %s to %s\nChanged %d links across %d files."):format( current_path, new_path, total_changed.links, @@ -306,7 +306,7 @@ M.data = { vim.lsp.util.apply_workspace_edit(wsEdit, "utf-8") vim.notify( - ("[word] renamed %s to %s\nChanged %d links across %d files."):format( + ("[down] renamed %s to %s\nChanged %d links across %d files."):format( title_text, new_name, total_changed.links, diff --git a/lua/word/mod/lsp/type/README.md b/lua/down/mod/lsp/reference/README.md similarity index 100% rename from lua/word/mod/lsp/type/README.md rename to lua/down/mod/lsp/reference/README.md diff --git a/lua/word/mod/lsp/reference/init.lua b/lua/down/mod/lsp/reference/init.lua similarity index 85% rename from lua/word/mod/lsp/reference/init.lua rename to lua/down/mod/lsp/reference/init.lua index 8775ffa..ff24478 100644 --- a/lua/word/mod/lsp/reference/init.lua +++ b/lua/down/mod/lsp/reference/init.lua @@ -1,4 +1,4 @@ -local I = require("word.mod").create("lsp.reference") +local I = require("down.mod").create("lsp.reference") function I.setup() return { diff --git a/lua/word/mod/lsp/window/README.md b/lua/down/mod/lsp/type/README.md similarity index 100% rename from lua/word/mod/lsp/window/README.md rename to lua/down/mod/lsp/type/README.md diff --git a/lua/word/mod/lsp/type/init.lua b/lua/down/mod/lsp/type/init.lua similarity index 88% rename from lua/word/mod/lsp/type/init.lua rename to lua/down/mod/lsp/type/init.lua index dc00541..aee2e15 100644 --- a/lua/word/mod/lsp/type/init.lua +++ b/lua/down/mod/lsp/type/init.lua @@ -9,7 +9,7 @@ function T.setup() } end -T.config.public = {} +T.config = {} T.data = {} return T diff --git a/lua/word/mod/lsp/util.lua b/lua/down/mod/lsp/util.lua similarity index 98% rename from lua/word/mod/lsp/util.lua rename to lua/down/mod/lsp/util.lua index 5736025..7d692e2 100644 --- a/lua/word/mod/lsp/util.lua +++ b/lua/down/mod/lsp/util.lua @@ -75,7 +75,7 @@ local M = { infoOutline = "  ", interface = "  ", key = "  ", - keyword = "  ", + keydown = "  ", light = "  ", lightbulb = "  ", lightbulbOutline = "  ", @@ -138,7 +138,7 @@ local M = { warningTriangle = "  ", warningTriangleNoBg = "  ", watch = "  ", - word = "  ", + down = "  ", wrench = "  ", fillBox = " 󰄮 ", outlineBox = " 󰄱 ", diff --git a/lua/word/mod/lsp/window/msg/README.md b/lua/down/mod/lsp/window/README.md similarity index 100% rename from lua/word/mod/lsp/window/msg/README.md rename to lua/down/mod/lsp/window/README.md diff --git a/lua/word/mod/lsp/window/init.lua b/lua/down/mod/lsp/window/init.lua similarity index 96% rename from lua/word/mod/lsp/window/init.lua rename to lua/down/mod/lsp/window/init.lua index 262588a..7bc60b8 100644 --- a/lua/word/mod/lsp/window/init.lua +++ b/lua/down/mod/lsp/window/init.lua @@ -13,7 +13,7 @@ function W.setup() end ---@class (exact) lsp.window.Config -W.config.public = {} +W.config = {} ---@class lsp.window.Data W.data = {} diff --git a/lua/word/mod/lsp/workspace/README.md b/lua/down/mod/lsp/window/msg/README.md similarity index 100% rename from lua/word/mod/lsp/workspace/README.md rename to lua/down/mod/lsp/window/msg/README.md diff --git a/lua/word/mod/lsp/window/msg/init.lua b/lua/down/mod/lsp/window/msg/init.lua similarity index 93% rename from lua/word/mod/lsp/window/msg/init.lua rename to lua/down/mod/lsp/window/msg/init.lua index f269ec4..3388d60 100644 --- a/lua/word/mod/lsp/window/msg/init.lua +++ b/lua/down/mod/lsp/window/msg/init.lua @@ -12,7 +12,7 @@ function W.setup() end ---@class lsp.window.msg.Config -W.config.public = { +W.config = { } diff --git a/lua/word/mod/lsp/workspace/config/README.md b/lua/down/mod/lsp/workspace/README.md similarity index 100% rename from lua/word/mod/lsp/workspace/config/README.md rename to lua/down/mod/lsp/workspace/README.md diff --git a/lua/word/mod/lsp/workspace/diagnostic/README.md b/lua/down/mod/lsp/workspace/config/README.md similarity index 100% rename from lua/word/mod/lsp/workspace/diagnostic/README.md rename to lua/down/mod/lsp/workspace/config/README.md diff --git a/lua/word/mod/lsp/workspace/config/init.lua b/lua/down/mod/lsp/workspace/config/init.lua similarity index 100% rename from lua/word/mod/lsp/workspace/config/init.lua rename to lua/down/mod/lsp/workspace/config/init.lua diff --git a/lua/word/mod/lsp/workspace/edit/README.md b/lua/down/mod/lsp/workspace/diagnostic/README.md similarity index 100% rename from lua/word/mod/lsp/workspace/edit/README.md rename to lua/down/mod/lsp/workspace/diagnostic/README.md diff --git a/lua/word/mod/lsp/workspace/diagnostic/init.lua b/lua/down/mod/lsp/workspace/diagnostic/init.lua similarity index 100% rename from lua/word/mod/lsp/workspace/diagnostic/init.lua rename to lua/down/mod/lsp/workspace/diagnostic/init.lua diff --git a/lua/word/mod/lsp/workspace/file/README.md b/lua/down/mod/lsp/workspace/edit/README.md similarity index 100% rename from lua/word/mod/lsp/workspace/file/README.md rename to lua/down/mod/lsp/workspace/edit/README.md diff --git a/lua/word/mod/lsp/workspace/edit/init.lua b/lua/down/mod/lsp/workspace/edit/init.lua similarity index 100% rename from lua/word/mod/lsp/workspace/edit/init.lua rename to lua/down/mod/lsp/workspace/edit/init.lua diff --git a/lua/word/mod/lsp/workspace/folders/README.md b/lua/down/mod/lsp/workspace/file/README.md similarity index 100% rename from lua/word/mod/lsp/workspace/folders/README.md rename to lua/down/mod/lsp/workspace/file/README.md diff --git a/lua/word/mod/lsp/workspace/file/init.lua b/lua/down/mod/lsp/workspace/file/init.lua similarity index 100% rename from lua/word/mod/lsp/workspace/file/init.lua rename to lua/down/mod/lsp/workspace/file/init.lua diff --git a/lua/word/mod/lsp/workspace/lens/README.md b/lua/down/mod/lsp/workspace/folders/README.md similarity index 100% rename from lua/word/mod/lsp/workspace/lens/README.md rename to lua/down/mod/lsp/workspace/folders/README.md diff --git a/lua/word/mod/lsp/workspace/folders/init.lua b/lua/down/mod/lsp/workspace/folders/init.lua similarity index 100% rename from lua/word/mod/lsp/workspace/folders/init.lua rename to lua/down/mod/lsp/workspace/folders/init.lua diff --git a/lua/word/mod/lsp/workspace/init.lua b/lua/down/mod/lsp/workspace/init.lua similarity index 97% rename from lua/word/mod/lsp/workspace/init.lua rename to lua/down/mod/lsp/workspace/init.lua index f23b39c..852fc49 100644 --- a/lua/word/mod/lsp/workspace/init.lua +++ b/lua/down/mod/lsp/workspace/init.lua @@ -19,7 +19,7 @@ function M.setup() end ---@class lsp.workspace.Config -M.config.public = {} +M.config = {} ---@class lsp.workspace.Data ---@field workspace lsp.workspace.Workspace ---@field capabilities lsp.WorkspaceClientCapabilities diff --git a/lua/word/mod/lsp/workspace/symbol/README.md b/lua/down/mod/lsp/workspace/lens/README.md similarity index 100% rename from lua/word/mod/lsp/workspace/symbol/README.md rename to lua/down/mod/lsp/workspace/lens/README.md diff --git a/lua/word/mod/lsp/workspace/lens/init.lua b/lua/down/mod/lsp/workspace/lens/init.lua similarity index 100% rename from lua/word/mod/lsp/workspace/lens/init.lua rename to lua/down/mod/lsp/workspace/lens/init.lua diff --git a/lua/word/mod/lsp/workspace/tag/README.md b/lua/down/mod/lsp/workspace/symbol/README.md similarity index 100% rename from lua/word/mod/lsp/workspace/tag/README.md rename to lua/down/mod/lsp/workspace/symbol/README.md diff --git a/lua/word/mod/lsp/workspace/symbol/init.lua b/lua/down/mod/lsp/workspace/symbol/init.lua similarity index 100% rename from lua/word/mod/lsp/workspace/symbol/init.lua rename to lua/down/mod/lsp/workspace/symbol/init.lua diff --git a/lua/word/mod/note/README.md b/lua/down/mod/lsp/workspace/tag/README.md similarity index 100% rename from lua/word/mod/note/README.md rename to lua/down/mod/lsp/workspace/tag/README.md diff --git a/lua/down/mod/lsp/workspace/tag/init.lua b/lua/down/mod/lsp/workspace/tag/init.lua new file mode 100644 index 0000000..057f17b --- /dev/null +++ b/lua/down/mod/lsp/workspace/tag/init.lua @@ -0,0 +1,20 @@ +local M = require("down.mod").create("lsp.workspace.tag") + +function M.setup() + return { + requires = { + "workspace", + }, + loaded = true, + } +end + +---@class down.lsp.workspace.tag.Data +M.data = {} + +---@class down.lsp.workspace.tag.Config +M.config = { + enable = true, +} + +return M diff --git a/lua/word/mod/ui/README.md b/lua/down/mod/note/README.md similarity index 100% rename from lua/word/mod/ui/README.md rename to lua/down/mod/note/README.md diff --git a/lua/word/mod/note/init.lua b/lua/down/mod/note/init.lua similarity index 74% rename from lua/word/mod/note/init.lua rename to lua/down/mod/note/init.lua index e8faaa2..352b294 100644 --- a/lua/word/mod/note/init.lua +++ b/lua/down/mod/note/init.lua @@ -1,31 +1,31 @@ -local word = require("word") +local down = require("down") local config, lib, log, mod = - require("word.config").config, word.lib, word.log, word.mod + require("down.config").config, down.lib, down.log, down.mod local M = mod.create("note") M.maps = function() vim.api.nvim_set_keymap( "n", ",wn", - "Word note today", + "Down note today", { silent = true } ) vim.api.nvim_set_keymap( "n", ",wy", - "Word note yesterday", + "Down note yesterday", { silent = true } ) vim.api.nvim_set_keymap( "n", ",wc", - "Word note capture", + "Down note capture", { silent = true } ) vim.api.nvim_set_keymap( "n", ",wt", - "Word note tomorrow", + "Down note tomorrow", { silent = true } ) end @@ -35,14 +35,14 @@ M.data = { end, year_index = function() local yr = os.date("%Y") - local ws = M.config.public.workspace - or M.required["workspace"].get_current_workspace()[1] + local ws = M.config.workspace + or M.required["workspace"].get_current_workspace()[1] local ws_path = M.required["workspace"].get_workspace(ws) - local ix = M.config.public.note_folder - .. config.pathsep - .. yr - .. config.pathsep - .. "index.md" + local ix = M.config.note_folder + .. config.pathsep + .. yr + .. config.pathsep + .. "index.md" local path = ws_path .. config.pathsep .. ix local index_exists = M.required["workspace"].file_exists(path) if index_exists then @@ -55,16 +55,16 @@ M.data = { month_index = function() local yr = os.date("%Y") local mo = os.date("%m") - local ws = M.config.public.workspace - or M.required["workspace"].get_current_workspace()[1] + local ws = M.config.workspace + or M.required["workspace"].get_current_workspace()[1] local ws_path = M.required["workspace"].get_workspace(ws) - local ix = M.config.public.note_folder - .. config.pathsep - .. yr - .. config.pathsep - .. mo - .. config.pathsep - .. "index.md" + local ix = M.config.note_folder + .. config.pathsep + .. yr + .. config.pathsep + .. mo + .. config.pathsep + .. "index.md" local path = ws_path .. config.pathsep .. ix local index_exists = M.required["workspace"].file_exists(path) if index_exists then @@ -76,10 +76,10 @@ M.data = { end, select_month = function() end, note_index = function() - local ws = M.config.public.workspace - or M.required["workspace"].get_current_workspace()[1] + local ws = M.config.workspace + or M.required["workspace"].get_current_workspace()[1] local ws_path = M.required["workspace"].get_workspace(ws) - local ix = M.config.public.note_folder .. config.pathsep .. "index.md" + local ix = M.config.note_folder .. config.pathsep .. "index.md" local path = ws_path .. config.pathsep .. ix local index_exists = M.required["workspace"].file_exists(path) if index_exists then @@ -93,12 +93,12 @@ M.data = { ---@param time? number #The time to open the note entry at as returned by `os.time()` ---@param custom_date? string #A YYYY-mm-dd string that specifies a date to open the note at instead open_year = function(time, custom_date) - -- TODO(vhyrro): Change this to use word dates! - local workspace = M.config.public.workspace - or M.required["workspace"].get_current_workspace()[1] + -- TODO(vhyrro): Change this to use down dates! + local workspace = M.config.workspace + or M.required["workspace"].get_current_workspace()[1] local workspace_path = M.required["workspace"].get_workspace(workspace) - local folder_name = M.config.public.note_folder - local tmpl = M.config.public.template.year + local folder_name = M.config.note_folder + local tmpl = M.config.template.year if custom_date then local year, _month, _day = custom_date:match("^(%d%d%d%d)-(%d%d)-(%d%d)$") @@ -117,9 +117,9 @@ M.data = { end local path = os.date( - type(M.config.public.strategy) == "function" - and M.config.public.strategy(os.date("*t", time)) - or M.config.public.strategy, + type(M.config.strategy) == "function" + and M.config.strategy(os.date("*t", time)) + or M.config.strategy, time ) @@ -135,31 +135,31 @@ M.data = { -- M.required["workspace"].create_file(folder_name..config.pathsep..path, workspace) if - not note_file_exists - and M.config.public.template.enable - and M.required["workspace"].file_exists( - workspace_path .. "/" .. folder_name .. "/" .. tmpl - ) + not note_file_exists + and M.config.template.enable + and M.required["workspace"].file_exists( + workspace_path .. "/" .. folder_name .. "/" .. tmpl + ) then vim.cmd( "$read " - .. workspace_path - .. "/" - .. folder_name - .. "/" - .. tmpl - .. "| silent! w" + .. workspace_path + .. "/" + .. folder_name + .. "/" + .. tmpl + .. "| silent! w" ) end end, ---@param time? number #The time to open the note entry at as returned by `os.time()` ---@param custom_date? string #A YYYY-mm-dd string that specifies a date to open the note at instead open_month = function(time, custom_date) - local workspace = M.config.public.workspace - or M.required["workspace"].get_current_workspace()[1] + local workspace = M.config.workspace + or M.required["workspace"].get_current_workspace()[1] local workspace_path = M.required["workspace"].get_workspace(workspace) - local folder_name = M.config.public.note_folder - local tmpl = M.config.public.template.month + local folder_name = M.config.note_folder + local tmpl = M.config.template.month if custom_date then local year, month, day = custom_date:match("^(%d%d%d%d)-(%d%d)-(%d%d)$") @@ -177,9 +177,9 @@ M.data = { end local path = os.date( - type(M.config.public.strategy) == "function" - and M.config.public.strategy(os.date("*t", time)) - or M.config.public.strategy, + type(M.config.strategy) == "function" + and M.config.strategy(os.date("*t", time)) + or M.config.strategy, time ) @@ -195,42 +195,42 @@ M.data = { -- M.required["workspace"].create_file(folder_name..config.pathsep..path, workspace) if - not note_file_exists - and M.config.public.template.enable - and M.required["workspace"].file_exists( - workspace_path .. "/" .. folder_name .. "/" .. tmpl - ) + not note_file_exists + and M.config.template.enable + and M.required["workspace"].file_exists( + workspace_path .. "/" .. folder_name .. "/" .. tmpl + ) then vim.cmd( "$read " - .. workspace_path - .. "/" - .. folder_name - .. "/" - .. tmpl - .. "| silent! w" + .. workspace_path + .. "/" + .. folder_name + .. "/" + .. tmpl + .. "| silent! w" ) end end, capture = function() - local b, w = M.required["ui.win"].win("today", "note", "Word note today") + local b, w = M.required["ui.win"].win("today", "note", "Down note today") -- vim.cmd -- Mod.get_mod("ui.win").cmd(w, function() - -- vim.api.nvim_command("word note today") + -- vim.api.nvim_command("down note today") -- end) - -- pcall(vim.api.nvim_command, ":word note today") + -- pcall(vim.api.nvim_command, ":down note today") end, --- Opens a note entry at the given time ---@param time? number #The time to open the note entry at as returned by `os.time()` ---@param custom_date? string #A YYYY-mm-dd string that specifies a date to open the note at instead open_note = function(time, custom_date) - -- TODO(vhyrro): Change this to use word dates! - local workspace = M.config.public.workspace - or M.required["workspace"].get_current_workspace()[1] + -- TODO(vhyrro): Change this to use down dates! + local workspace = M.config.workspace + or M.required["workspace"].get_current_workspace()[1] local workspace_path = M.required["workspace"].get_workspace(workspace) - local folder_name = M.config.public.note_folder - local tmpl = M.config.public.template.day + local folder_name = M.config.note_folder + local tmpl = M.config.template.day if custom_date then local year, month, day = custom_date:match("^(%d%d%d%d)-(%d%d)-(%d%d)$") @@ -248,9 +248,9 @@ M.data = { end local path = os.date( - type(M.config.public.strategy) == "function" - and M.config.public.strategy(os.date("*t", time)) - or M.config.public.strategy, + type(M.config.strategy) == "function" + and M.config.strategy(os.date("*t", time)) + or M.config.strategy, time ) @@ -266,20 +266,20 @@ M.data = { -- M.required["workspace"].create_file(folder_name..config.pathsep..path, workspace) if - not note_file_exists - and M.config.public.template.enable - and M.required["workspace"].file_exists( - workspace_path .. "/" .. folder_name .. "/" .. tmpl - ) + not note_file_exists + and M.config.template.enable + and M.required["workspace"].file_exists( + workspace_path .. "/" .. folder_name .. "/" .. tmpl + ) then vim.cmd( "$read " - .. workspace_path - .. "/" - .. folder_name - .. "/" - .. tmpl - .. "| silent! w" + .. workspace_path + .. "/" + .. folder_name + .. "/" + .. tmpl + .. "| silent! w" ) end end, @@ -322,9 +322,9 @@ M.data = { end, create_month_template = function() - local workspace = M.config.public.workspace - local folder_name = M.config.public.note_folder - local tmpl = M.config.public.template.month + local workspace = M.config.workspace + local folder_name = M.config.note_folder + local tmpl = M.config.template.month M.required["workspace"].create_file( folder_name .. config.pathsep .. tmpl, workspace or M.required["workspace"].get_current_workspace()[1] @@ -332,18 +332,18 @@ M.data = { end, --- Creates a template file create_year_template = function() - local workspace = M.config.public.workspace - local folder_name = M.config.public.note_folder - local tmpl = M.config.public.template.year + local workspace = M.config.workspace + local folder_name = M.config.note_folder + local tmpl = M.config.template.year M.required["workspace"].create_file( folder_name .. config.pathsep .. tmpl, workspace or M.required["workspace"].get_current_workspace()[1] ) end, create_day_template = function() - local workspace = M.config.public.workspace - local folder_name = M.config.public.note_folder - local tmpl = M.config.public.template.day + local workspace = M.config.workspace + local folder_name = M.config.note_folder + local tmpl = M.config.template.day M.required["workspace"].create_file( folder_name .. config.pathsep .. tmpl, @@ -353,16 +353,16 @@ M.data = { --- Opens the toc file open_toc = function() - local workspace = M.config.public.workspace - or M.required["workspace"].get_current_workspace()[1] + local workspace = M.config.workspace + or M.required["workspace"].get_current_workspace()[1] local index = mod.get_mod_config("workspace").index - local folder_name = M.config.public.note_folder + local folder_name = M.config.note_folder -- If the toc exists, open it, if not, create it if - M.required["workspace"].file_exists( - folder_name .. config.pathsep .. index - ) + M.required["workspace"].file_exists( + folder_name .. config.pathsep .. index + ) then M.required["workspace"].open_file( workspace, @@ -375,12 +375,12 @@ M.data = { --- Creates or updates the toc file create_toc = function() - local workspace = M.config.public.workspace - or M.required["workspace"].get_current_workspace()[1] + local workspace = M.config.workspace + or M.required["workspace"].get_current_workspace()[1] local index = mod.get_mod_config("workspace").index local workspace_path = M.required["workspace"].get_workspace(workspace) - local workspace_name_for_link = M.config.public.workspace or "" - local folder_name = M.config.public.note_folder + local workspace_name_for_link = M.config.workspace or "" + local folder_name = M.config.note_folder -- Each entry is a table that contains tables like { yy, mm, dd, link, title } local toc_entries = {} @@ -391,10 +391,10 @@ M.data = { path = path or "" local handle = vim.loop.fs_scandir( workspace_path - .. config.pathsep - .. folder_name - .. config.pathsep - .. path + .. config.pathsep + .. folder_name + .. config.pathsep + .. path ) if type(handle) ~= "userdata" then @@ -416,10 +416,10 @@ M.data = { local get_title = function(file) local buffer = vim.fn.bufadd( workspace_path - .. config.pathsep - .. folder_name - .. config.pathsep - .. file + .. config.pathsep + .. folder_name + .. config.pathsep + .. file ) local meta = M.required["workspace"].get_document_metadata(buffer) return meta.title @@ -439,7 +439,7 @@ M.data = { ) while true do - -- Name corresponds to either a YYYY-mm-dd.word file, or just the year ("nested" strategy) + -- Name corresponds to either a YYYY-mm-dd.down file, or just the year ("nested" strategy) local name, type = vim.loop.fs_scandir_next(handle) ---@diagnostic disable-line -- TODO: type error workaround if not name then @@ -459,7 +459,7 @@ M.data = { if mtype == "directory" then local months_handle = - get_fs_handle(name .. config.pathsep .. mname) + get_fs_handle(name .. config.pathsep .. mname) while true do -- dname is the day local dname, dtype = vim.loop.fs_scandir_next(months_handle) @@ -468,7 +468,7 @@ M.data = { break end - -- If it's a .word file, also ensure it is a day entry + -- If it's a .down file, also ensure it is a day entry if dtype == "file" and string.match(dname, "%d%d%.md") then -- Split the file name local file = vim.split(dname, ".", { plain = true }) @@ -477,10 +477,10 @@ M.data = { -- Get the title from the metadata, else, it just base to the name of the file local title = get_title( name - .. config.pathsep - .. mname - .. config.pathsep - .. dname + .. config.pathsep + .. mname + .. config.pathsep + .. dname ) or file[1] -- Insert a new entry @@ -489,16 +489,16 @@ M.data = { tonumber(mname), tonumber(file[1]), "{:$" - .. workspace_name_for_link - .. config.pathsep - .. M.config.public.note_folder - .. config.pathsep - .. name - .. config.pathsep - .. mname - .. config.pathsep - .. file[1] - .. ":}", + .. workspace_name_for_link + .. config.pathsep + .. M.config.note_folder + .. config.pathsep + .. name + .. config.pathsep + .. mname + .. config.pathsep + .. file[1] + .. ":}", title, }) end) @@ -509,7 +509,7 @@ M.data = { end -- Handles flat entries - -- If it is a .word file, but it's not any user generated file. + -- If it is a .down file, but it's not any user generated file. -- The match is here to avoid handling files made by the user, like a template file, or -- the toc file if type == "file" and string.match(name, "%d+-%d+-%d+%.md") then @@ -532,12 +532,12 @@ M.data = { parts[2], parts[3], "{:$" - .. workspace_name_for_link - .. config.pathsep - .. M.config.public.note_folder - .. config.pathsep - .. file[1] - .. ":}", + .. workspace_name_for_link + .. config.pathsep + .. M.config.note_folder + .. config.pathsep + .. file[1] + .. ":}", title, }) end) @@ -546,35 +546,35 @@ M.data = { vim.schedule(function() -- Gets a base format for the entries - local format = M.config.public.toc_format - or function(entries) - local months_text = M.months - -- Convert the entries into a certain format to be written - local output = {} - local current_year - local current_month - for _, entry in ipairs(entries) do - -- Don't print the year and month if they haven't changed - if not current_year or current_year < entry[1] then - current_year = entry[1] - current_month = nil - table.insert(output, "* " .. current_year) - end - if not current_month or current_month < entry[2] then - current_month = entry[2] - table.insert(output, "** " .. months_text[current_month]) + local format = M.config.toc_format + or function(entries) + local months_text = M.months + -- Convert the entries into a certain format to be written + local output = {} + local current_year + local current_month + for _, entry in ipairs(entries) do + -- Don't print the year and month if they haven't changed + if not current_year or current_year < entry[1] then + current_year = entry[1] + current_month = nil + table.insert(output, "* " .. current_year) + end + if not current_month or current_month < entry[2] then + current_month = entry[2] + table.insert(output, "** " .. months_text[current_month]) + end + + -- Prints the file link + table.insert( + output, + " " .. entry[4] .. string.format("[%s]", entry[5]) + ) end - -- Prints the file link - table.insert( - output, - " " .. entry[4] .. string.format("[%s]", entry[5]) - ) + return output end - return output - end - M.required["workspace"].create_file( folder_name .. config.pathsep .. index, workspace or M.required["workspace"].get_current_workspace()[1] @@ -589,8 +589,8 @@ M.data = { end, } ----@class word.mod.note.Config -M.config.public = { +---@class down.note.Config +M.config = { -- Which workspace to use for the note files, the base behaviour -- is to use the current workspace. -- @@ -602,12 +602,12 @@ M.config.public = { note_folder = "note", -- The strategy to use to create directories. - -- May be "flat" (`2022-03-02.word`), "nested" (`2022/03/02.word`), + -- May be "flat" (`2022-03-02.down`), "nested" (`2022/03/02.down`), -- a lua string with the format given to `os.date()` or a lua function -- that returns a lua string with the same format. strategy = "nested", - -- The name of the template file to use when running `:word note template`. + -- The name of the template file to use when running `:down note template`. template = { enable = true, @@ -625,7 +625,7 @@ M.config.public = { toc_format = nil, } -M.config.public.strategies = { +M.config.strategies = { flat = "%Y-%m-%d.md", nested = "%Y" .. config.pathsep .. "%m" .. config.pathsep .. "%d.md", } @@ -672,10 +672,10 @@ M.on = function(event) M.data.open_note( nil, string.format("%04d", osdate.year) - .. "-" - .. string.format("%02d", osdate.month) - .. "-" - .. string.format("%02d", osdate.day) + .. "-" + .. string.format("%02d", osdate.month) + .. "-" + .. string.format("%02d", osdate.day) ) end), }) @@ -756,9 +756,9 @@ M.data.timetable = { M.data.time = os.time() M.data.weekday = tonumber(os.date("%w", os.time(M.data.timetable))) M.setup = function() - if M.config.public.strategies[M.config.public.strategy] then - M.config.public.strategy = - M.config.public.strategies[M.config.public.strategy] + if M.config.strategies[M.config.strategy] then + M.config.strategy = + M.config.strategies[M.config.strategy] end mod.await("cmd", function(cmd) diff --git a/lua/word/mod/ui/calendar/README.md b/lua/down/mod/ui/README.md similarity index 100% rename from lua/word/mod/ui/calendar/README.md rename to lua/down/mod/ui/README.md diff --git a/lua/word/mod/ui/calendar/day/README.md b/lua/down/mod/ui/calendar/README.md similarity index 100% rename from lua/word/mod/ui/calendar/day/README.md rename to lua/down/mod/ui/calendar/README.md diff --git a/lua/word/mod/ui/calendar/month/README.md b/lua/down/mod/ui/calendar/day/README.md similarity index 100% rename from lua/word/mod/ui/calendar/month/README.md rename to lua/down/mod/ui/calendar/day/README.md diff --git a/lua/down/mod/ui/calendar/day/init.lua b/lua/down/mod/ui/calendar/day/init.lua new file mode 100644 index 0000000..bd9d679 --- /dev/null +++ b/lua/down/mod/ui/calendar/day/init.lua @@ -0,0 +1,3 @@ +local D = require("down.mod").create("ui.calendar.day") + +return D diff --git a/lua/word/mod/ui/calendar/init.lua b/lua/down/mod/ui/calendar/init.lua similarity index 98% rename from lua/word/mod/ui/calendar/init.lua rename to lua/down/mod/ui/calendar/init.lua index 245b925..1776411 100644 --- a/lua/word/mod/ui/calendar/init.lua +++ b/lua/down/mod/ui/calendar/init.lua @@ -1,5 +1,5 @@ -local word = require("word") -local mod = word.mod +local down = require("down") +local mod = down.mod local G = mod.create("ui.calendar") @@ -13,7 +13,7 @@ G.setup = function() } end ----@class word.ui.calendar.Data +---@class down.ui.calendar.Data ---@field select_date fun(options:table) G.data = { diff --git a/lua/word/mod/ui/calendar/time/README.md b/lua/down/mod/ui/calendar/month/README.md similarity index 100% rename from lua/word/mod/ui/calendar/time/README.md rename to lua/down/mod/ui/calendar/month/README.md diff --git a/lua/word/mod/ui/calendar/month/init.lua b/lua/down/mod/ui/calendar/month/init.lua similarity index 98% rename from lua/word/mod/ui/calendar/month/init.lua rename to lua/down/mod/ui/calendar/month/init.lua index 1a6e31c..f82f653 100644 --- a/lua/word/mod/ui/calendar/month/init.lua +++ b/lua/down/mod/ui/calendar/month/init.lua @@ -1,5 +1,5 @@ -local word = require("word") -local lib, log, mod, utils = word.lib, word.log, word.mod, word.utils +local down = require("down") +local lib, log, mod, utils = down.lib, down.log, down.mod, down.utils local M = mod.create("ui.calendar.month") @@ -563,16 +563,16 @@ M.data = { }, {}, { - { "Tuesday May 5th 2023 19:00.23", "@word.markup.verbatim" }, + { "Tuesday May 5th 2023 19:00.23", "@down.markup.verbatim" }, }, { - { "10 Feb CEST 0600", "@word.markup.verbatim" }, + { "10 Feb CEST 0600", "@down.markup.verbatim" }, { " (", "@comment" }, { "0600", "@text.emphasis" }, { " is the year)", "@comment" }, }, { - { "9:00.4 2nd March Wed", "@word.markup.verbatim" }, + { "9:00.4 2nd March Wed", "@down.markup.verbatim" }, }, }), { buffer = buffer } @@ -607,8 +607,8 @@ M.data = { end, namespaces = { - logical = vim.api.nvim_create_namespace("word/calendar/logical"), - decorational = vim.api.nvim_create_namespace("word/calendar/decorational"), + logical = vim.api.nvim_create_namespace("down/calendar/logical"), + decorational = vim.api.nvim_create_namespace("down/calendar/decorational"), }, set_extmark = function( @@ -1232,7 +1232,7 @@ M.data = { callback = quit, }) - local namespace = vim.api.nvim_create_namespace("word/calendar-help") + local namespace = vim.api.nvim_create_namespace("down/calendar-help") vim.api.nvim_buf_set_option(buffer, "modifiable", false) vim.api.nvim_buf_set_extmark(buffer, namespace, 0, 0, { diff --git a/lua/word/mod/ui/calendar/week/README.md b/lua/down/mod/ui/calendar/time/README.md similarity index 100% rename from lua/word/mod/ui/calendar/week/README.md rename to lua/down/mod/ui/calendar/time/README.md diff --git a/lua/down/mod/ui/calendar/time/init.lua b/lua/down/mod/ui/calendar/time/init.lua new file mode 100644 index 0000000..1087826 --- /dev/null +++ b/lua/down/mod/ui/calendar/time/init.lua @@ -0,0 +1,3 @@ +local T = require("down.mod").create("ui.calendar.time") + +return T diff --git a/lua/word/mod/ui/calendar/year/README.md b/lua/down/mod/ui/calendar/week/README.md similarity index 100% rename from lua/word/mod/ui/calendar/year/README.md rename to lua/down/mod/ui/calendar/week/README.md diff --git a/lua/down/mod/ui/calendar/week/init.lua b/lua/down/mod/ui/calendar/week/init.lua new file mode 100644 index 0000000..52ffb73 --- /dev/null +++ b/lua/down/mod/ui/calendar/week/init.lua @@ -0,0 +1,3 @@ +local W = require("down.mod").create("ui.calendar.week") + +return W diff --git a/lua/word/mod/ui/chat/README.md b/lua/down/mod/ui/calendar/year/README.md similarity index 100% rename from lua/word/mod/ui/chat/README.md rename to lua/down/mod/ui/calendar/year/README.md diff --git a/lua/down/mod/ui/calendar/year/init.lua b/lua/down/mod/ui/calendar/year/init.lua new file mode 100644 index 0000000..533534b --- /dev/null +++ b/lua/down/mod/ui/calendar/year/init.lua @@ -0,0 +1,3 @@ +local Y = require("down.mod").create("ui.calendar.year") + +return Y diff --git a/lua/word/mod/ui/dashboard/README.md b/lua/down/mod/ui/chat/README.md similarity index 100% rename from lua/word/mod/ui/dashboard/README.md rename to lua/down/mod/ui/chat/README.md diff --git a/lua/down/mod/ui/chat/init.lua b/lua/down/mod/ui/chat/init.lua new file mode 100644 index 0000000..da8b885 --- /dev/null +++ b/lua/down/mod/ui/chat/init.lua @@ -0,0 +1,16 @@ +local C = require("down.mod").create("ui.chat") + +C.setup = function() + return { + loaded = true, + requires = {}, + } +end + +---@class down.ui.chat.Config +C.config = {} + +---@class down.ui.chat.Data +C.data = {} + +return C diff --git a/lua/word/mod/ui/icon/README.md b/lua/down/mod/ui/dashboard/README.md similarity index 100% rename from lua/word/mod/ui/icon/README.md rename to lua/down/mod/ui/dashboard/README.md diff --git a/lua/down/mod/ui/dashboard/init.lua b/lua/down/mod/ui/dashboard/init.lua new file mode 100644 index 0000000..080d5e6 --- /dev/null +++ b/lua/down/mod/ui/dashboard/init.lua @@ -0,0 +1,16 @@ +local D = require("down.mod").create("ui.dashboard") + +D.setup = function() + return { + loaded = true, + requires = {}, + } +end + +---@class down.ui.dashboard.Config +D.config = {} + +---@class down.ui.dashboard.Data +D.data = {} + +return D diff --git a/lua/word/mod/ui/icon/basic/README.md b/lua/down/mod/ui/icon/README.md similarity index 100% rename from lua/word/mod/ui/icon/basic/README.md rename to lua/down/mod/ui/icon/README.md diff --git a/lua/word/mod/ui/icon/complex/README.md b/lua/down/mod/ui/icon/basic/README.md similarity index 100% rename from lua/word/mod/ui/icon/complex/README.md rename to lua/down/mod/ui/icon/basic/README.md diff --git a/lua/word/mod/ui/icon/basic/init.lua b/lua/down/mod/ui/icon/basic/init.lua similarity index 96% rename from lua/word/mod/ui/icon/basic/init.lua rename to lua/down/mod/ui/icon/basic/init.lua index a09ee6c..1057a19 100644 --- a/lua/word/mod/ui/icon/basic/init.lua +++ b/lua/down/mod/ui/icon/basic/init.lua @@ -1,13 +1,13 @@ -local word = require("word") +local down = require("down") -local M = word.mod.create("ui.icon.basic") +local M = down.mod.create("ui.icon.basic") ----@class word.ui.icon.basic.Config -M.config.public = { +---@class down.ui.icon.basic.Config +M.config = { icon_basic = {}, } ----@class word.ui.icon.basic.Data +---@class down.ui.icon.basic.Data M.data = { icons = { default = { glyph = "󰟢", hl = "MiniIconsGrey" }, @@ -93,7 +93,7 @@ M.data = { ['function'] = { glyph = '', hl = 'MiniIconsAzure' }, interface = { glyph = '', hl = 'MiniIconsPurple' }, key = { glyph = '', hl = 'MiniIconsYellow' }, - keyword = { glyph = '', hl = 'MiniIconsCyan' }, + keydown = { glyph = '', hl = 'MiniIconsCyan' }, method = { glyph = '', hl = 'MiniIconsAzure' }, module = { glyph = '', hl = 'MiniIconsPurple' }, namespace = { glyph = '', hl = 'MiniIconsRed' }, diff --git a/lua/word/mod/ui/icon/diamond/README.md b/lua/down/mod/ui/icon/complex/README.md similarity index 100% rename from lua/word/mod/ui/icon/diamond/README.md rename to lua/down/mod/ui/icon/complex/README.md diff --git a/lua/word/mod/ui/icon/complex/init.lua b/lua/down/mod/ui/icon/complex/init.lua similarity index 71% rename from lua/word/mod/ui/icon/complex/init.lua rename to lua/down/mod/ui/icon/complex/init.lua index 6767d82..99f6981 100644 --- a/lua/word/mod/ui/icon/complex/init.lua +++ b/lua/down/mod/ui/icon/complex/init.lua @@ -1,10 +1,10 @@ -local word = require("word") -local mod = word.mod +local down = require("down") +local mod = down.mod local M = mod.create("ui.icon.diamond") ----@class word.ui.icon.diamond.Config -M.config.public = { +---@class down.ui.icon.diamond.Config +M.config = { icon_diamond = { heading = { icons = { "◈", "◇", "◆", "⋄", "❖", "⟡" }, @@ -24,7 +24,7 @@ M.config.public = { }, } ----@class word.ui.icon.diamond.Data +---@class down.ui.icon.diamond.Data M.data = {} return M diff --git a/lua/word/mod/ui/nav/README.md b/lua/down/mod/ui/icon/diamond/README.md similarity index 100% rename from lua/word/mod/ui/nav/README.md rename to lua/down/mod/ui/icon/diamond/README.md diff --git a/lua/word/mod/ui/icon/diamond/init.lua b/lua/down/mod/ui/icon/diamond/init.lua similarity index 71% rename from lua/word/mod/ui/icon/diamond/init.lua rename to lua/down/mod/ui/icon/diamond/init.lua index 6767d82..99f6981 100644 --- a/lua/word/mod/ui/icon/diamond/init.lua +++ b/lua/down/mod/ui/icon/diamond/init.lua @@ -1,10 +1,10 @@ -local word = require("word") -local mod = word.mod +local down = require("down") +local mod = down.mod local M = mod.create("ui.icon.diamond") ----@class word.ui.icon.diamond.Config -M.config.public = { +---@class down.ui.icon.diamond.Config +M.config = { icon_diamond = { heading = { icons = { "◈", "◇", "◆", "⋄", "❖", "⟡" }, @@ -24,7 +24,7 @@ M.config.public = { }, } ----@class word.ui.icon.diamond.Data +---@class down.ui.icon.diamond.Data M.data = {} return M diff --git a/lua/word/mod/ui/icon/init.lua b/lua/down/mod/ui/icon/init.lua similarity index 95% rename from lua/word/mod/ui/icon/init.lua rename to lua/down/mod/ui/icon/init.lua index f6e22b8..0e3d988 100644 --- a/lua/word/mod/ui/icon/init.lua +++ b/lua/down/mod/ui/icon/init.lua @@ -1,6 +1,6 @@ -local word = require("word") -local log, mod, utils = word.log, word.mod, word.utils -local u = require("word.mod.ui.icon.util") +local down = require("down") +local log, mod, utils = down.log, down.mod, down.utils +local u = require("down.mod.ui.icon.util") local M = mod.create("ui.icon", { "basic", @@ -368,10 +368,10 @@ local superscript_digits = { ["-"] = "⁻", } ----@class word.ui.icon.Data +---@class down.ui.icon.Data M.data = { - ns_icon = vim.api.nvim_create_namespace("word/icon"), - ns_prettify_flag = vim.api.nvim_create_namespace("word/icon.prettify-flag"), + ns_icon = vim.api.nvim_create_namespace("down/icon"), + ns_prettify_flag = vim.api.nvim_create_namespace("down/icon.prettify-flag"), rerendering_scheduled_bufids = {}, enabled = true, cursor_record = {}, @@ -662,8 +662,8 @@ M.data = { end, }, } ----@class word.ui.icon.Config -M.config.public = { +---@class down.ui.icon.Config +M.config = { -- Which icon preset to use. -- -- The currently available icon presets are: @@ -672,16 +672,16 @@ M.config.public = { -- - "varied" - use a mix of round and diamond shapes for headings; no cute flower icons though :( icon = "basic", - -- If true, word will enable folding by default for `.word` documents. + -- If true, down will enable folding by default for `.down` documents. -- You may use the inbuilt Neovim folding options like `foldnestmax`, -- `foldlevelstart` and others to then tune the behaviour to your liking. -- - -- Set to `false` if you do not want word setting anything. + -- Set to `false` if you do not want down setting anything. folds = true, - -- When set to `auto`, word will open all folds when opening new documents if `foldlevel` is 0. - -- When set to `always`, word will always open all folds when opening new documents. - -- When set to `never`, word will not do anything. + -- When set to `auto`, down will open all folds when opening new documents if `foldlevel` is 0. + -- When set to `always`, down will always open all folds when opening new documents. + -- When set to `never`, down will not do anything. mod_open_folds = "auto", -- Configuration for icons. @@ -775,12 +775,12 @@ M.config.public = { -- "quote6", }, highlights = { - "@word.quotes.1.prefix", - "@word.quotes.2.prefix", - "@word.quotes.3.prefix", - "@word.quotes.4.prefix", - "@word.quotes.5.prefix", - "@word.quotes.6.prefix", + "@down.quotes.1.prefix", + "@down.quotes.2.prefix", + "@down.quotes.3.prefix", + "@down.quotes.4.prefix", + "@down.quotes.5.prefix", + "@down.quotes.6.prefix", }, render = M.data.icon_renderers.quote_concealed, clear = M.data.icon_removers.quote, @@ -788,12 +788,12 @@ M.config.public = { heading = { icons = { "◉", "◎", "○", "✺", "▶", "⤷" }, highlights = { - "@word.headings.1.prefix", - "@word.headings.2.prefix", - "@word.headings.3.prefix", - "@word.headings.4.prefix", - "@word.headings.5.prefix", - "@word.headings.6.prefix", + "@down.headings.1.prefix", + "@down.headings.2.prefix", + "@down.headings.3.prefix", + "@down.headings.4.prefix", + "@down.headings.5.prefix", + "@down.headings.6.prefix", }, nodes = { -- "heading1_prefix", @@ -840,7 +840,7 @@ M.config.public = { -- When set to true, footnote link with numeric title will be -- concealed to superscripts. numeric_superscript = true, - title_highlight = "@word.footnotes.title", + title_highlight = "@down.footnotes.title", nodes = { "single_footnote_prefix", concealed = { "link_target_footnote" }, @@ -863,19 +863,19 @@ M.config.public = { delimiter = { weak = { icon = "⟨", - highlight = "@word.delimiters.weak", + highlight = "@down.delimiters.weak", nodes = { "weak_paragraph_delimiter" }, render = M.data.icon_renderers.fill_text, }, strong = { icon = "⟪", - highlight = "@word.delimiters.strong", + highlight = "@down.delimiters.strong", nodes = { "strong_paragraph_delimiter" }, render = M.data.icon_renderers.fill_text, }, horizontal_line = { icon = "─", - highlight = "@word.delimiters.horizontal_line", + highlight = "@down.delimiters.horizontal_line", nodes = { "horizontal_line" }, -- The starting position of horizontal lines: -- - "window": the horizontal line starts from the first column, reaching the left of the window @@ -892,7 +892,7 @@ M.config.public = { markup = { spoiler = { icon = "•", - highlight = "@word.markup.spoiler", + highlight = "@down.markup.spoiler", nodes = { "spoiler" }, render = M.data.icon_renderers.fill_multiline_chop2, }, @@ -934,7 +934,7 @@ M.config.public = { spell_check = true, nodes = { "ranged_verbatim_tag" }, - highlight = "@word.tags.ranged_verbatim.code_block", + highlight = "@down.tags.ranged_verbatim.code_block", render = M.data.icon_renderers.render_code_block, insert_enabled = true, }, @@ -1127,7 +1127,7 @@ local function get_parsed_query_lazy() local config_by_node_name = {} local queries = { "[" } - traverse_config(M.config.public.icons, function(config) + traverse_config(M.config.icons, function(config) for _, node_type in ipairs(config.nodes) do table.insert(queries, ("(%s)@icon"):format(node_type)) config_by_node_name[node_type] = config @@ -1374,7 +1374,7 @@ local function handle_mod_event(event) mark_all_lines_changed(event.buffer) if - M.config.public.folds + M.config.folds and vim.api.nvim_win_is_valid(event.window) and vim.api.nvim_buf_is_valid(event.buffer) then @@ -1388,7 +1388,7 @@ local function handle_mod_event(event) or "nvim_treesitter#foldexpr()" wo.foldtext = "" - local mod_open_folds = M.config.public.mod_open_folds + local mod_open_folds = M.config.mod_open_folds local function open_folds() vim.cmd("normal! zR") end @@ -1482,27 +1482,27 @@ end M.load = function() local icon = - M.import[M.name .. "." .. M.config.public.icon].config["icon_" .. M.config.public.icon] + M.import[M.name .. "." .. M.config.icon].config["icon_" .. M.config.icon] if not icon then log.error( ("Unable to load icon preset '%s' - such a preset does not exist"):format( - M.config.public.icon + M.config.icon ) ) return end - M.config.public = vim.tbl_deep_extend( + M.config = vim.tbl_deep_extend( "force", - M.config.public, + M.config, { icons = icon }, - M.config.public.custom or {} + M.config.custom or {} ) -- M.required["core.autocommands"].enable_autocommand("BufNewFile") - mod.await("cmd", function(wordcmd) - wordcmd.add_commands_from_table({ + mod.await("cmd", function(downcmd) + downcmd.add_commands_from_table({ toggle = { name = "icon.toggle", args = 0, diff --git a/lua/word/mod/ui/icon/util.lua b/lua/down/mod/ui/icon/util.lua similarity index 100% rename from lua/word/mod/ui/icon/util.lua rename to lua/down/mod/ui/icon/util.lua diff --git a/lua/word/mod/ui/init.lua b/lua/down/mod/ui/init.lua similarity index 95% rename from lua/word/mod/ui/init.lua rename to lua/down/mod/ui/init.lua index 8409934..2980fcd 100644 --- a/lua/word/mod/ui/init.lua +++ b/lua/down/mod/ui/init.lua @@ -1,5 +1,5 @@ -local word = require("word") -local log, mod = word.log, word.mod +local down = require("down") +local log, mod = down.log, down.mod local M = mod.create("ui", { -- "icon", @@ -18,7 +18,7 @@ M.load = function() end M.setup = function() return { - namespace = vim.api.nvim_create_namespace("word.ui"), + namespace = vim.api.nvim_create_namespace("down.ui"), requires = {}, loaded = true, } @@ -27,7 +27,7 @@ end ---@class base.ui M.data = { - namespace = vim.api.nvim_create_namespace("word.ui"), + namespace = vim.api.nvim_create_namespace("down.ui"), --- Returns a table in the form of { width, height } containing the width and height of the current window ---@param half boolean #If true returns a position that could be considered the center of the window get_window_size = function(half) @@ -92,7 +92,7 @@ M.data = { end, ---Creates a new horizontal split at the bottom of the screen - ---@param name string the name of the buffer contained within the split (will have word:// prepended to it) + ---@param name string the name of the buffer contained within the split (will have down:// prepended to it) ---@param config table? a table of