diff --git a/.icon/module.lua b/.icon/module.lua deleted file mode 100644 index 3e63c0e..0000000 --- a/.icon/module.lua +++ /dev/null @@ -1,612 +0,0 @@ ---[[ - file: conceal - title: Display Markup as Icons, not Text - description: The conceal M converts verbose markup elements into beautified icons for your viewing pleasure. - summary: Enhances the basic dorm experience by using icons instead of text. - embed: https://user-images.githubusercontent.com/76052559/216767027-726b451d-6da1-4d09-8fa4-d08ec4f93f54.png - --- -"Concealing" is the process of hiding away from plain sight. When writing raw dorm, long strings like -`***** Hello` or `$$ Definition` can be distracting and sometimes unpleasant when sifting through large notes. - -To reduce the amount of cognitive load required to "parse" dorm documents with your own eyes, this M -masks, or sometimes completely hides many categories of markup. - -The conceal depends on [Nerd Fonts >=v3.0.1](https://github.com/ryanoasis/nerd-fonts/releases/latest) to be -installed on your system. - -This M respects `:h conceallevel` and `:h concealcursor`. Setting the wrong values for these options can -make it look like this M isn't working. ---]] - --- utils to be refactored - -local d = require("dorm") -local u = require("dorm.mod.icon.util") -local log, mod, utils = d.log, d.mod, d.utils - - ---- end utils - -local M = mod.create("icon", { - -- "basic", - -- "diamond" -}) - -M.setup = function() - return { - success = true, - requires = { - "autocmd", - "treesitter", - }, - } -end - -M.private = { - ns_icon = utils.ns("dorm-icon"), - ns_prettify_flag = utils.ns("dorm-icon.prettify-flag"), - rerendering_scheduled_bufids = {}, - enabled = true, - cursor_record = {}, -} - - - ----@class base.icon -M.public = { - icon_renderers = { - on_left = function(config, bufid, node) - if not config.icon then - return - end - local row_0b, col_0b, len = get_node_position_and_text_length(bufid, node) - local text = (" "):rep(len - 1) .. config.icon - set_mark(bufid, row_0b, col_0b, text, config.highlight) - end, - - multilevel_on_right = function(is_ordered) - return function(config, bufid, node) - if not config.icons then - return - end - - local row_0b, col_0b, len = get_node_position_and_text_length(bufid, node) - local icon_pattern = table_get_base_last(config.icons, len) - if not icon_pattern then - return - end - - local icon = not is_ordered and icon_pattern - or format_ordered_icon(icon_pattern, get_ordered_index(bufid, node)) - if not icon then - return - end - - local text = (" "):rep(len - 1) .. icon - - local _, first_unicode_end = text:find("[%z\1-\127\194-\244][\128-\191]*", len) - local highlight = config.hl and table_get_base_last(config.hl, len) - set_mark(bufid, row_0b, col_0b, text:sub(1, first_unicode_end), highlight) - if vim.fn.strcharlen(text) > len then - set_mark(bufid, row_0b, col_0b + len, text:sub(first_unicode_end + 1), highlight, { - virt_text_pos = "inline", - }) - end - end - end, - - footnote_concealed = function(config, bufid, node) - local link_title_node = node:next_named_sibling() - local link_title = vim.treesitter.get_node_text(link_title_node, bufid) - if config.numeric_superscript and link_title:match("^[-0-9]+$") then - local t = {} - for i = 1, #link_title do - local d = link_title:sub(i, i) - table.insert(t, superscript_digits[d]) - end - local superscripted_title = table.concat(t) - local row_start_0b, col_start_0b, _, _ = link_title_node:range() - local highlight = config.title_highlight - set_mark(bufid, row_start_0b, col_start_0b, superscripted_title, highlight) - end - end, - - ---@param node TSNode - quote_concealed = function(config, bufid, node) - if not config.icons then - return - end - - local prefix = node:named_child(0) - - local row_0b, col_0b, len = get_node_position_and_text_length(bufid, prefix) - - local last_icon, last_highlight - - for _, child in ipairs(node:field("content")) do - local row_last_0b, col_last_0b = child:end_() - - -- Sometimes the parser overshoots to the next newline, breaking - -- the range. - -- To counteract this we correct the overshoot. - if col_last_0b == 0 then - row_last_0b = row_last_0b - 1 - end - - for line = row_0b, row_last_0b do - if get_line_length(bufid, line) > len then - for col = 1, len do - if config.icons[col] ~= nil then - last_icon = config.icons[col] - end - if not last_icon then - goto continue - end - last_highlight = config.hl[col] or last_highlight - set_mark(bufid, line, col_0b + (col - 1), last_icon, last_highlight) - ::continue:: - end - end - end - end - end, - - fill_text = function(config, bufid, node) - if not config.icon then - return - end - local row_0b, col_0b, len = get_node_position_and_text_length(bufid, node) - local text = config.icon:rep(len) - set_mark(bufid, row_0b, col_0b, text, config.highlight) - end, - - fill_multiline_chop2 = function(config, bufid, node) - if not config.icon then - return - end - local row_start_0b, col_start_0b, row_end_0bin, col_end_0bex = node:range() - for i = row_start_0b, row_end_0bin do - local l = i == row_start_0b and col_start_0b + 1 or 0 - local r_ex = i == row_end_0bin and col_end_0bex - 1 or get_line_length(bufid, i) - set_mark(bufid, i, l, config.icon:rep(r_ex - l), config.highlight) - end - end, - - render_horizontal_line = function(config, bufid, node) - if not config.icon then - return - end - - local row_start_0b, col_start_0b, _, col_end_0bex = node:range() - local render_col_start_0b = config.left == "here" and col_start_0b or 0 - local opt_textwidth = vim.bo[bufid].textwidth - local render_col_end_0bex = config.right == "textwidth" and (opt_textwidth > 0 and opt_textwidth or 79) - or vim.api.nvim_win_get_width(assert(vim.fn.bufwinid(bufid))) - local len = math.max(col_end_0bex - col_start_0b, render_col_end_0bex - render_col_start_0b) - set_mark(bufid, row_start_0b, render_col_start_0b, config.icon:rep(len), config.highlight) - end, - - render_code_block = function(config, bufid, node) - local tag_name = vim.treesitter.get_node_text(node:named_child(0), bufid) - if not (tag_name == "code" or tag_name == "embed") then - return - end - - local row_start_0b, col_start_0b, row_end_0bin = node:range() - assert(row_start_0b < row_end_0bin) - local conceal_on = (vim.wo.conceallevel >= 2) and config.conceal - - if conceal_on then - for _, row_0b in ipairs({ row_start_0b, row_end_0bin }) do - vim.api.nvim_buf_set_extmark( - bufid, - M.private.ns_icon, - row_0b, - 0, - { end_col = get_line_length(bufid, row_0b), conceal = "" } - ) - end - end - - if conceal_on or config.content_only then - row_start_0b = row_start_0b + 1 - row_end_0bin = row_end_0bin - 1 - end - - local line_lengths = {} - local max_len = config.min_width or 0 - for row_0b = row_start_0b, row_end_0bin do - local len = get_line_length(bufid, row_0b) - if len > max_len then - max_len = len - end - table.insert(line_lengths, len) - end - - local to_eol = (config.width ~= "content") - - for row_0b = row_start_0b, row_end_0bin do - local len = line_lengths[row_0b - row_start_0b + 1] - local mark_col_start_0b = math.max(0, col_start_0b - config.padding.left) - local mark_col_end_0bex = max_len + config.padding.right - local priority = 101 - if len >= mark_col_start_0b then - vim.api.nvim_buf_set_extmark(bufid, M.private.ns_icon, row_0b, mark_col_start_0b, { - end_row = row_0b + 1, - hl_eol = to_eol, - hl_group = config.highlight, - hl_mode = "blend", - virt_text = not to_eol and { { (" "):rep(mark_col_end_0bex - len), config.highlight } } or nil, - virt_text_pos = "overlay", - virt_text_win_col = len, - spell = config.spell_check, - priority = priority, - }) - else - vim.api.nvim_buf_set_extmark(bufid, M.private.ns_icon, row_0b, len, { - end_row = row_0b + 1, - hl_eol = to_eol, - hl_group = config.highlight, - hl_mode = "blend", - virt_text = { - { (" "):rep(mark_col_start_0b - len) }, - { not to_eol and (" "):rep(mark_col_end_0bex - mark_col_start_0b) or "", config.highlight }, - }, - virt_text_pos = "overlay", - virt_text_win_col = len, - spell = config.spell_check, - priority = priority, - }) - end - end - end, - }, - - icon_removers = { - quote = function(_, bufid, node) - for _, content in ipairs(node:field("content")) do - local end_row, end_col = content:end_() - - -- This counteracts the issue where a quote can span onto the next - -- line, even though it shouldn't. - if end_col == 0 then - end_row = end_row - 1 - end - - vim.api.nvim_buf_clear_namespace(bufid, M.private.ns_icon, (content:start()), end_row + 1) - end - end, - }, -} - -M.config.public = { - -- Which icon preset to use. - -- - -- The currently available icon presets are: - -- - "basic" - use a mixture of icons (includes cute flower icons!) - -- - "diamond" - use diamond shapes for headings - preset = "basic", - - -- If true, dorm will enable folding by base for `.dorm` 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 dorm setting anything. - folds = true, - - -- When set to `auto`, dorm will open all folds when opening new documents if `foldlevel` is 0. - -- When set to `always`, dorm will always open all folds when opening new documents. - -- When set to `never`, dorm will not do anything. - init_open_folds = "auto", - - -- Configuration for icons. - -- - -- This table contains the full configuration set for each icon, including - -- its query (where to be placed), render functions (how to be placed) and - -- characters to use. - -- - -- For most use cases, the only values that you should be changing is the `icon`/`icons` field. - -- `icon` is a string, while `icons` is a table of strings for multilevel elements like - -- headings, lists, and quotes. - -- - -- To disable part of the config, replace the table with `false`, or prepend `false and` to it. - -- For example: `done = false` or `done = false and { ... }`. - icons = { - todo = { - done = { - icon = "󰄬", - nodes = { "todo_item_done" }, - render = M.public.icon_renderers.on_left, - }, - pending = { - icon = "󰥔", - nodes = { "todo_item_pending" }, - render = M.public.icon_renderers.on_left, - }, - undone = { - icon = " ", - nodes = { "todo_item_undone" }, - render = M.public.icon_renderers.on_left, - }, - uncertain = { - icon = "", - nodes = { "todo_item_uncertain" }, - render = M.public.icon_renderers.on_left, - }, - on_hold = { - icon = "", - nodes = { "todo_item_on_hold" }, - render = M.public.icon_renderers.on_left, - }, - cancelled = { - icon = "", - nodes = { "todo_item_cancelled" }, - render = M.public.icon_renderers.on_left, - }, - recurring = { - icon = "↺", - nodes = { "todo_item_recurring" }, - render = M.public.icon_renderers.on_left, - }, - urgent = { - icon = "⚠", - nodes = { "todo_item_urgent" }, - render = M.public.icon_renderers.on_left, - }, - }, - - list = { - icons = { "•" }, - nodes = { - "unordered_list1_prefix", - "unordered_list2_prefix", - "unordered_list3_prefix", - "unordered_list4_prefix", - "unordered_list5_prefix", - "unordered_list6_prefix", - }, - render = M.public.icon_renderers.multilevel_on_right(false), - }, - ordered = { - icons = { "1.", "A.", "a.", "(1)", "I.", "i." }, - nodes = { - "ordered_list1_prefix", - "ordered_list2_prefix", - "ordered_list3_prefix", - "ordered_list4_prefix", - "ordered_list5_prefix", - "ordered_list6_prefix", - }, - render = M.public.icon_renderers.multilevel_on_right(true), - }, - quote = { - icons = { "│" }, - nodes = { - "quote1", - "quote2", - "quote3", - "quote4", - "quote5", - "quote6", - }, - hl = { - "@dorm.quotes.1.prefix", - "@dorm.quotes.2.prefix", - "@dorm.quotes.3.prefix", - "@dorm.quotes.4.prefix", - "@dorm.quotes.5.prefix", - "@dorm.quotes.6.prefix", - }, - render = M.public.icon_renderers.quote_concealed, - clear = M.public.icon_removers.quote, - }, - heading = { - icons = { "◉", "◎", "○", "✺", "▶", "⤷" }, - hl = { - "@dorm.headings.1.prefix", - "@dorm.headings.2.prefix", - "@dorm.headings.3.prefix", - "@dorm.headings.4.prefix", - "@dorm.headings.5.prefix", - "@dorm.headings.6.prefix", - }, - nodes = { - "heading1_prefix", - "heading2_prefix", - "heading3_prefix", - "heading4_prefix", - "heading5_prefix", - "heading6_prefix", - concealed = { - "link_target_heading1", - "link_target_heading2", - "link_target_heading3", - "link_target_heading4", - "link_target_heading5", - "link_target_heading6", - }, - }, - render = M.public.icon_renderers.multilevel_on_right(false), - }, - definition = { - single = { - icon = "≡", - nodes = { "single_definition_prefix", concealed = { "link_target_definition" } }, - render = M.public.icon_renderers.on_left, - }, - multi_prefix = { - icon = "⋙ ", - nodes = { "multi_definition_prefix" }, - render = M.public.icon_renderers.on_left, - }, - multi_suffix = { - icon = "⋘ ", - nodes = { "multi_definition_suffix" }, - render = M.public.icon_renderers.on_left, - }, - }, - - footnote = { - single = { - icon = "⁎", - -- When set to true, footnote link with numeric title will be - -- concealed to superscripts. - numeric_superscript = true, - title_highlight = "@dorm.footnotes.title", - nodes = { "single_footnote_prefix", concealed = { "link_target_footnote" } }, - render = M.public.icon_renderers.on_left, - render_concealed = M.public.icon_renderers.footnote_concealed, - }, - multi_prefix = { - icon = "⁑ ", - nodes = { "multi_footnote_prefix" }, - render = M.public.icon_renderers.on_left, - }, - multi_suffix = { - icon = "⁑ ", - nodes = { "multi_footnote_suffix" }, - render = M.public.icon_renderers.on_left, - }, - }, - - delimiter = { - weak = { - icon = "⟨", - highlight = "@dorm.delimiters.weak", - nodes = { "weak_paragraph_delimiter" }, - render = M.public.icon_renderers.fill_text, - }, - strong = { - icon = "⟪", - highlight = "@dorm.delimiters.strong", - nodes = { "strong_paragraph_delimiter" }, - render = M.public.icon_renderers.fill_text, - }, - horizontal_line = { - icon = "─", - highlight = "@dorm.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 - -- - "here": the horizontal line starts from the node column - left = "here", - -- The ending position of horizontal lines: - -- - "window": the horizontal line ends at the last column, reaching the right of the window - -- - "textwidth": the horizontal line ends at column `textwidth` or 79 when it's set to zero - right = "window", - render = M.public.icon_renderers.render_horizontal_line, - }, - }, - - markup = { - spoiler = { - icon = "•", - highlight = "@dorm.markup.spoiler", - nodes = { "spoiler" }, - render = M.public.icon_renderers.fill_multiline_chop2, - }, - }, - - -- Options that control the behaviour of code block dimming - -- (placing a darker background behind `@code` tags). - code_block = { - -- If true will only dim the content of the code block (without the - -- `@code` and `@end` lines), not the entirety of the code block itself. - content_only = true, - - -- The width to use for code block backgrounds. - -- - -- When set to `fullwidth` (the base), will create a background - -- that spans the width of the buffer. - -- - -- When set to `content`, will only span as far as the longest line - -- within the code block. - width = "fullwidth", - - -- When set to a number, the code block background will be at least - -- this many chars wide. Useful in conjunction with `width = "content"` - min_width = nil, - - -- Additional padding to apply to either the left or the right. Making - -- these values negative is considered undefined behaviour (it is - -- likely to work, but it's not officially supported). - padding = { - left = 0, - right = 0, - }, - - -- If `true` will conceal (hide) the `@code` and `@end` portion of the code - -- block. - conceal = false, - - -- If `false` will disable spell check on code blocks when 'spell' option is switched on. - spell_check = true, - - nodes = { "ranged_verbatim_tag" }, - highlight = "@dorm.tags.ranged_verbatim.code_block", - render = M.public.icon_renderers.render_code_block, - insert_enabled = true, - }, - }, -} - - -M.config.public = - vim.tbl_deep_extend("force", M.config.public, { icons = preset }, M.config.custom or {}) - --- M.required["autocmd"].enable_autocommand("BufNewFile") -M.required["autocmd"].enable_autocommand("FileType", true) -M.required["autocmd"].enable_autocommand("BufReadPost") -M.required["autocmd"].enable_autocommand("InsertEnter") -M.required["autocmd"].enable_autocommand("InsertLeave") -M.required["autocmd"].enable_autocommand("CursorMoved") -M.required["autocmd"].enable_autocommand("CursorMovedI") -M.required["autocmd"].enable_autocommand("WinScrolled", true) - -mod.await("cmd", function(cmd) - cmd.add_commands_from_table({ - ["icon"] = { - name = "icon", - args = 0, - condition = "dorm", - subcommands = { - ["toggle"] = { - args = 0, - name = "icon.toggle" - - } - } - }, - }) -end) - -vim.api.nvim_create_autocmd("OptionSet", { - pattern = "conceallevel", - callback = function() - local bufid = vim.api.nvim_get_current_buf() - if vim.bo[bufid].ft ~= "dorm" then - return - end - mark_all_lines_changed(bufid) - end, -}) --- end - -M.events.subscribed = { - ["autocmd"] = { - -- bufnewfile = true, - filetype = true, - bufreadpost = true, - insertenter = true, - insertleave = true, - cursormoved = true, - cursormovedi = true, - winscrolled = true, - }, - - ["cmd"] = { - ["icon.toggle"] = true, - }, -} - -return M diff --git a/.icon/util.lua b/.icon/util.lua deleted file mode 100644 index b457406..0000000 --- a/.icon/util.lua +++ /dev/null @@ -1,901 +0,0 @@ -M = {} - -local d = require "dorm" -local log, utils = d.log, d.utils - -M.in_range = function(k, l, r_ex) - return l <= k and k < r_ex -end - -M.is_concealing_on_row_range = function(mode, conceallevel, concealcursor, current_row_0b, row_start_0b, row_end_0bex) - if conceallevel < 1 then - return false - elseif not M.in_range(current_row_0b, row_start_0b, row_end_0bex) then - return true - else - return (concealcursor:find(mode) ~= nil) - end -end - -M.table_extend_in_place = function(tbl, tbl_ext) - for k, v in pairs(tbl_ext) do - tbl[k] = v - end -end - -M.get_node_position_and_text_length = function(bufid, node) - local row_start_0b, col_start_0b = node:range() - - -- FIXME parser: multi_definition_suffix, weak_paragraph_delimiter should not span across lines - -- assert(row_start_0b == row_end_0bin, row_start_0b .. "," .. row_end_0bin) - local text = vim.treesitter.get_node_text(node, bufid) - local past_end_offset_1b = text:find("%s") or text:len() + 1 - return row_start_0b, col_start_0b, (past_end_offset_1b - 1) -end - -M.get_header_prefix_node = function(header_node) - local first_child = header_node:child(0) - assert(first_child:type() == header_node:type() .. "_prefix") - return first_child -end - -M.get_line_length = function(bufid, row_0b) - return vim.api.nvim_strwidth(vim.api.nvim_buf_get_lines(bufid, row_0b, row_0b + 1, true)[1]) -end -M.roman_numerals = { - { "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix" }, - { "x", "xx", "xxx", "xl", "l", "lx", "lxx", "lxxx", "xc" }, - { "c", "cc", "ccc", "cd", "d", "dc", "dcc", "dccc", "cm" }, - { "m", "mm", "mmm" }, -} -M.set_mark = function(bufid, row_0b, col_0b, text, highlight, ext_opts) - local ns_icon = M.private.ns_icon - local opt = { - virt_text = { { text, highlight } }, - virt_text_pos = "overlay", - virt_text_win_col = nil, - hl_group = nil, - conceal = nil, - id = nil, - end_row = row_0b, - end_col = col_0b, - hl_eol = nil, - virt_text_hide = nil, - hl_mode = "combine", - virt_lines = nil, - virt_lines_above = nil, - virt_lines_leftcol = nil, - ephemeral = nil, - right_gravity = nil, - end_right_gravity = nil, - priority = nil, - strict = nil, -- base true - sign_text = nil, - sign_hl_group = nil, - number_hl_group = nil, - line_hl_group = nil, - cursorline_hl_group = nil, - spell = nil, - ui_watched = nil, - invalidate = true, - } - - if ext_opts then - M.table_extend_in_place(opt, ext_opts) - end - - vim.api.nvim_buf_set_extmark(bufid, ns_icon, row_0b, col_0b, opt) -end - -M.table_get_base_last = function(tbl, index) - return tbl[index] or tbl[#tbl] -end - -M.get_ordered_index = function(bufid, prefix_node) - -- TODO: calculate levels in one pass, since treesitter API implementation seems to have ridiculously high complexity - local _, _, level = M.get_node_position_and_text_length(bufid, prefix_node) - local header_node = prefix_node:parent() - -- TODO: fix parser: `(ERROR)` on standalone prefix not followed by text, like `- ` - -- assert(header_node:type() .. "_prefix" == prefix_node:type()) - local sibling = header_node:prev_named_sibling() - local count = 1 - - while sibling and (sibling:type() == header_node:type()) do - local _, _, sibling_level = M.get_node_position_and_text_length(bufid, M.get_header_prefix_node(sibling)) - if sibling_level < level then - break - elseif sibling_level == level then - count = count + 1 - end - sibling = sibling:prev_named_sibling() - end - - return count, (sibling or header_node:parent()) -end - -M.tbl_reverse = function(tbl) - local result = {} - for i = 1, #tbl do - result[i] = tbl[#tbl - i + 1] - end - return result -end - -M.tostring_lowercase = function(n) - local t = {} - while n > 0 do - t[#t + 1] = string.char(0x61 + (n - 1) % 26) - n = math.floor((n - 1) / 26) - end - return table.concat(t):reverse() -end - -M.tostring_roman_lowercase = function(n) - if n >= 4000 then - -- too large to render - return - end - - local result = {} - local i = 1 - while n > 0 do - result[#result + 1] = u.roman_numerals[i][n % 10] - n = math.floor(n / 10) - i = i + 1 - end - return table.concat(M.tbl_reverse(result)) -end - -M.ordered_icon_table = { - ["0"] = function(i) - return tostring(i - 1) - end, - ["1"] = function(i) - return tostring(i) - end, - ["a"] = function(i) - return M.tostring_lowercase(i) - end, - ["A"] = function(i) - return M.tostring_lowercase(i):upper() - end, - ["i"] = function(i) - return M.tostring_roman_lowercase(i) - end, - ["I"] = function(i) - return M.tostring_roman_lowercase(i):upper() - end, - ["Ⅰ"] = { - "Ⅰ", - "Ⅱ", - "Ⅲ", - "Ⅳ", - "Ⅴ", - "Ⅵ", - "Ⅶ", - "Ⅷ", - "Ⅸ", - "Ⅹ", - "Ⅺ", - "Ⅻ", - }, - ["ⅰ"] = { - "ⅰ", - "ⅱ", - "ⅲ", - "ⅳ", - "ⅴ", - "ⅵ", - "ⅶ", - "ⅷ", - "ⅸ", - "ⅹ", - "ⅺ", - "ⅻ", - }, - ["⒈"] = { - "⒈", - "⒉", - "⒊", - "⒋", - "⒌", - "⒍", - "⒎", - "⒏", - "⒐", - "⒑", - "⒒", - "⒓", - "⒔", - "⒕", - "⒖", - "⒗", - "⒘", - "⒙", - "⒚", - "⒛", - }, - ["⑴"] = { - "⑴", - "⑵", - "⑶", - "⑷", - "⑸", - "⑹", - "⑺", - "⑻", - "⑼", - "⑽", - "⑾", - "⑿", - "⒀", - "⒁", - "⒂", - "⒃", - "⒄", - "⒅", - "⒆", - "⒇", - }, - ["①"] = { - "①", - "②", - "③", - "④", - "⑤", - "⑥", - "⑦", - "⑧", - "⑨", - "⑩", - "⑪", - "⑫", - "⑬", - "⑭", - "⑮", - "⑯", - "⑰", - "⑱", - "⑲", - "⑳", - }, - ["⒜"] = { - "⒜", - "⒝", - "⒞", - "⒟", - "⒠", - "⒡", - "⒢", - "⒣", - "⒤", - "⒥", - "⒦", - "⒧", - "⒨", - "⒩", - "⒪", - "⒫", - "⒬", - "⒭", - "⒮", - "⒯", - "⒰", - "⒱", - "⒲", - "⒳", - "⒴", - "⒵", - }, - ["Ⓐ"] = { - "Ⓐ", - "Ⓑ", - "Ⓒ", - "Ⓓ", - "Ⓔ", - "Ⓕ", - "Ⓖ", - "Ⓗ", - "Ⓘ", - "Ⓙ", - "Ⓚ", - "Ⓛ", - "Ⓜ", - "Ⓝ", - "Ⓞ", - "Ⓟ", - "Ⓠ", - "Ⓡ", - "Ⓢ", - "Ⓣ", - "Ⓤ", - "Ⓥ", - "Ⓦ", - "Ⓧ", - "Ⓨ", - "Ⓩ", - }, - ["ⓐ"] = { - "ⓐ", - "ⓑ", - "ⓒ", - "ⓓ", - "ⓔ", - "ⓕ", - "ⓖ", - "ⓗ", - "ⓘ", - "ⓙ", - "ⓚ", - "ⓛ", - "ⓜ", - "ⓝ", - "ⓞ", - "ⓟ", - "ⓠ", - "ⓡ", - "ⓢ", - "ⓣ", - "ⓤ", - "ⓥ", - "ⓦ", - "ⓧ", - "ⓨ", - "ⓩ", - }, -} - -M.memoized_ordered_icon_generator = {} - -M.format_ordered_icon = function(pattern, index) - if type(pattern) == "function" then - return pattern(index) - end - - local gen = M.memoized_ordered_icon_generator[pattern] - if gen then - return gen(index) - end - - for char_one, number_table in pairs(M.ordered_icon_table) do - local l, r = pattern:find(char_one:find("%w") and "%f[%w]" .. char_one .. "%f[%W]" or char_one) - if l then - gen = function(index_) - local icon = type(number_table) == "function" and number_table(index_) or number_table[index_] - return icon and pattern:sub(1, l - 1) .. icon .. pattern:sub(r + 1) - end - break - end - end - - gen = gen or function(_) end - - M.memoized_ordered_icon_generator[pattern] = gen - return gen(index) -end - -M.superscript_digits = { - ["0"] = "⁰", - ["1"] = "¹", - ["2"] = "²", - ["3"] = "³", - ["4"] = "⁴", - ["5"] = "⁵", - ["6"] = "⁶", - ["7"] = "⁷", - ["8"] = "⁸", - ["9"] = "⁹", - ["-"] = "⁻", -} - -M.pos_eq = function(pos1, pos2) - return (pos1.x == pos2.x) and (pos1.y == pos2.y) -end - -M.pos_le = function(pos1, pos2) - return pos1.x < pos2.x or (pos1.x == pos2.x and pos1.y <= pos2.y) -end - --- M.pos_lt(pos1, pos2) --- return pos1.x < pos2.x or (pos1.x == pos2.x and pos1.y < pos2.y) --- end - -M.remove_extmarks = function(bufid, pos_start_0b_0b, pos_end_0bin_0bex) - assert(M.pos_le(pos_start_0b_0b, pos_end_0bin_0bex)) - if M.pos_eq(pos_start_0b_0b, pos_end_0bin_0bex) then - return - end - - local ns_icon = M.private.ns_icon - for _, result in - ipairs( - vim.api.nvim_buf_get_extmarks( - bufid, - ns_icon, - { pos_start_0b_0b.x, pos_start_0b_0b.y }, - { pos_end_0bin_0bex.x - ((pos_end_0bin_0bex.y == 0) and 1 or 0), pos_end_0bin_0bex.y - 1 }, - {} - ) - ) - do - local extmark_id = result[1] - -- TODO: Optimize - -- local node_pos_0b_0b = { x = result[2], y = result[3] } - -- assert( - -- pos_le(pos_start_0b_0b, node_pos_0b_0b) and pos_le(node_pos_0b_0b, pos_end_0bin_0bex), - -- ("start=%s, end=%s, node=%s"):format( - -- vim.inspect(pos_start_0b_0b), - -- vim.inspect(pos_end_0bin_0bex), - -- vim.inspect(node_pos_0b_0b) - -- ) - -- ) - vim.api.nvim_buf_del_extmark(bufid, ns_icon, extmark_id) - end -end - -M.is_inside_example = function(_) - -- TODO: waiting for parser fix - return false -end - -M.should_skip_prettify = function(mode, current_row_0b, node, config, row_start_0b, row_end_0bex) - local result - if config.insert_enabled then - result = false - elseif (mode == "i") and M.in_range(current_row_0b, row_start_0b, row_end_0bex) then - result = true - elseif M.is_inside_example(node) then - result = true - else - result = false - end - return result -end - -M.query_get_nodes = function(query, document_root, bufid, row_start_0b, row_end_0bex) - local result = {} - local concealed_node_ids = {} - for id, node in query:iter_captures(document_root, bufid, row_start_0b, row_end_0bex) do - if node:missing() then - goto continue - end - if query.captures[id] == "icon-concealed" then - concealed_node_ids[node:id()] = true - end - table.insert(result, node) - ::continue:: - end - return result, concealed_node_ids -end - -M.check_min = function(xy, x_new, y_new) - if (x_new < xy.x) or (x_new == xy.x and y_new < xy.y) then - xy.x = x_new - xy.y = y_new - end -end - -M.check_max = function(xy, x_new, y_new) - if (x_new > xy.x) or (x_new == xy.x and y_new > xy.y) then - xy.x = x_new - xy.y = y_new - end -end - -M.add_prettify_flag_line = function(bufid, row) - local ns_prettify_flag = M.private.ns_prettify_flag - vim.api.nvim_buf_set_extmark(bufid, ns_prettify_flag, row, 0, {}) -end - -M.add_prettify_flag_range = function(bufid, row_start_0b, row_end_0bex) - for row = row_start_0b, row_end_0bex - 1 do - M.add_prettify_flag_line(bufid, row) - end -end - -M.remove_prettify_flag_on_line = function(bufid, row_0b) - -- TODO: optimize - local ns_prettify_flag = M.private.ns_prettify_flag - vim.api.nvim_buf_clear_namespace(bufid, ns_prettify_flag, row_0b, row_0b + 1) -end - -M.remove_prettify_flag_range = function(bufid, row_start_0b, row_end_0bex) - -- TODO: optimize - local ns_prettify_flag = M.private.ns_prettify_flag - vim.api.nvim_buf_clear_namespace(bufid, ns_prettify_flag, row_start_0b, row_end_0bex) -end - -M.remove_prettify_flag_all = function(bufid) - M.remove_prettify_flag_range(bufid, 0, -1) -end - -M.get_visible_line_range = function(winid) - local row_start_1b = vim.fn.line("w0", winid) - local row_end_1b = vim.fn.line("w$", winid) - return (row_start_1b - 1), row_end_1b -end - -M.get_parsed_query_lazy = function() - if M.private.prettify_query then - return M.private.prettify_query - end - - local keys = { "config", "icons" } - M.traverse_config = function(config, f) - if config == false then - return - end - if config.nodes then - f(config) - return - end - if type(config) ~= "table" then - log.warn(("unsupported icon config: %s = %s"):format(table.concat(keys, "."), config)) - return - end - local key_pos = #keys + 1 - for key, sub_config in pairs(config) do - keys[key_pos] = key - M.traverse_config(sub_config, f) - keys[key_pos] = nil - end - end - - local config_by_node_name = {} - local queries = { "[" } - - M.traverse_config(M.config.public.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 - end - for _, node_type in ipairs(config.nodes.concealed or {}) do - table.insert(queries, ("(%s)@icon-concealed"):format(node_type)) - config_by_node_name[node_type] = config - end - end) - - table.insert(queries, "]") - local query_combined = table.concat(queries, " ") - M.private.prettify_query = utils.ts_parse_query("dorm", query_combined) - assert(M.private.prettify_query) - M.private.config_by_node_name = config_by_node_name - return M.private.prettify_query -end - -M.prettify_range = function(bufid, row_start_0b, row_end_0bex) - -- in case there's undo/removal garbage - -- TODO: optimize - row_end_0bex = math.min(row_end_0bex + 1, vim.api.nvim_buf_line_count(bufid)) - - local treesitter_M = M.required["treesitter"] - local document_root = treesitter_M.get_document_root(bufid) - assert(document_root) - - local nodes, concealed_node_ids = - M.query_get_nodes(M.get_parsed_query_lazy(), document_root, bufid, row_start_0b, row_end_0bex) - - local winid = vim.fn.bufwinid(bufid) - assert(winid > 0) - local current_row_0b = vim.api.nvim_win_get_cursor(winid)[1] - 1 - local current_mode = vim.api.nvim_get_mode().mode - local conceallevel = vim.wo[winid].conceallevel - local concealcursor = vim.wo[winid].concealcursor - - assert(document_root) - - for _, node in ipairs(nodes) do - local node_row_start_0b, node_col_start_0b, node_row_end_0bin, node_col_end_0bex = node:range() - local node_row_end_0bex = node_row_end_0bin + 1 - local config = M.private.config_by_node_name[node:type()] - - if config.clear then - config:clear(bufid, node) - else - local pos_start_0b_0b, pos_end_0bin_0bex = - { x = node_row_start_0b, y = node_col_start_0b }, { x = node_row_end_0bin, y = node_col_end_0bex } - - M.check_min(pos_start_0b_0b, node:start()) - M.check_max(pos_end_0bin_0bex, node:end_()) - - M.remove_extmarks(bufid, pos_start_0b_0b, pos_end_0bin_0bex) - end - - M.remove_prettify_flag_range(bufid, node_row_start_0b, node_row_end_0bex) - M.add_prettify_flag_range(bufid, node_row_start_0b, node_row_end_0bex) - - if M.should_skip_prettify(current_mode, current_row_0b, node, config, node_row_start_0b, node_row_end_0bex) then - goto continue - end - - local has_conceal = ( - concealed_node_ids[node:id()] - and (not config.check_conceal or config.check_conceal(node)) - and M.is_concealing_on_row_range( - current_mode, - conceallevel, - concealcursor, - current_row_0b, - node_row_start_0b, - node_row_end_0bex - ) - ) - - if has_conceal then - if config.render_concealed then - config:render_concealed(bufid, node) - end - else - config:render(bufid, node) - end - - ::continue:: - end -end - -M.render_window_buffer = function(bufid) - local ns_prettify_flag = M.private.ns_prettify_flag - local winid = vim.fn.bufwinid(bufid) - local row_start_0b, row_end_0bex = M.get_visible_line_range(winid) - local prettify_flags_0b = vim.api.nvim_buf_get_extmarks( - bufid, - ns_prettify_flag, - { row_start_0b, 0 }, - { row_end_0bex - 1, -1 }, - {} - ) - local row_nomark_start_0b, row_nomark_end_0bin - local i_flag = 1 - for i = row_start_0b, row_end_0bex - 1 do - while i_flag <= #prettify_flags_0b and i > prettify_flags_0b[i_flag][2] do - i_flag = i_flag + 1 - end - - if i_flag <= #prettify_flags_0b and i == prettify_flags_0b[i_flag][2] then - i_flag = i_flag + 1 - else - assert(i < (prettify_flags_0b[i_flag] and prettify_flags_0b[i_flag][2] or row_end_0bex)) - row_nomark_start_0b = row_nomark_start_0b or i - row_nomark_end_0bin = i - end - end - - assert((row_nomark_start_0b == nil) == (row_nomark_end_0bin == nil)) - if row_nomark_start_0b then - M.prettify_range(bufid, row_nomark_start_0b, row_nomark_end_0bin + 1) - end -end - -M.render_all_scheduled_and_done = function() - for bufid, _ in pairs(M.private.rerendering_scheduled_bufids) do - if vim.fn.bufwinid(bufid) >= 0 then - M.render_window_buffer(bufid) - end - end - M.private.rerendering_scheduled_bufids = {} -end - -M.schedule_rendering = function(bufid) - local not_scheduled = vim.tbl_isempty(M.private.rerendering_scheduled_bufids) - M.private.rerendering_scheduled_bufids[bufid] = true - if not_scheduled then - vim.schedule(M.render_all_scheduled_and_done) - end -end - -M.mark_line_changed = function(bufid, row_0b) - M.remove_prettify_flag_on_line(bufid, row_0b) - M.schedule_rendering(bufid) -end - -M.mark_line_range_changed = function(bufid, row_start_0b, row_end_0bex) - M.remove_prettify_flag_range(bufid, row_start_0b, row_end_0bex) - M.schedule_rendering(bufid) -end - -M.mark_all_lines_changed = function(bufid) - if not M.private.enabled then - return - end - - M.remove_prettify_flag_all(bufid) - M.schedule_rendering(bufid) -end - -M.clear_all_extmarks = function(bufid) - local ns_icon = M.private.ns_icon - local ns_prettify_flag = M.private.ns_prettify_flag - vim.api.nvim_buf_clear_namespace(bufid, ns_icon, 0, -1) - vim.api.nvim_buf_clear_namespace(bufid, ns_prettify_flag, 0, -1) -end - -M.get_table_base_empty = function(tbl, key) - if not tbl[key] then - tbl[key] = {} - end - return tbl[key] -end - -M.update_cursor = function(event) - local cursor_record = M.get_table_base_empty(M.private.cursor_record, event.buffer) - cursor_record.row_0b = event.cursor_position[1] - 1 - cursor_record.col_0b = event.cursor_position[2] - cursor_record.line_content = event.line_content -end - -M.handle_init_event = function(event) - assert(vim.api.nvim_win_is_valid(event.window)) - M.update_cursor(event) - - M.on_line_callback( - tag, - bufid, - _changedtick, ---@diagnostic disable-line -- TODO: type error workaround - row_start_0b, - _row_end_0bex, ---@diagnostic disable-line -- TODO: type error workaround - row_updated_0bex, - _n_byte_prev ---@diagnostic disable-line -- TODO: type error workaround - ) - assert(tag == "lines") - - if not M.private.enabled then - return - end - - M.mark_line_range_changed(bufid, row_start_0b, row_updated_0bex) -end - -local attach_succeeded = vim.api.nvim_buf_attach(event.buffer, true, { on_lines = M.on_line_callback }) -assert(attach_succeeded) -local language_tree = vim.treesitter.get_parser(event.buffer, "markdown") - -local bufid = event.buffer --- used for detecting non-local (multiline) changes, like spoiler / code block --- TODO: exemption in certain cases, for example when changing only heading followed by pure texts, --- in which case all its descendents would be unnecessarily re-concealed. -M.on_changedtree_callback = function(ranges) - -- TODO: abandon if too large - for i = 1, #ranges do - local range = ranges[i] - local row_start_0b = range[1] - local row_end_0bex = range[3] + 1 - M.remove_prettify_flag_range(bufid, row_start_0b, row_end_0bex) - end -end - -language_tree:register_cbs({ on_changedtree = M.on_changedtree_callback }) -mark_all_lines_changed(event.buffer) - -if - M.config.public.folds - and vim.api.nvim_win_is_valid(event.window) - and vim.api.nvim_buf_is_valid(event.buffer) -then - vim.api.nvim_buf_call(event.buffer, function() - -- NOTE(vhyrro): `vim.wo` only supports `wo[winid][0]`, - -- hence the `buf_call` here. - local wo = vim.wo[event.window][0] - wo.foldmethod = "expr" - wo.foldexpr = vim.treesitter.foldexpr and "v:lua.vim.treesitter.foldexpr()" or "nvim_treesitter#foldexpr()" - wo.foldtext = "" - - local init_open_folds = M.config.public.init_open_folds - M.open_folds = function() - vim.cmd("normal! zR") - end - - if init_open_folds == "always" then - M.open_folds() - elseif init_open_folds == "never" then -- luacheck:ignore 542 - -- do nothing - else - if init_open_folds ~= "auto" then - log.warn('"init_open_folds" must be "auto", "always", or "never"') - end - - if wo.foldlevel == 0 then - M.open_folds() - end - end - end) -end - -M.handle_insert_toggle = function(event) - M.mark_line_changed(event.buffer, event.cursor_position[1] - 1) -end - -M.handle_insertenter = function(event) - M.handle_insert_toggle(event) -end - -M.handle_insertleave = function(event) - M.handle_insert_toggle(event) -end - -M.handle_toggle_prettifier = function(event) - -- FIXME: M.private.enabled should be a map from bufid to boolean - M.private.enabled = not M.private.enabled - if M.private.enabled then - M.mark_all_lines_changed(event.buffer) - else - M.private.rerendering_scheduled_bufids[event.buffer] = nil - M.clear_all_extmarks(event.buffer) - end -end - -M.is_same_line_movement = function(event) - -- some operations like dd / u cannot yet be listened reliably - -- below is our best approximation - local cursor_record = M.private.cursor_record - return ( - cursor_record - and cursor_record.row_0b == event.cursor_position[1] - 1 - and cursor_record.col_0b ~= event.cursor_position[2] - and cursor_record.line_content == event.line_content - ) -end - -M.handle_cursor_moved = function(event) - -- reveal/conceal when conceallevel>0 - -- also triggered when dd / u - if not M.is_same_line_movement(event) then - local cursor_record = M.private.cursor_record[event.buffer] - if cursor_record then - -- leaving previous line, conceal it if necessary - M.mark_line_changed(event.buffer, cursor_record.row_0b) - end - -- entering current line, conceal it if necessary - local current_row_0b = event.cursor_position[1] - 1 - M.mark_line_changed(event.buffer, current_row_0b) - end - M.update_cursor(event) -end - -M.handle_cursor_moved_i = function(event) - return M.handle_cursor_moved(event) -end - -M.handle_winscrolled = function(event) - M.schedule_rendering(event.buffer) -end - -M.handle_filetype = function(event) - M.handle_init_event(event) -end - -local event_handlers = { - ["cmd.events.base.icon.toggle"] = M.handle_toggle_prettifier, - -- ["autocmd.events.bufnewfile"] = M.handle_init_event, - ["autocmd.events.filetype"] = M.handle_filetype, - ["autocmd.events.bufreadpost"] = M.handle_init_event, - ["autocmd.events.insertenter"] = M.handle_insertenter, - ["autocmd.events.insertleave"] = M.handle_insertleave, - ["autocmd.events.cursormoved"] = M.handle_cursor_moved, - ["autocmd.events.cursormovedi"] = M.handle_cursor_moved_i, - ["autocmd.events.winscrolled"] = M.handle_winscrolled, -} - -M.on_event = function(event) - if event.referrer == "autocmd" and vim.bo[event.buffer].ft ~= "dorm" then - return - end - - if (not M.private.enabled) and (event.type ~= "cmd.events.base.icon.toggle") then - return - end - return event_handlers[event.type](event) -end - -M.load = function() - local preset = - M.imported[M.name .. "." .. M.config.public.preset].config.private - ["preset_" .. M.config.public.preset] - if not preset then - log.error( - ("Unable to load icon preset '%s' - such a preset does not exist"):format(M.config.public.preset) - ) - return - end -end - -return M diff --git a/.null-ls_851613_flake.nix b/.null-ls_851613_flake.nix new file mode 100644 index 0000000..b103691 --- /dev/null +++ b/.null-ls_851613_flake.nix @@ -0,0 +1,14 @@ +{ + description = "word.lua"; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + }; + + outputs = { self, nixpkgs }: { + + packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello; + + packages.x86_64-linux.default = self.packages.x86_64-linux.hello; + + }; +} diff --git a/README.md b/README.md index daa4fa3..27a021d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# dorm - the _familiar_, organized future for neovim +# word - 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) @@ -7,7 +7,7 @@ ## Introduction -- **dorm** is a plugin meant to bring the awesome extensibility of emacs [org-mode] or [neorg] without needing to switch from the gold standard [markdown], or from the best editor [neovim]. +- **word** is a plugin meant to bring the awesome extensibility of emacs [org-mode] or [neorg] without needing to switch from the gold standard [markdown], or from the best editor [neovim]. - we want to be able to take notes like developers, without shutting ourselves out of the entire ecosystem built around markdown. @@ -23,7 +23,7 @@ ```lua { - "clpi/dorm.lua", + "clpi/word.lua", lazy = false, version = false, config = true, @@ -36,9 +36,9 @@ ### plug.vim ```vim -Plug "clpi/dorm.lua", { +Plug "clpi/word.lua", { \ "branch" : "main", - \ "do" : ":lua require('dorm').setup()" + \ "do" : ":lua require('word').setup()" \ } ``` @@ -57,7 +57,7 @@ use { }, tag = "*", config = function() - require("dorm").setup() + require("word").setup() end, } ``` @@ -78,8 +78,8 @@ check back! thank you and keep updated! -- [The Dorm book](https://dorm.cli.st) -- [dorm.lua on luarocks](https://luarocks.org/modules/clpi/dorm.lua) +- [The word book](https://word.cli.st) +- [word.lua on luarocks](https://luarocks.org/modules/clpi/word.lua) diff --git a/TODO.md b/TODO.md index e69de29..4640904 100644 --- a/TODO.md +++ b/TODO.md @@ -0,0 +1 @@ +# TODO diff --git a/book/book.toml b/book/book.toml index daeaf88..4928db4 100644 --- a/book/book.toml +++ b/book/book.toml @@ -3,4 +3,4 @@ authors = ["Chris Pecunies"] language = "en" multilingual = false src = "src" -title = "The dorm.lua book" +title = "The word.lua book" diff --git a/book/src/intro.md b/book/src/intro.md index b8f6d05..5ce8893 100644 --- a/book/src/intro.md +++ b/book/src/intro.md @@ -1,8 +1,8 @@ -# dorm.lua +# word.lua ## Intro -`dorm.lua` is a simple ORM for Lua. It is designed to be simple to use and +`word.lua` is a simple ORM for Lua. It is designed to be simple to use and ## Is it for you? diff --git a/doc/dorm.md b/doc/dorm.md deleted file mode 100644 index f9bacba..0000000 --- a/doc/dorm.md +++ /dev/null @@ -1 +0,0 @@ -# The dorm diff --git a/doc/dorm.lua.txt b/doc/word.lua.txt similarity index 82% rename from doc/dorm.lua.txt rename to doc/word.lua.txt index 8cd0bbf..96a47fb 100644 --- a/doc/dorm.lua.txt +++ b/doc/word.lua.txt @@ -1,20 +1,20 @@ -*dorm.lua.txt* dorm.lua +*word.lua.txt* word.lua Author: Chris Pecunies -INTRODUCTION *dorm.lua* +INTRODUCTION *word.lua* ================================================================================ -`dorm.lua` is a plugin to bring the extensibility of org-mode to neovim without +`word.lua` is a plugin to bring the extensibility of org-mode to neovim without leaving the gold standard markdown file format. -ABOUT *dorm-about* +ABOUT *word-about* ================================================================================ To be filled out -TODO *dorm-todo* +TODO *word-todo* ================================================================================ - [ ] Separate commands and mods `(11/15 22:43)` @@ -22,15 +22,15 @@ TODO *dorm-todo - [ ] Easy linking of files by title, and easy colloqial hierarchy `(11/1522:43)` - [ ] Easy tagging of tracked todos, easy disparate categ. of todos -LINKS *dorm-links* +LINKS *word-links* ================================================================================ Grab the latest version or report a bug on GitHub: -https://github.com/clpi/dorm.lua +https://github.com/clpi/word.lua Or visit the website: -https://dorm.clp.is +https://word.clp.is vim:tw=80:colorcolumn=81:et:ft=help:norl: diff --git a/doc/word.md b/doc/word.md new file mode 100644 index 0000000..e3cfbb5 --- /dev/null +++ b/doc/word.md @@ -0,0 +1,6 @@ +# The word + +- [ ] Separate commands and mods `(11/15 22:43)` +- [ ] Docgen `(11/15 22:43)` +- [ ] Easy linking of files by title, and easy colloqial hierarchy `(11/1522:43)` +- [ ] Easy tagging of tracked todos, easy disparate categ. of todos diff --git a/flake.nix b/flake.nix index bb2747f..b103691 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "dorm.lua"; + description = "word.lua"; inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; }; diff --git a/lua/dorm/mod/completion/module.lua b/lua/dorm/mod/completion/module.lua deleted file mode 100644 index c2d305a..0000000 --- a/lua/dorm/mod/completion/module.lua +++ /dev/null @@ -1,9 +0,0 @@ -local dib = require "dib" - -local M = dib.mod.create("data") - -M.load = function() - -end - -return M diff --git a/lua/dorm/mod/search/module.lua b/lua/dorm/mod/search/module.lua deleted file mode 100644 index c39398f..0000000 --- a/lua/dorm/mod/search/module.lua +++ /dev/null @@ -1,62 +0,0 @@ -local d = require("dorm") - -local lib, mod, cfg = d.lib, d.mod, d.config - -local module = mod.create("search") - -module.load = function() - mod.await("cmd", function(cmd) - cmd.add_commands_from_table({ - ["search"] = { - subcommands = { - update = { - args = 0, - name = "search.update" - }, - insert = { - name = "search.insert", - args = 0, - }, - }, - name = "search" - } - }) - end) -end - - - -module.setup = function() - return { - success = true, - requires = { - "workspace" - } - - } -end - -module.public = { - -} - -module.config.private = { - -} -module.config.public = { - -} -module.private = { - -} -module.events = {} - - -module.events.subscribed = { - cmd = { - ["search.insert"] = true, - ["search.update"] = true, - }, -} - -return module diff --git a/lua/telescope/_extensions/dorm/util/init.lua b/lua/telescope/_extensions/dorm/util/init.lua deleted file mode 100644 index f6b74d7..0000000 --- a/lua/telescope/_extensions/dorm/util/init.lua +++ /dev/null @@ -1,9 +0,0 @@ -M = {} - -function M.dorm(ns) - local hasdorm, v = pcall(require, "dorm") - assert(hasdorm, "dorm is not loaded - load it before telescope") - vim.api.nvim_create_namespace(ns) -end - -return M diff --git a/lua/telescope/_extensions/dorm/finders/browse.lua b/lua/telescope/_extensions/word/finders/browse.lua similarity index 100% rename from lua/telescope/_extensions/dorm/finders/browse.lua rename to lua/telescope/_extensions/word/finders/browse.lua diff --git a/lua/telescope/_extensions/dorm/finders/files.lua b/lua/telescope/_extensions/word/finders/files.lua similarity index 100% rename from lua/telescope/_extensions/dorm/finders/files.lua rename to lua/telescope/_extensions/word/finders/files.lua diff --git a/lua/telescope/_extensions/dorm/finders/grep.lua b/lua/telescope/_extensions/word/finders/grep.lua similarity index 100% rename from lua/telescope/_extensions/dorm/finders/grep.lua rename to lua/telescope/_extensions/word/finders/grep.lua diff --git a/lua/dorm/cmd/custom/init.lua b/lua/telescope/_extensions/word/finders/init.lua similarity index 100% rename from lua/dorm/cmd/custom/init.lua rename to lua/telescope/_extensions/word/finders/init.lua diff --git a/lua/telescope/_extensions/dorm/finders/root.lua b/lua/telescope/_extensions/word/finders/root.lua similarity index 100% rename from lua/telescope/_extensions/dorm/finders/root.lua rename to lua/telescope/_extensions/word/finders/root.lua diff --git a/lua/telescope/_extensions/dorm/init.lua b/lua/telescope/_extensions/word/init.lua similarity index 85% rename from lua/telescope/_extensions/dorm/init.lua rename to lua/telescope/_extensions/word/init.lua index 41fff8b..857062a 100644 --- a/lua/telescope/_extensions/dorm/init.lua +++ b/lua/telescope/_extensions/word/init.lua @@ -11,7 +11,7 @@ local srt = require("telescope.sorters") local bui = require("telescope.builtin") local win = require("telescope.pickers.window") -local has_dorm, dorm = pcall(require, "dorm") +local has_word, word = pcall(require, "word") local M = {} @@ -19,12 +19,12 @@ local M = {} function M.setup_keys() local map = vim.api.nvim_set_keymap local opt = { noremap = true, silent = true } - map("n", ",vv", "lua require('telescope._extensions.dorm').custom_picker()", opt) + map("n", ",vv", "lua require('telescope._extensions.word').custom_picker()", opt) end function M.custom_picker() pic.new({}, { - prompt_title = "dorm", + prompt_title = "word", sorter = srt.get_generic_fuzzy_sorter(), finder = fnd.new_table { results = { @@ -37,9 +37,9 @@ function M.custom_picker() local selection = act.get_selected_entry() act.close(prompt_bufnr) if selection.value == 'Index' then - require('dorm.index').index() + require('word.index').index() elseif selection.value == 'Notes' then - require('dorm.notes').notes() + require('word.notes').notes() end end) return true @@ -59,7 +59,7 @@ function M.setup() } }) - tel.load_extension("dorm") + tel.load_extension("word") end return M diff --git a/lua/telescope/_extensions/word/util/init.lua b/lua/telescope/_extensions/word/util/init.lua new file mode 100644 index 0000000..3b7e099 --- /dev/null +++ b/lua/telescope/_extensions/word/util/init.lua @@ -0,0 +1,9 @@ +M = {} + +function M.word(ns) + local hasword, v = pcall(require, "word") + assert(hasword, "word is not loaded - load it before telescope") + vim.api.nvim_create_namespace(ns) +end + +return M diff --git a/lua/dorm/mod/README.md b/lua/word/cmd/README.md similarity index 100% rename from lua/dorm/mod/README.md rename to lua/word/cmd/README.md diff --git a/lua/dorm/cmd/find/init.lua b/lua/word/cmd/custom/init.lua similarity index 100% rename from lua/dorm/cmd/find/init.lua rename to lua/word/cmd/custom/init.lua diff --git a/lua/dorm/cmd/init.lua b/lua/word/cmd/find/init.lua similarity index 100% rename from lua/dorm/cmd/init.lua rename to lua/word/cmd/find/init.lua diff --git a/lua/dorm/cmd/return/init.lua b/lua/word/cmd/init.lua similarity index 100% rename from lua/dorm/cmd/return/init.lua rename to lua/word/cmd/init.lua diff --git a/lua/dorm/lsp/init.lua b/lua/word/cmd/return/init.lua similarity index 100% rename from lua/dorm/lsp/init.lua rename to lua/word/cmd/return/init.lua diff --git a/lua/dorm/config/default.lua b/lua/word/config/default.lua similarity index 100% rename from lua/dorm/config/default.lua rename to lua/word/config/default.lua diff --git a/lua/dorm/config/init.lua b/lua/word/config/init.lua similarity index 62% rename from lua/dorm/config/init.lua rename to lua/word/config/init.lua index 85682e0..6755a2e 100644 --- a/lua/dorm/config/init.lua +++ b/lua/word/config/init.lua @@ -1,8 +1,8 @@ --- @brief [[ ---- Defines the configuration table for use throughout dorm. +--- Defines the configuration table for use throughout word. --- @brief ]] --- TODO(vhyrro): Make `dorm_version` and `version` a `Version` class. +-- TODO(vhyrro): Make `word_version` and `version` a `Version` class. --- @alias OperatingSystem --- | "windows" @@ -12,24 +12,24 @@ --- | "linux" --- | "bsd" ---- @alias dorm.configuration.module { config?: table } +--- @alias word.configuration.module { config?: table } ---- @class (exact) dorm.configuration.user ---- @field hook? fun(manual: boolean, arguments?: string) A user-defined function that is invoked whenever dorm starts up. May be used to e.g. set custom keybindings. ---- @field lazy_loading? boolean Whether to defer loading the dorm base until after the user has entered a `.dorm` file. ---- @field load table A list of mod to load, alongside their configurations. ---- @field logger? dorm.log.configuration A configuration table for the logger. +--- @class (exact) word.configuration.user +--- @field hook? fun(manual: boolean, arguments?: string) A user-defined function that is invoked whenever word starts up. May be used to e.g. set custom keybindings. +--- @field lazy_loading? boolean Whether to defer loading the word base until after the user has entered a `.word` file. +--- @field load table A list of mod to load, alongside their configurations. +--- @field logger? word.log.configuration A configuration table for the logger. ---- @class (exact) dorm.configuration ---- @field arguments table A list of arguments provided to the `:DormStart` function in the form of `key=value` pairs. Only applicable when `user_config.lazy_loading` is `true`. ---- @field manual boolean? Used if dorm was manually loaded via `:DormStart`. Only applicable when `user_config.lazy_loading` is `true`. ---- @field mod table Acts as a copy of the user's configuration that may be modified at runtime. ---- @field dorm_version string The version of the file format to be used throughout dorm. Used internally. ---- @field os_info OperatingSystem The operating system that dorm is currently running under. ---- @field pathsep "\\"|"/" The operating system that dorm is currently running under. ---- @field started boolean Set to `true` when dorm is fully initialized. ---- @field user_config dorm.configuration.user Stores the configuration provided by the user. ---- @field version string The version of dorm that is currently active. Automatically updated by CI on every release. +--- @class (exact) word.configuration +--- @field arguments table A list of arguments provided to the `:wordStart` function in the form of `key=value` pairs. Only applicable when `user_config.lazy_loading` is `true`. +--- @field manual boolean? Used if word was manually loaded via `:wordStart`. Only applicable when `user_config.lazy_loading` is `true`. +--- @field mod table Acts as a copy of the user's configuration that may be modified at runtime. +--- @field word_version string The version of the file format to be used throughout word. Used internally. +--- @field os_info OperatingSystem The operating system that word is currently running under. +--- @field pathsep "\\"|"/" The operating system that word is currently running under. +--- @field started boolean Set to `true` when word is fully initialized. +--- @field user_config word.configuration.user Stores the configuration provided by the user. +--- @field version string The version of word that is currently active. Automatically updated by CI on every release. --- Gets the current operating system. --- @return OperatingSystem @@ -56,17 +56,17 @@ local function get_os_info() return "bsd" end - error("[dorm]: Unable to determine the currently active operating system!") + error("[word]: Unable to determine the currently active operating system!") end local os_info = get_os_info() ---- Stores the configuration for the entirety of dorm. +--- Stores the configuration for the entirety of word. --- This includes not only the user configuration (passed to `setup()`), but also internal --- variables that describe something specific about the user's hardware. ---- @see dorm.setup +--- @see word.setup --- ---- @type dorm.configuration +--- @type word.configuration local config = { user_config = { lazy_loading = false, @@ -81,7 +81,7 @@ local config = { manual = nil, arguments = {}, - dorm_version = "1.1.1", + word_version = "1.1.1", version = "9.1.1", os_info = os_info, diff --git a/lua/dorm/init.lua b/lua/word/init.lua similarity index 63% rename from lua/dorm/init.lua rename to lua/word/init.lua index 3f9ba03..16ef491 100644 --- a/lua/dorm/init.lua +++ b/lua/word/init.lua @@ -2,29 +2,29 @@ --- This file marks the beginning of the entire plugin. It's here that everything fires up and starts pumping. --- @brief ]] -local dorm = { - callbacks = require("dorm.util.callback"), - config = require("dorm.config"), - lsp = require("dorm.lsp"), - cmd = require("dorm.cmd"), - ui = require("dorm.ui"), - log = require("dorm.util.log"), - mod = require("dorm.mod"), - utils = require("dorm.util"), - lib = require("dorm.util.lib") +local word = { + callbacks = require("word.util.callback"), + config = require("word.config"), + lsp = require("word.lsp"), + cmd = require("word.cmd"), + ui = require("word.ui"), + log = require("word.util.log"), + mod = require("word.mod"), + utils = require("word.util"), + lib = require("word.util.lib") } -local config, log, mod, utils = dorm.config, dorm.log, dorm.mod, dorm.utils +local config, log, mod, utils = word.config, word.log, word.mod, word.utils ---- @module "dorm.config" +--- @module "word.config" ---- Initializes dorm. Parses the supplied user configuration, initializes all selected mod and adds filetype checking for `.dorm`. ---- @param cfg dorm.configuration.user? A table that reflects the structure of `config.user_config`. +--- Initializes word. Parses the supplied user configuration, initializes all selected mod and adds filetype checking for `.word`. +--- @param cfg word.configuration.user? A table that reflects the structure of `config.user_config`. --- @see config.user_config ---- @see dorm.configuration.user -function dorm.setup(cfg) +--- @see word.configuration.user +function word.setup(cfg) -- Ensure that we are running Neovim 0.10+ - assert(utils.is_minimum_version(0, 10, 0), "dorm requires at least Neovim version 0.10 to operate!") + assert(utils.is_minimum_version(0, 10, 0), "word requires at least Neovim version 0.10 to operate!") -- If the user supplied no configuration then generate a base one (assume the user wants the base) cfg = cfg or { @@ -33,7 +33,7 @@ function dorm.setup(cfg) workspace = { config = { workspaces = { - dorm = "~/dorm" + word = "~/word" } } } @@ -54,24 +54,24 @@ function dorm.setup(cfg) config.user_config = vim.tbl_deep_extend("force", config.user_config, cfg) - -- Create a new global instance of the dorm logger. + -- Create a new global instance of the word logger. log.new(config.user_config.logger or log.get_base_config(), true) - -- If the file we have entered has a `.dorm` extension: - if vim.fn.expand("%:e") == "dorm" or not config.user_config.lazy_loading then + -- If the file we have entered has a `.word` extension: + if vim.fn.expand("%:e") == "word" or not config.user_config.lazy_loading then -- Then boot up the environment. - dorm.org_file_entered(false) + word.org_file_entered(false) else - -- Else listen for a BufAdd event for `.dorm` files and fire up the dorm environment. - vim.api.nvim_create_user_command("dormStart", function() - vim.cmd.delcommand("dormStart") - dorm.org_file_entered(true) + -- Else listen for a BufAdd event for `.word` files and fire up the word environment. + vim.api.nvim_create_user_command("wordStart", function() + vim.cmd.delcommand("wordStart") + word.org_file_entered(true) end, {}) vim.api.nvim_create_autocmd("BufAdd", { - pattern = "dorm", + pattern = "word", callback = function() - dorm.org_file_entered(false) + word.org_file_entered(false) end, }) end @@ -80,14 +80,14 @@ function dorm.setup(cfg) mod.load_modules() end ---- This function gets called upon entering a .dorm file and loads all of the user-defined mod. +--- This function gets called upon entering a .word file and loads all of the user-defined mod. --- @param manual boolean If true then the environment was kickstarted manually by the user. --- @param arguments string? A list of arguments in the format of "key=value other_key=other_value". -function dorm.org_file_entered(manual, arguments) +function word.org_file_entered(manual, arguments) -- Extract the module list from the user config local module_list = config.user_config and config.user_config.load or {} - -- If we have already started dorm or if we haven't defined any mod to load then bail + -- If we have already started word or if we haven't defined any mod to load then bail if config.started or not module_list or vim.tbl_isempty(module_list) then return end @@ -97,10 +97,10 @@ function dorm.org_file_entered(manual, arguments) config.user_config.hook(manual, arguments) end - -- If dorm was loaded manually (through `:DormStart`) then set this flag to true + -- If word was loaded manually (through `:wordStart`) then set this flag to true config.manual = manual - -- If the user has supplied any dorm environment variables + -- If the user has supplied any word environment variables -- then parse those here if arguments and arguments:len() > 0 then for key, value in arguments:gmatch("([%w%W]+)=([%w%W]+)") do @@ -124,15 +124,15 @@ function dorm.org_file_entered(manual, arguments) end end - -- Goes through each loaded module and invokes dorm_post_load() + -- Goes through each loaded module and invokes word_post_load() for _, module in pairs(mod.loaded_mod) do - module.dorm_post_load() + module.word_post_load() end - -- Set this variable to prevent dorm from loading twice + -- Set this variable to prevent word from loading twice config.started = true - -- Lets the entire dorm environment know that dorm has started! + -- Lets the entire word environment know that word has started! mod.broadcast_event({ type = "started", split_type = { "base", "started" }, @@ -149,15 +149,15 @@ function dorm.org_file_entered(manual, arguments) -- Sometimes external plugins prefer hooking in to an autocommand vim.api.nvim_exec_autocmds("User", { - pattern = "dormStarted", + pattern = "wordStarted", }) end ---- Returns whether or not dorm is loaded +--- Returns whether or not word is loaded --- @return boolean -function dorm.is_loaded() +function word.is_loaded() return config.started end --- require("telescope").load_extension("dorm") -return dorm +-- require("telescope").load_extension("word") +return word diff --git a/lua/dorm/mod/web/init.lua b/lua/word/lsp/init.lua similarity index 100% rename from lua/dorm/mod/web/init.lua rename to lua/word/lsp/init.lua diff --git a/lua/dorm/mod/export/module.lua b/lua/word/mod/README.md similarity index 100% rename from lua/dorm/mod/export/module.lua rename to lua/word/mod/README.md diff --git a/lua/dorm/mod/autocmd/module.lua b/lua/word/mod/autocmd/module.lua similarity index 94% rename from lua/dorm/mod/autocmd/module.lua rename to lua/word/mod/autocmd/module.lua index 729b04b..dc1106d 100644 --- a/lua/dorm/mod/autocmd/module.lua +++ b/lua/word/mod/autocmd/module.lua @@ -36,17 +36,17 @@ Upon receiving an event, it will come in this format: ``` --]] -local dorm = require("dorm") -local log, mod = dorm.log, dorm.mod +local word = require("word") +local log, mod = word.log, word.mod local module = mod.create("autocmd") --- This function gets invoked whenever a base.autocmd enabled autocommand is triggered. Note that this function should be only used internally ---@param name string #The name of the autocommand that was just triggered ----@param triggered_from_dorm boolean #If true, that means we have received this event as part of a *.dorm autocommand +---@param triggered_from_word boolean #If true, that means we have received this event as part of a *.word autocommand ---@param ev? table the original event data -function _dorm_module_autocommand_triggered(name, triggered_from_dorm, ev) - local event = mod.create_event(module, name, { dorm = triggered_from_dorm }, ev) +function _word_module_autocommand_triggered(name, triggered_from_word, ev) + local event = mod.create_event(module, name, { word = triggered_from_word }, ev) assert(event) mod.broadcast_event(event) end @@ -61,7 +61,7 @@ module.public = { --- By base, all autocmd are disabled for performance reasons. To enable them, use this command. If an invalid autocmd is given nothing happens. ---@param autocmd string #The relative name of the autocommand to enable - ---@param dont_isolate boolean #base to false. Specifies whether the autocommand should run globally (* instead of in dorm files (*.dorm) + ---@param dont_isolate boolean #base to false. Specifies whether the autocommand should run globally (* instead of in word files (*.word) enable_autocommand = function(autocmd, dont_isolate) dont_isolate = dont_isolate or false @@ -69,19 +69,19 @@ module.public = { local subscribed_autocommand = module.events.subscribed["autocmd"][autocmd] if subscribed_autocommand ~= nil then - vim.cmd("augroup dorm") + vim.cmd("augroup word") - if dont_isolate and vim.fn.exists("#dorm#" .. autocmd .. "#*") == 0 then + if dont_isolate and vim.fn.exists("#word#" .. autocmd .. "#*") == 0 then vim.api.nvim_create_autocmd(autocmd, { callback = function(ev) - _dorm_module_autocommand_triggered("autocmd.events." .. autocmd, false, ev) + _word_module_autocommand_triggered("autocmd.events." .. autocmd, false, ev) end, }) - elseif vim.fn.exists("#dorm#" .. autocmd .. "#*.dorm") == 0 then + elseif vim.fn.exists("#word#" .. autocmd .. "#*.word") == 0 then vim.api.nvim_create_autocmd(autocmd, { - pattern = "*.dorm", + pattern = "*.word", callback = function(ev) - _dorm_module_autocommand_triggered("autocmd.events." .. autocmd, true, ev) + _word_module_autocommand_triggered("autocmd.events." .. autocmd, true, ev) end, }) end diff --git a/lua/dorm/mod/base/module.lua b/lua/word/mod/base/module.lua similarity index 90% rename from lua/dorm/mod/base/module.lua rename to lua/word/mod/base/module.lua index df0ff70..6175c9a 100644 --- a/lua/dorm/mod/base/module.lua +++ b/lua/word/mod/base/module.lua @@ -22,8 +22,8 @@ load = { ``` --]] -local dorm = require("dorm") -local mod = dorm.mod +local word = require("word") +local mod = word.mod return mod.create_meta( -- "treesitter", @@ -36,6 +36,8 @@ return mod.create_meta( "cmd", "store", "code", + "export", + "preview", "pick", -- "icon", "lsp", @@ -53,5 +55,6 @@ return mod.create_meta( "todo", "ui", "calendar", + "publish", "link" ) diff --git a/lua/dorm/mod/calendar/module.lua b/lua/word/mod/calendar/module.lua similarity index 99% rename from lua/dorm/mod/calendar/module.lua rename to lua/word/mod/calendar/module.lua index 6789561..0ac3cee 100644 --- a/lua/dorm/mod/calendar/module.lua +++ b/lua/word/mod/calendar/module.lua @@ -10,8 +10,8 @@ also be launched in standalone mode, select date range mode and others. To view keys and help, press `?` in the calendar view. --]] -local dorm = require("dorm") -local mod = dorm.mod +local word = require("word") +local mod = word.mod local module = mod.create("calendar") diff --git a/lua/dorm/mod/calendar/views/monthly/module.lua b/lua/word/mod/calendar/views/monthly/module.lua similarity index 99% rename from lua/dorm/mod/calendar/views/monthly/module.lua rename to lua/word/mod/calendar/views/monthly/module.lua index 7eaa2cf..55e8461 100644 --- a/lua/dorm/mod/calendar/views/monthly/module.lua +++ b/lua/word/mod/calendar/views/monthly/module.lua @@ -1,5 +1,5 @@ -local dorm = require("dorm") -local lib, log, mod, utils = dorm.lib, dorm.log, dorm.mod, dorm.utils +local word = require("word") +local lib, log, mod, utils = word.lib, word.log, word.mod, word.utils local module = mod.create("calendar.views.monthly") @@ -18,8 +18,8 @@ end module.private = { namespaces = { - logical = vim.api.nvim_create_namespace("dorm/calendar/logical"), - decorational = vim.api.nvim_create_namespace("dorm/calendar/decorational"), + logical = vim.api.nvim_create_namespace("word/calendar/logical"), + decorational = vim.api.nvim_create_namespace("word/calendar/decorational"), }, set_extmark = function(ui_info, namespace, row, col, length, virt_text, alignment, extra) @@ -563,7 +563,7 @@ module.private = { callback = quit, }) - local namespace = vim.api.nvim_create_namespace("dorm/calendar-help") + local namespace = vim.api.nvim_create_namespace("word/calendar-help") vim.api.nvim_buf_set_option(buffer, "modifiable", false) vim.api.nvim_buf_set_extmark(buffer, namespace, 0, 0, { @@ -1111,16 +1111,16 @@ module.public = { }, {}, { - { "Tuesday May 5th 2023 19:00.23", "@dorm.markup.verbatim" }, + { "Tuesday May 5th 2023 19:00.23", "@word.markup.verbatim" }, }, { - { "10 Feb CEST 0600", "@dorm.markup.verbatim" }, + { "10 Feb CEST 0600", "@word.markup.verbatim" }, { " (", "@comment" }, { "0600", "@text.emphasis" }, { " is the year)", "@comment" }, }, { - { "9:00.4 2nd March Wed", "@dorm.markup.verbatim" }, + { "9:00.4 2nd March Wed", "@word.markup.verbatim" }, }, }), { buffer = buffer } diff --git a/lua/dorm/mod/capture/module.lua b/lua/word/mod/capture/module.lua similarity index 96% rename from lua/dorm/mod/capture/module.lua rename to lua/word/mod/capture/module.lua index f1075a4..9901a74 100644 --- a/lua/dorm/mod/capture/module.lua +++ b/lua/word/mod/capture/module.lua @@ -1,4 +1,4 @@ -local d = require("dorm") +local d = require("word") local lib, mod = d.lib, d.mod local module = mod.create("capture") diff --git a/lua/dorm/mod/cmd/commands/return/module.lua b/lua/word/mod/cmd/commands/return/module.lua similarity index 78% rename from lua/dorm/mod/cmd/commands/return/module.lua rename to lua/word/mod/cmd/commands/return/module.lua index 182d13f..a9eac92 100644 --- a/lua/dorm/mod/cmd/commands/return/module.lua +++ b/lua/word/mod/cmd/commands/return/module.lua @@ -1,15 +1,15 @@ --[[ file: cmd-return - title: Provides the `:Dorm return` Command - summary: Return to last location before entering dorm. + title: Provides the `:word return` Command + summary: Return to last location before entering word. internal: true --- -When executed (`:Dorm return`), all currently open `.dorm` files are deleted from +When executed (`:word return`), all currently open `.word` files are deleted from the buffer list, and the current workspace is set to "base". --]] -local dorm = require("dorm") -local mod = dorm.mod +local word = require("word") +local mod = word.mod local module = mod.create("cmd.commands.return") @@ -18,7 +18,7 @@ module.setup = function() end module.public = { - dorm_commands = { + word_commands = { ["return"] = { args = 0, name = "return", @@ -34,7 +34,7 @@ module.on_event = 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 .dorm extension then remove it (not forcibly) + -- If the listed buffer we're working with has a .word 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/dorm/mod/cmd/module.lua b/lua/word/mod/cmd/module.lua similarity index 84% rename from lua/dorm/mod/cmd/module.lua rename to lua/word/mod/cmd/module.lua index 319b59c..8103391 100644 --- a/lua/dorm/mod/cmd/module.lua +++ b/lua/word/mod/cmd/module.lua @@ -1,10 +1,10 @@ --[[ file: cmd-Module - title: Does the Heavy Lifting for the `:Dorm` Command - summary: This module deals with handling everything related to the `:Dorm` command. + title: Does the Heavy Lifting for the `:word` Command + summary: This module deals with handling everything related to the `:word` command. internal: true --- -This internal module handles everything there is for the `:Dorm` command to function. +This internal module handles everything there is for the `:word` command to function. Different mod can define their own commands, completions and conditions on when they'd like these commands to be avaiable. @@ -14,13 +14,13 @@ For a full example on how to create your own command, it is recommended to read which walks you through the necessary steps. --]] -local dorm = require("dorm") -local log, mod = dorm.log, dorm.mod +local word = require("word") +local log, mod = word.log, word.mod local module = mod.create("cmd") module.examples = { - ["Adding a dorm command"] = function() + ["Adding a word command"] = function() -- In your module.setup(), make sure to require base.cmd (requires = { "cmd" }) -- Afterwards in a function of your choice that gets called *after* base.cmd gets intialized e.g. load(): @@ -31,8 +31,8 @@ module.examples = { min_args = 1, -- Tells cmd that we want at least one argument for this command max_args = 1, -- Tells cmd we want no more than one argument args = 1, -- Setting this variable instead would be the equivalent of min_args = 1 and max_args = 1 - -- This command is only avaiable within `.dorm` files. - -- This can also be a function(bufnr, is_in_an_dorm_file) + -- This command is only avaiable within `.word` files. + -- This can also be a function(bufnr, is_in_an_word_file) condition = "markdown", subcommands = { -- Defines subcommands @@ -74,7 +74,7 @@ module.examples = { -- To enable a command in the commands/ directory, do this: - require("dorm").setup({ + require("word").setup({ load = { ["cmd"] = { config = { @@ -87,15 +87,15 @@ module.examples = { }) -- And that's it! You're good to go. - -- Want to find out more? Read the wiki entry! https://github.com/nvim-dorm/dorm/wiki/dorm-Command + -- Want to find out more? Read the wiki entry! https://github.com/nvim-word/word/wiki/word-Command end, } module.load = function() - -- Define the :Dorm command with autocompletion taking any number of arguments (-nargs=*) + -- Define the :word 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("Dorm", module.private.command_callback, { - desc = "The dorm command", + vim.api.nvim_create_user_command("Word", module.private.command_callback, { + desc = "The word command", force = true, -- bang = true, nargs = "*", @@ -130,7 +130,7 @@ module.config.public = { ---@class base.cmd module.public = { -- The table containing all the functions. This can get a tad complex so I recommend you read the wiki entry - dorm_commands = { + word_commands = { module = { subcommands = { -- new = { @@ -150,30 +150,30 @@ module.public = { }, }, - --- Recursively merges the contents of the module's config.public.funtions table with base.cmd's module.config.public.dorm_commands table. - ---@param module_name string #An absolute path to a loaded module with a module.config.public.dorm_commands table following a valid structure + --- Recursively merges the contents of the module's config.public.funtions table with base.cmd's module.config.public.word_commands table. + ---@param module_name string #An absolute path to a loaded module with a module.config.public.word_commands table following a valid structure add_commands = function(module_name) local module_config = mod.get_module(module_name) - if not module_config or not module_config.dorm_commands then + if not module_config or not module_config.word_commands then return end - module.public.dorm_commands = - vim.tbl_extend("force", module.public.dorm_commands, module_config.dorm_commands) + module.public.word_commands = + vim.tbl_extend("force", module.public.word_commands, module_config.word_commands) end, - --- Recursively merges the provided table with the module.config.public.dorm_commands table. - ---@param functions table #A table that follows the module.config.public.dorm_commands structure + --- Recursively merges the provided table with the module.config.public.word_commands table. + ---@param functions table #A table that follows the module.config.public.word_commands structure add_commands_from_table = function(functions) - module.public.dorm_commands = vim.tbl_extend("force", module.public.dorm_commands, functions) + module.public.word_commands = vim.tbl_extend("force", module.public.word_commands, functions) end, --- Takes a relative path (e.g "list.mod") and loads it from the commands/ directory ---@param name string #The relative path of the module we want to load add_commands_from_file = function(name) -- Attempt to require the file - local err, ret = pcall(require, "dorm.mod.cmd.commands." .. name .. ".module") + local err, ret = pcall(require, "word.mod.cmd.commands." .. name .. ".module") -- If we've failed bail out if not err then @@ -193,14 +193,14 @@ module.public = { sync = function() -- Loop through every loaded module and set up all their commands for _, mod in pairs(mod.loaded_mod) do - if mod.public.dorm_commands then - module.public.add_commands_from_table(mod.public.dorm_commands) + if mod.public.word_commands then + module.public.add_commands_from_table(mod.public.word_commands) end end 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 dorm`. + ---@param callback function The same function format as you would receive by being called by `:command -completion=customlist,v:lua.callback word`. set_completion_callback = function(callback) module.private.generate_completions = callback end, @@ -212,26 +212,26 @@ module.private = { local args = data.fargs local current_buf = vim.api.nvim_get_current_buf() - local is_dorm = vim.bo[current_buf].filetype == "markdown" + local is_word = vim.bo[current_buf].filetype == "markdown" local function check_condition(condition) if condition == nil then return true end - if condition == "dorm" and not is_dorm then + if condition == "word" and not is_word then return false end if type(condition) == "function" then - return condition(current_buf, is_dorm) + return condition(current_buf, is_word) end return condition end local ref = { - subcommands = module.public.dorm_commands, + subcommands = module.public.word_commands, } local argument_index = 0 @@ -244,14 +244,14 @@ module.private = { if not ref then log.error( - ("Error when executing `:Dorm %s` - such a command does not exist!"):format( + ("Error when executing `:word %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 `:Dorm %s` - the command is currently disabled. Some commands will only become available under certain conditions, e.g. being within a `.dorm` file!") + ("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( table.concat(vim.list_slice(args, 1, i), " ") ) @@ -275,12 +275,12 @@ module.private = { end if #args == 0 or argument_count < ref.min_args then - local completions = module.private.generate_completions(_, table.concat({ "Dorm ", data.args, " " })) + local completions = module.private.generate_completions(_, table.concat({ "word ", data.args, " " })) module.private.select_next_cmd_arg(data.args, completions) return elseif argument_count > ref.max_args then log.error( - ("Error when executing `:Dorm %s` - too many arguments supplied! The command expects %s argument%s.") + ("Error when executing `:word %s` - too many arguments supplied! The command expects %s argument%s.") :format( data.args, ref.max_args == 0 and "no" or ref.max_args, @@ -292,7 +292,7 @@ module.private = { if not ref.name then log.error( - ("Error when executing `:Dorm %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 module.") + ("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 module.") :format( data.args ) @@ -315,24 +315,24 @@ module.private = { ) end, - --- This function returns all available commands to be used for the :Dorm command + --- This function returns all available commands to be used for the :word 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_dorm = vim.api.nvim_buf_get_option(current_buf, "filetype") == "dorm" + local is_word = vim.api.nvim_buf_get_option(current_buf, "filetype") == "word" local function check_condition(condition) if condition == nil then return true end - if condition == "dorm" and not is_dorm then + if condition == "word" and not is_word then return false end if type(condition) == "function" then - return condition(current_buf, is_dorm) + return condition(current_buf, is_word) end return condition @@ -349,7 +349,7 @@ module.private = { ) local ref = { - subcommands = module.public.dorm_commands, + subcommands = module.public.word_commands, } local last_valid_ref = ref local last_completion_level = 0 @@ -370,14 +370,14 @@ module.private = { 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_dorm) + last_valid_ref.complete = last_valid_ref.complete(current_buf, is_word) end if vim.endswith(command, " ") then local completions = last_valid_ref.complete[#splitcmd - last_completion_level + 1] or {} if type(completions) == "function" then - completions = completions(current_buf, is_dorm) or {} + completions = completions(current_buf, is_word) or {} end return completions @@ -385,7 +385,7 @@ module.private = { local completions = last_valid_ref.complete[#splitcmd - last_completion_level] or {} if type(completions) == "function" then - completions = completions(current_buf, is_dorm) or {} + completions = completions(current_buf, is_word) or {} end return vim.tbl_filter(function(key) @@ -394,7 +394,7 @@ module.private = { end end - -- TODO: Fix `:Dorm m ` giving invalid completions + -- TODO: Fix `:word m ` giving invalid completions local keys = ref and vim.tbl_keys(ref.subcommands or {}) or ( vim.tbl_filter(function(key) @@ -413,10 +413,10 @@ module.private = { end, --- Queries the user to select next argument - ---@param qargs table #A string of arguments previously supplied to the dorm command + ---@param qargs table #A string of arguments previously supplied to the word command ---@param choices table #all possible choices for the next argument select_next_cmd_arg = function(qargs, choices) - local current = table.concat({ "dorm ", qargs }) + local current = table.concat({ "word ", qargs }) local query @@ -440,7 +440,7 @@ module.private = { end, } -module.dorm_post_load = module.public.sync +module.word_post_load = module.public.sync module.on_event = function(event) if event.type == "cmd.events.module.load" then @@ -482,7 +482,7 @@ module.on_event = function(event) local lines = {} - for name, _ in pairs(dorm.mod.loaded_mod) do + for name, _ in pairs(word.mod.loaded_mod) do table.insert(lines, "- `" .. name .. "`") end diff --git a/lua/dorm/mod/code/module.lua b/lua/word/mod/code/module.lua similarity index 95% rename from lua/dorm/mod/code/module.lua rename to lua/word/mod/code/module.lua index 43c0f3c..8363105 100644 --- a/lua/dorm/mod/code/module.lua +++ b/lua/word/mod/code/module.lua @@ -1,16 +1,16 @@ --[[ file: Tangling title: From Code Blocks to Files - description: The `base.code` module exports code blocks within a `.dorm` file straight to a file of your choice. + description: The `base.code` module exports code blocks within a `.word` file straight to a file of your choice. summary: An Advanced Code Block Exporter. --- The goal of this module is to allow users to spit out the contents of code blocks into -many different files. This is the primary component required for a literate configuration in dorm, -where the configuration is annotated and described in a `.dorm` document, and the actual code itself +many different files. This is the primary component required for a literate configuration in word, +where the configuration is annotated and described in a `.word` document, and the actual code itself is thrown out into a file that can then be normally consumed by e.g. an application. The `code` module currently provides a single command: -- `:Dorm code current-file` - performs all possible tangling operations on the current file +- `:word code current-file` - performs all possible tangling operations on the current file ### Usage Tutorial By base, *zero* code blocks are coded. You must provide where you'd like to code each code @@ -18,7 +18,7 @@ block manually (global configuration will be discussed later). To do so, add a ` ` tag above the code block you'd wish to export, where is relative to the current file. For example: -```dorm +```word #code init.lua @code lua print("Hello World!") @@ -28,7 +28,7 @@ The above snippet will *only* code that single code block to the desired output #### Global Tangling for Single Files Apart from tangling a single or a set of code blocks, you can declare a global output file in the document's metadata: -```dorm +```word @document.meta code: ./init.lua @end @@ -39,7 +39,7 @@ the `#code` tag takes precedence. #### Global Tangling for Multiple Files Apart from a single filepath, you can provide many in an array: -```dorm +```word @document.meta code: [ ./init.lua @@ -48,12 +48,12 @@ code: [ @end ``` -The above snippet tells the dorm tangling engine to code all `lua` code blocks to `./init.lua` and all `haskell` code blocks to `./output.hs`. +The above snippet tells the word tangling engine to code all `lua` code blocks to `./init.lua` and all `haskell` code blocks to `./output.hs`. As always if any of the code blocks have a `#code` tag then that takes precedence. #### Ignoring Code Blocks Sometimes when tangling you may want to omit some code blocks. For this you may use the `#code.none` tag: -```dorm +```word #code.none @code lua print("I won't be coded!") @@ -63,7 +63,7 @@ print("I won't be coded!") #### Global Tangling with Extra Options But wait, it doesn't stop there! You can supply a string to `code`, an array to `code`, but also an object! It looks like this: -```dorm +```word @document.meta code: { languages: { @@ -85,7 +85,7 @@ The following variations are allowed: * `heading` -- Try to determine the filetype of the code block and insert any headings from the original document as a comment in the coded output. If filetype detection fails, `newline` will be used instead. -* `file-content` -- Try to determine the filetype of the codeblock and insert the dorm file content as a delimiter. +* `file-content` -- Try to determine the filetype of the codeblock and insert the word file content as a delimiter. If filetype detection fails, `none` will be used instead. * `newline` -- Use an extra newline between coded blocks. * `none` -- Do not add any delimiter. This implies that the code blocks are inserted into the code target as-is. @@ -99,13 +99,13 @@ with `#code.none`. There are two other types: `tagged` and `main`. ##### The `tagged` Scope When in this mode, the coder will only code code blocks that have been `tagged` with a `#code` tag. Note that you don't have to always provide a filetype, and that: -```dorm +```word #code @code lua @end ``` Will use the global output file for that language as defined in the metadata. I.e., if I do: -```dorm +```word @document.meta code: { languages: { @@ -134,7 +134,7 @@ can probably see that this system can get expressive pretty quick. ##### The `main` scope This mode is the opposite of the `tagged` one in that it will only code code blocks to files that are defined in the document metadata. I.e. in this case: -```dorm +```word @document.meta code: { languages: { @@ -161,8 +161,8 @@ print("Ayo") The first code block will be coded to `./output.lua`, the second code block will also be coded to `./output.lua` and the third code block will be ignored. --]] -local dorm = require("dorm") -local lib, mod, utils, log = dorm.lib, dorm.mod, dorm.utils, dorm.log +local word = require("word") +local lib, mod, utils, log = word.lib, word.mod, word.utils, word.log local module = mod.create("code") local Path = require("pathlib") @@ -181,7 +181,7 @@ module.load = function() cmd.add_commands_from_table({ code = { args = 1, - condition = "dorm", + condition = "word", subcommands = { ["current-file"] = { @@ -198,12 +198,12 @@ module.load = function() end) if module.config.public.code_on_write then - local augroup = vim.api.nvim_create_augroup("dorm_auto_code", { clear = true }) + local augroup = vim.api.nvim_create_augroup("word_auto_code", { clear = true }) vim.api.nvim_create_autocmd("BufWritePost", { desc = "code the current file on write", - pattern = "*.dorm", + pattern = "*.word", group = augroup, - command = "dorm code current-file", + command = "word code current-file", }) end end @@ -273,7 +273,7 @@ module.public = { ]], }) - local query = utils.ts_parse_query("dorm", query_str) + local query = utils.ts_parse_query("word", query_str) local previous_headings = {} local commentstrings = {} local file_content_line_start = {} @@ -297,7 +297,7 @@ module.public = { local declared_filetype = parsed_tag.parameters[1] local block_content = parsed_tag.content - if parsed_tag.parameters[1] == "dorm" then + if parsed_tag.parameters[1] == "word" then for i, line in ipairs(block_content) do -- remove escape char local new_line, _ = line:gsub("\\(.?)", "%1") @@ -451,10 +451,10 @@ module.config.public = { -- 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 dorm file on file write. + -- code all code blocks in the current word file on file write. code_on_write = false, - -- When text in a code block is less indented than the block itself, dorm will not code that + -- When text in a code block is less indented than the block itself, word 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 diff --git a/lua/word/mod/completion/module.lua b/lua/word/mod/completion/module.lua new file mode 100644 index 0000000..e7bf9e6 --- /dev/null +++ b/lua/word/mod/completion/module.lua @@ -0,0 +1,9 @@ +local word = require "word" + +local M = word.mod.create("data") + +M.load = function() + +end + +return M diff --git a/lua/dorm/mod/data/module.lua b/lua/word/mod/data/module.lua similarity index 72% rename from lua/dorm/mod/data/module.lua rename to lua/word/mod/data/module.lua index 7c5b8aa..6fc7ff3 100644 --- a/lua/dorm/mod/data/module.lua +++ b/lua/word/mod/data/module.lua @@ -1,4 +1,4 @@ -local d = require "dorm" +local d = require "word" local M = d.mod.create("data") M.load = function() diff --git a/lua/dorm/mod/encrypt/module.lua b/lua/word/mod/encrypt/module.lua similarity index 96% rename from lua/dorm/mod/encrypt/module.lua rename to lua/word/mod/encrypt/module.lua index 8ce921b..dae8e02 100644 --- a/lua/dorm/mod/encrypt/module.lua +++ b/lua/word/mod/encrypt/module.lua @@ -1,4 +1,4 @@ -local d = require("dorm") +local d = require("word") local lib, mod = d.lib, d.mod local module = mod.create("encrypt") diff --git a/lua/word/mod/export/module.lua b/lua/word/mod/export/module.lua new file mode 100644 index 0000000..f65a4eb --- /dev/null +++ b/lua/word/mod/export/module.lua @@ -0,0 +1,61 @@ +local d = require "word" +local mod = d.mod + +local M = d.mod.create("export") + + +M.load = function() + mod.await("cmd", function(cmd) + cmd.add_commands_from_table({ + ["export"] = { + subcommands = { + update = { + args = 0, + name = "export.update" + }, + insert = { + name = "export.insert", + args = 0, + }, + }, + name = "export" + } + }) + end) +end + +M.setup = function() + return { + success = true, + requires = { + "workspace" + } + + } +end + +M.public = { + +} + +M.config.private = { + +} +M.config.public = { + +} +M.private = { + +} +M.events = {} + + +M.events.subscribed = { + cmd = { + ["export.insert"] = true, + ["export.update"] = true, + }, +} + + +return M diff --git a/lua/dorm/mod/gen/toc/module.lua b/lua/word/mod/gen/toc/module.lua similarity index 98% rename from lua/dorm/mod/gen/toc/module.lua rename to lua/word/mod/gen/toc/module.lua index 7c79285..ca9769c 100644 --- a/lua/dorm/mod/gen/toc/module.lua +++ b/lua/word/mod/gen/toc/module.lua @@ -5,7 +5,7 @@ summary: Generates a table of contents for a given Norg buffer. --- -The TOC module exposes a single command - `:Dorm toc`. This command can be executed with one of three +The TOC module exposes a single command - `:word toc`. This command can be executed with one of three optional arguments: `left`, `right` and `qflist`. When `left` or `right` is supplied, the Table of Contents split is placed on that side of the screen. @@ -16,8 +16,8 @@ When in the TOC view, `` can be pressed on any of the entries to move to tha Norg document. The TOC view updates automatically when switching buffers. --]] -local dorm = require("dorm.core") -local modules, utils, log = dorm.modules, dorm.utils, dorm.log +local word = require("word.core") +local modules, utils, log = word.modules, word.utils, word.log local module = modules.create("toc") @@ -30,8 +30,8 @@ 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 module.load = function() - modules.await("core.dormcmd", function(dormcmd) - dormcmd.add_commands_from_table({ + modules.await("core.wordcmd", function(wordcmd) + wordcmd.add_commands_from_table({ toc = { name = "toc", max_args = 1, @@ -50,7 +50,7 @@ module.load = function() vim.schedule(function() if vim.bo.filetype == "norg" then next_open_is_auto = true - vim.cmd([[dorm toc]]) + vim.cmd([[word toc]]) end end) end, @@ -421,7 +421,7 @@ 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("dorm/toc") + toc_namespace = toc_namespace or vim.api.nvim_create_namespace("word/toc") local ui_buffer, ui_window = module.required["core.ui"].create_vsplit( ("toc-%d"):format(tabpage), enter, @@ -642,7 +642,7 @@ module.on_event = function(event) end module.events.subscribed = { - ["core.dormcmd"] = { + ["core.wordcmd"] = { [module.name] = true, }, } diff --git a/lua/dorm/mod/gen/todo/module.lua b/lua/word/mod/gen/todo/module.lua similarity index 94% rename from lua/dorm/mod/gen/todo/module.lua rename to lua/word/mod/gen/todo/module.lua index 801cd88..2335f72 100644 --- a/lua/dorm/mod/gen/todo/module.lua +++ b/lua/word/mod/gen/todo/module.lua @@ -7,23 +7,23 @@ This module handles the whole concept of toggling TODO items, as well as updatin parent and/or children items alongside the current item. The following keybinds are exposed (with their default binds): -- `(dorm.qol.todo-items.todo.task-done)` (`td`) -- `(dorm.qol.todo-items.todo.task-undone)` (`tu`) -- `(dorm.qol.todo-items.todo.task-pending)` (`tp`) -- `(dorm.qol.todo-items.todo.task-on_hold)` (`th`) -- `(dorm.qol.todo-items.todo.task-cancelled)` (`tc`) -- `(dorm.qol.todo-items.todo.task-recurring)` (`tr`) -- `(dorm.qol.todo-items.todo.task-important)` (`ti`) -- `(dorm.qol.todo-items.todo.task-cycle)` (``) -- `(dorm.qol.todo-items.todo.task-cycle-reverse)` (no default keybind) +- `(word.qol.todo-items.todo.task-done)` (`td`) +- `(word.qol.todo-items.todo.task-undone)` (`tu`) +- `(word.qol.todo-items.todo.task-pending)` (`tp`) +- `(word.qol.todo-items.todo.task-on_hold)` (`th`) +- `(word.qol.todo-items.todo.task-cancelled)` (`tc`) +- `(word.qol.todo-items.todo.task-recurring)` (`tr`) +- `(word.qol.todo-items.todo.task-important)` (`ti`) +- `(word.qol.todo-items.todo.task-cycle)` (``) +- `(word.qol.todo-items.todo.task-cycle-reverse)` (no default keybind) With your cursor on a line that contains an item with a TODO attribute, press any of the above keys to toggle the state of that particular item. Parent items of the same type and children items of the same type are update accordingly. --]] -local dorm = require("dorm") -local log, modules = dorm.log, dorm.modules +local word = require("word") +local log, modules = word.log, word.modules local module = modules.create("todo_items") @@ -46,7 +46,7 @@ module.load = function() }) do vim.keymap.set( "", - string.format("(dorm.qol.todo-items.todo.task-%s)", task), + string.format("(word.qol.todo-items.todo.task-%s)", task), module.public["task-" .. task] ) end @@ -208,7 +208,7 @@ module.private = { local first_status_extension = module.private.find_first_status_extension(item_at_cursor:named_child(1)) -- TODO(vhyrro): - -- Implement a toggleable behaviour where dorm can automatically convert this: + -- Implement a toggleable behaviour where word can automatically convert this: -- * (@ Mon 5th Feb) Test -- ** ( ) Test -- To this: @@ -405,7 +405,7 @@ module.private = { } local function task_set(character, name) - return dorm.utils.wrap_dotrepeat(function() + return word.utils.wrap_dotrepeat(function() local buffer = vim.api.nvim_get_current_buf() local cursor = vim.api.nvim_win_get_cursor(0) diff --git a/lua/dorm/mod/hl/module.lua b/lua/word/mod/hl/module.lua similarity index 91% rename from lua/dorm/mod/hl/module.lua rename to lua/word/mod/hl/module.lua index b1bbae1..0e53e39 100644 --- a/lua/dorm/mod/hl/module.lua +++ b/lua/word/mod/hl/module.lua @@ -5,21 +5,21 @@ internal: true --- `base.hl` maps all possible highlight groups available throughout -dorm under a single tree of hl: `@dorm.*`. +word under a single tree of hl: `@word.*`. --]] -local dorm = require("dorm") -local lib, log, mod = dorm.lib, dorm.log, dorm.mod +local word = require("word") +local lib, log, mod = word.lib, word.log, word.mod local module = mod.create("hl") --[[ --]] module.config.public = { - -- The TS hl for each dorm type. + -- The TS hl for each word type. -- -- The `hl` table is a large collection of nested trees. At the leaves of each of these - -- trees is the final highlight to apply to that tree. For example: `"+@comment"` tells dorm to + -- trees is the final highlight to apply to that tree. For example: `"+@comment"` tells word to -- link to an existing highlight group `@comment` (denoted by the `+` prefix). When no prefix is -- found, the string is treated as arguments passed to `:highlight`, for example: `gui=bold -- fg=#000000`. @@ -34,14 +34,14 @@ module.config.public = { -- ``` -- matches the highlight group: -- ```lua - -- @dorm.tags.ranged_verbatim.begin + -- @word.tags.ranged_verbatim.begin -- ``` -- and converts into the following command: -- ```vim - -- highlight! link @dorm.tags.ranged_verbatim.begin @comment + -- highlight! link @word.tags.ranged_verbatim.begin @comment -- ``` hl = { - -- hl displayed in dorm selection window popups. + -- hl displayed in word selection window popups. selection_window = { heading = "+@annotation", arrow = "+@none", @@ -249,49 +249,49 @@ module.config.public = { }, marker = { - [""] = "+@dorm.markers.title", - prefix = "+@dorm.markers.prefix", + [""] = "+@word.markers.title", + prefix = "+@word.markers.prefix", }, definition = { - [""] = "+@dorm.definitions.title", - prefix = "+@dorm.definitions.prefix", + [""] = "+@word.definitions.title", + prefix = "+@word.definitions.prefix", }, footnote = { - [""] = "+@dorm.footnotes.title", - prefix = "+@dorm.footnotes.prefix", + [""] = "+@word.footnotes.title", + prefix = "+@word.footnotes.prefix", }, heading = { ["1"] = { - [""] = "+@dorm.headings.1.title", - prefix = "+@dorm.headings.1.prefix", + [""] = "+@word.headings.1.title", + prefix = "+@word.headings.1.prefix", }, ["2"] = { - [""] = "+@dorm.headings.2.title", - prefix = "+@dorm.headings.2.prefix", + [""] = "+@word.headings.2.title", + prefix = "+@word.headings.2.prefix", }, ["3"] = { - [""] = "+@dorm.headings.3.title", - prefix = "+@dorm.headings.3.prefix", + [""] = "+@word.headings.3.title", + prefix = "+@word.headings.3.prefix", }, ["4"] = { - [""] = "+@dorm.headings.4.title", - prefix = "+@dorm.headings.4.prefix", + [""] = "+@word.headings.4.title", + prefix = "+@word.headings.4.prefix", }, ["5"] = { - [""] = "+@dorm.headings.5.title", - prefix = "+@dorm.headings.5.prefix", + [""] = "+@word.headings.5.title", + prefix = "+@word.headings.5.prefix", }, ["6"] = { - [""] = "+@dorm.headings.6.title", - prefix = "+@dorm.headings.6.prefix", + [""] = "+@word.headings.6.title", + prefix = "+@word.headings.6.prefix", }, }, }, @@ -442,18 +442,18 @@ module.public = { -- do -- local query = require("nvim-treesitter.query") - -- if not query.has_hl("dorm") then + -- if not query.has_hl("word") then -- query.invalidate_query_cache() - -- if not query.has_hl("dorm") then + -- if not query.has_hl("word") then -- log.error( - -- "nvim-treesitter has no available hl for dorm! Ensure treesitter is properly loaded in your config." + -- "nvim-treesitter has no available hl for word! Ensure treesitter is properly loaded in your config." -- ) -- end -- end - -- if vim.bo.filetype == "dorm" then - -- require("nvim-treesitter.highlight").attach(vim.api.nvim_get_current_buf(), "dorm") + -- if vim.bo.filetype == "word" then + -- require("nvim-treesitter.highlight").attach(vim.api.nvim_get_current_buf(), "word") -- end -- end @@ -486,7 +486,7 @@ module.public = { -- by checking for the existence of the + sign at the front local is_link = highlight:sub(1, 1) == "+" - local full_highlight_name = "@dorm" .. prefix .. (hl_name:len() > 0 and ("." .. hl_name) or "") + local full_highlight_name = "@word" .. prefix .. (hl_name:len() > 0 and ("." .. hl_name) or "") local does_hl_exist = lib.inline_pcall(vim.api.nvim_exec, "highlight " .. full_highlight_name, true) ---@diagnostic disable-line -- TODO: type error workaround -- If we are dealing with a link then link the hl together (excluding the + symbol) @@ -523,7 +523,7 @@ module.public = { return true end - local full_highlight_name = "@dorm" .. prefix .. (hl_name:len() > 0 and ("." .. hl_name) or "") + local full_highlight_name = "@word" .. prefix .. (hl_name:len() > 0 and ("." .. hl_name) or "") local does_hl_exist = lib.inline_pcall(vim.api.nvim_exec, "highlight " .. full_highlight_name, true) ---@diagnostic disable-line -- TODO: type error workaround -- If the highlight already exists then assume the user doesn't want it to be @@ -560,7 +560,7 @@ module.public = { module.public.trigger_hl() end, - --- Assigns all dorm* hl to `clear` + --- Assigns all word* hl to `clear` clear_hl = function() --- Recursively descends down the highlight configuration and clears every highlight accordingly ---@param hl table #The table of hl to descend down @@ -573,7 +573,7 @@ module.public = { descend(highlight, hl_name) else -- Otherwise we're dealing with a string -- Hence we should clear the highlight - vim.cmd("highlight! clear dorm" .. prefix .. hl_name) + vim.cmd("highlight! clear word" .. prefix .. hl_name) end end end diff --git a/lua/dorm/mod/init.lua b/lua/word/mod/init.lua similarity index 91% rename from lua/dorm/mod/init.lua rename to lua/word/mod/init.lua index b0511bf..1441037 100644 --- a/lua/dorm/mod/init.lua +++ b/lua/word/mod/init.lua @@ -1,19 +1,19 @@ --- @brief [[ --- Base file for mod. ---- This file contains the base implementation for "mod", building blocks of the dorm environment. +--- This file contains the base implementation for "mod", building blocks of the word environment. --- @brief ]] -- TODO: What goes below this line until the next notice used to belong to mod.base -- We need to find a way to make these constructors easier to maintain and more efficient -local callbacks = require("dorm.util.callback") -local config = require("dorm.config") -local log = require("dorm.util.log") -local utils = require("dorm.util") +local callbacks = require("word.util.callback") +local config = require("word.config") +local log = require("word.util.log") +local utils = require("word.util") ---- @alias dorm.module.public { version: string, [any]: any } +--- @alias word.module.public { version: string, [any]: any } ---- @class (exact) dorm.module.resolver +--- @class (exact) word.module.resolver --- @field ["autocmd"] autocmd --- @field ["completion"] completion --- @field ["conceal"] conceal @@ -30,46 +30,46 @@ local utils = require("dorm.util") --- @field ["ui.selection_popup"] ui.selection_popup --- @field ["ui.text_popup"] Mi.text_popup ---- Defines both a public and private configuration for a dorm module. ---- Public configurations may be tweaked by the user from the `dorm.setup()` function, whereas private configurations are for internal use only. ---- @class (exact) dorm.module.configuration +--- Defines both a public and private configuration for a word module. +--- Public configurations may be tweaked by the user from the `word.setup()` function, whereas private configurations are for internal use only. +--- @class (exact) word.module.configuration --- @field custom? table Internal table that tracks the differences (changes) between the base `public` table and the new (altered) `public` table. It contains only the tables that the user has altered in their own configuration. --- @field public private? table Internal configuration variables that may be tweaked by the developer. --- @field public public? table Configuration variables that may be tweaked by the user. ---- @class (exact) dorm.module.events ---- @field defined? { [string]: dorm.event } Lists all events defined by this module. +--- @class (exact) word.module.events +--- @field defined? { [string]: word.event } Lists all events defined by this module. --- @field subscribed? { [string]: { [string]: boolean } } Lists the events that the module is subscribed to. ---- @alias dorm.module.setup { success: boolean, requires?: string[], replaces?: string, replace_merge?: boolean, wants?: string[] } +--- @alias word.module.setup { success: boolean, requires?: string[], replaces?: string, replace_merge?: boolean, wants?: string[] } --- Defines a module. ---- A module is an object that contains a set of hooks which are invoked by dorm whenever something in the +--- A module is an object that contains a set of hooks which are invoked by word whenever something in the --- environment occurs. This can be an event, a simple act of the module being loaded or anything else. ---- @class (exact) dorm.module ---- @field config? dorm.module.configuration The configuration for the module. ---- @field events? dorm.module.events Describes all information related to events for this module. +--- @class (exact) word.module +--- @field config? word.module.configuration The configuration for the module. +--- @field events? word.module.events Describes all information related to events for this module. --- @field examples? table Contains examples of how to use the mod that users or developers may sift through. ---- @field imported? table Imported submod of the given module. Contrary to `required`, which only exposes the public API of a module, imported mod can be accessed in their entirety. +--- @field imported? table Imported submod of the given module. Contrary to `required`, which only exposes the public API of a module, imported mod can be accessed in their entirety. --- @field load? fun() Function that is invoked once the module is considered "stable", i.e. after all dependencies are loaded. Perform your main loading routine here. --- @field name string The name of the module. ---- @field dorm_post_load? fun() Function that is invoked after all mod are loaded. Useful if you want the dorm environment to be fully set up before performing some task. +--- @field word_post_load? fun() Function that is invoked after all mod are loaded. Useful if you want the word environment to be fully set up before performing some task. --- @field path string The full path to the module (a more verbose version of `name`). May be used in lua's `require()` statements. --- @field public private? table A convenience table to place all of your private variables that you don't want to expose. ---- @field public public? dorm.module.public Every module can expose any set of information it sees fit through this field. All functions and variables declared in this table will be visiable to any other module loaded. ---- @field required? dorm.module.resolver Contains the public tables of all mod that were required via the `requires` array provided in the `setup()` function of this module. ---- @field setup? fun(): dorm.module.setup? Function that is invoked before any other loading occurs. Should perform preliminary startup tasks. +--- @field public public? word.module.public Every module can expose any set of information it sees fit through this field. All functions and variables declared in this table will be visiable to any other module loaded. +--- @field required? word.module.resolver Contains the public tables of all mod that were required via the `requires` array provided in the `setup()` function of this module. +--- @field setup? fun(): word.module.setup? Function that is invoked before any other loading occurs. Should perform preliminary startup tasks. --- @field replaced? boolean If `true`, this means the module is a replacement for a base module. This flag is set automatically whenever `setup().replaces` is set to a value. ---- @field on_event fun(event: dorm.event) A callback that is invoked any time an event the module has subscribed to has fired. +--- @field on_event fun(event: word.event) A callback that is invoked any time an event the module has subscribed to has fired. local Mod = {} ---- Returns a new dorm module, exposing all the necessary function and variables. +--- Returns a new word module, exposing all the necessary function and variables. --- @param name string The name of the new module. Make sure this is unique. The recommended naming convention is `category.module_name` or `category.subcategory.module_name`. --- @param imports? string[] A list of imports to attach to the module. Import data is requestable via `module.required`. Use paths relative to the current module. ---- @return dorm.module +--- @return word.module function Mod.create(name, imports) - ---@type dorm.module + ---@type word.module local new_module = { setup = function() return { success = true, requires = {}, replaces = nil, replace_merge = false } @@ -79,7 +79,7 @@ function Mod.create(name, imports) on_event = function() end, - dorm_post_load = function() end, + word_post_load = function() end, name = "base", @@ -88,7 +88,7 @@ function Mod.create(name, imports) private = {}, public = { - version = config.dorm_version, + version = config.word_version, }, config = { @@ -186,7 +186,7 @@ end --- Constructs a metamodule from a list of submod. Metamod are mod that can autoload batches of mod at once. --- @param name string The name of the new metamodule. Make sure this is unique. The recommended naming convention is `category.module_name` or `category.subcategory.module_name`. --- @param ... string A list of module names to load. ---- @return dorm.module +--- @return word.module function Mod.create_meta(name, ...) local module = Mod.create(name) @@ -233,12 +233,12 @@ end Mod.loaded_module_count = 0 --- The table of currently loaded mod ---- @type { [string]: dorm.module } +--- @type { [string]: word.module } Mod.loaded_mod = {} --- Loads and enables a module --- Loads a specified module. If the module subscribes to any events then they will be activated too. ---- @param module dorm.module The actual module to load. +--- @param module word.module The actual module to load. --- @return boolean # Whether the module successfully loaded. function Mod.load_module_from_table(module) log.info("Loading module with name", module.name) @@ -250,7 +250,7 @@ function Mod.load_module_from_table(module) end -- Invoke the setup function. This function returns whether or not the loading of the module was successful and some metadata. - ---@type dorm.module.setup + ---@type word.module.setup local loaded_module = module.setup and module.setup() or { success = true, @@ -281,7 +281,7 @@ function Mod.load_module_from_table(module) -- If the module wants to replace an already loaded module then we need to create a deepcopy of that old module -- in order to stop it from getting overwritten. --]] - ---@type dorm.module + ---@type word.module local module_to_replace -- If the return value of module.setup() tells us to hotswap with another module then cache the module we want to replace with @@ -381,7 +381,7 @@ function Mod.load_module_from_table(module) -- If this flag has already been set before, then throw an error - there is no way for us to know which hotswapped module should take priority. if module_to_replace.replaced then log.error( - ("Unable to replace module %s - module replacement clashing detected. This error triggers when a module tries to be replaced more than two times - dorm doesn't know which replacement to prioritize.") + ("Unable to replace module %s - module replacement clashing detected. This error triggers when a module tries to be replaced more than two times - word doesn't know which replacement to prioritize.") :format( module_to_replace.name ) @@ -446,9 +446,9 @@ end --- Unlike `load_module_from_table()`, which loads a module from memory, `load_module()` tries to find the corresponding module file on disk and loads it into memory. --- If the module 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_module_from_table()` should only really be used by dorm itself. ---- @param module_name string A path to a module on disk. A path seperator in dorm is '.', not '/'. ---- @param cfg table? A config that reflects the structure of `dorm.config.user_config.load["module.name"].config`. +--- This is the recommended way of loading mod - `load_module_from_table()` should only really be used by word itself. +--- @param module_name string A path to a module on disk. A path seperator in word is '.', not '/'. +--- @param cfg table? A config that reflects the structure of `word.config.user_config.load["module.name"].config`. --- @return boolean # Whether the module was successfully loaded. function Mod.load_module(module_name, cfg) -- Don't bother loading the module from disk if it's already loaded @@ -457,7 +457,7 @@ function Mod.load_module(module_name, cfg) end -- Attempt to require the module, does not throw an error if the module doesn't exist - local module = require("dorm.mod." .. module_name .. ".module") + local module = require("word.mod." .. module_name .. ".module") -- If the module is nil for some reason return false if not module then @@ -494,8 +494,8 @@ function Mod.load_module(module_name, cfg) end --- Has the same principle of operation as load_module_from_table(), except it then sets up the parent module's "required" table, allowing the parent to access the child as if it were a dependency. ---- @param module dorm.module A valid table as returned by mod.create() ---- @param parent_module string|dorm.module If a string, then the parent is searched for in the loaded mod. If a table, then the module is treated as a valid module as returned by mod.create() +--- @param module word.module A valid table as returned by mod.create() +--- @param parent_module string|word.module If a string, then the parent is searched for in the loaded mod. If a table, then the module is treated as a valid module as returned by mod.create() function Mod.load_module_as_dependency_from_table(module, parent_module) if Mod.load_module_from_table(module) then if type(parent_module) == "string" then @@ -507,9 +507,9 @@ function Mod.load_module_as_dependency_from_table(module, parent_module) end --- Normally loads a module, but then sets up the parent module's "required" table, allowing the parent module to access the child as if it were a dependency. ---- @param module_name string A path to a module on disk. A path seperator in dorm is '.', not '/' +--- @param module_name string A path to a module on disk. A path seperator in word is '.', not '/' --- @param parent_module string The name of the parent module. This is the module which the dependency will be attached to. ---- @param cfg? table A config that reflects the structure of dorm.config.user_config.load["module.name"].config +--- @param cfg? table A config that reflects the structure of word.config.user_config.load["module.name"].config function Mod.load_module_as_dependency(module_name, parent_module, cfg) if Mod.load_module(module_name, cfg) and Mod.is_module_loaded(parent_module) then Mod.loaded_mod[parent_module].required[module_name] = Mod.get_module_config(module_name) @@ -572,7 +572,7 @@ end --- Executes `callback` once `module` is a valid and loaded module, else the callback gets instantly executed. --- @param module_name string The name of the module to listen for. ---- @param callback fun(module_public_table: dorm.module.public) The callback to execute. +--- @param callback fun(module_public_table: word.module.public) The callback to execute. function Mod.await(module_name, callback) if Mod.is_module_loaded(module_name) then callback(assert(Mod.get_module(module_name))) @@ -627,7 +627,7 @@ end --- | "!" --- | "t" ---- @class (exact) dorm.event +--- @class (exact) word.event --- @field type string The type of the event. Exists in the format of `category.name`. --- @field split_type string[] The event type, just split on every `.` character, e.g. `{ "category", "name" }`. --- @field content? table|any The content of the event. The data found here is specific to each individual event. Can be thought of as the payload. @@ -645,7 +645,7 @@ end -- We need to find a way to make these functions easier to maintain --[[ --- dorm EVENT FILE +-- word EVENT FILE -- This file is responsible for dealing with event handling and broadcasting. -- All mod that subscribe to an event will receive it once it is triggered. --]] @@ -668,9 +668,9 @@ function Mod.split_event_type(type) end --- Returns an event template defined in `module.events.defined`. ---- @param module dorm.module A reference to the module invoking the function +--- @param module word.module A reference to the module invoking the function --- @param type string A full path to a valid event type (e.g. `module.events.some_event`) ---- @return dorm.event? +--- @return word.event? function Mod.get_event_template(module, type) -- You can't get the event template of a type if the type isn't loaded if not Mod.is_module_loaded(module.name) then @@ -693,9 +693,9 @@ function Mod.get_event_template(module, type) end --- Creates a deep copy of the `mod.base_event` event and returns it with a custom type and referrer. ---- @param module dorm.module A reference to the module invoking the function. +--- @param module word.module A reference to the module invoking the function. --- @param name string A relative path to a valid event template. ---- @return dorm.event +--- @return word.event function Mod.define_event(module, name) -- Create a copy of the base event and override the values with ones specified by the user @@ -725,11 +725,11 @@ function Mod.define_event(module, name) end --- Returns a copy of the event template provided by a module. ---- @param module dorm.module A reference to the module invoking the function +--- @param module word.module A reference to the module invoking the function --- @param type string A full path to a valid event type (e.g. `module.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 dorm.event? # New event. +--- @return word.event? # New event. function Mod.create_event(module, type, content, ev) -- Get the module that contains the event local module_name = Mod.split_event_type(type)[1] @@ -775,7 +775,7 @@ function Mod.create_event(module, 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 dorm.event An event, usually created by `mod.create_event()`. +--- @param event word.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(event, callback) -- Broadcast the event to all mod @@ -810,7 +810,7 @@ end --- Instead of broadcasting to all loaded mod, `send_event()` only sends to one module. --- @param recipient string The name of a loaded module that will be the recipient of the event. ---- @param event dorm.event An event, usually created by `mod.create_event()`. +--- @param event word.event An event, usually created by `mod.create_event()`. function Mod.send_event(recipient, event) -- If the recipient is not loaded then there's no reason to send an event to it if not Mod.is_module_loaded(recipient) then @@ -837,9 +837,9 @@ function Mod.send_event(recipient, event) end end ---- Load all modules in the `lua/dorm/mod` directory. +--- Load all modules in the `lua/word/mod` directory. function Mod.load_modules() - local dir = "lua/dorm/mod" + local dir = "lua/word/mod" local handle = vim.loop.fs_scandir(dir) if not handle then return diff --git a/lua/dorm/mod/link/module.lua b/lua/word/mod/link/module.lua similarity index 97% rename from lua/dorm/mod/link/module.lua rename to lua/word/mod/link/module.lua index fc21a31..51ea852 100644 --- a/lua/dorm/mod/link/module.lua +++ b/lua/word/mod/link/module.lua @@ -8,11 +8,11 @@ This M provides utility functions that are used to find link and their targets in the buffer. --]] -local dorm = require("dorm") -local lib, mod, u = dorm.lib, dorm.mod, dorm.utils +local word = require("word") +local lib, mod, u = word.lib, word.mod, word.utils local M = mod.create("link") -u.ns("dorm-link") +u.ns("word-link") M.setup = function() return { diff --git a/lua/dorm/mod/lsp/module.lua b/lua/word/mod/lsp/module.lua similarity index 94% rename from lua/dorm/mod/lsp/module.lua rename to lua/word/mod/lsp/module.lua index 6c91036..6264da6 100644 --- a/lua/dorm/mod/lsp/module.lua +++ b/lua/word/mod/lsp/module.lua @@ -1,7 +1,7 @@ -local d = require "dorm" +local d = require "word" local mod, u = d.mod, d.utils -u.ns("dorm-lsp") +u.ns("word-lsp") local M = d.mod.create("lsp") M.load = function() diff --git a/lua/dorm/mod/maps/module.lua b/lua/word/mod/maps/module.lua similarity index 66% rename from lua/dorm/mod/maps/module.lua rename to lua/word/mod/maps/module.lua index fbca9bf..3487a52 100644 --- a/lua/dorm/mod/maps/module.lua +++ b/lua/word/mod/maps/module.lua @@ -1,15 +1,15 @@ --[[ file: User-keys - title: The Language of dorm - description: `base.keys` manages mappings for operations on or in `.dorm` files. - summary: Module for managing keybindings with dorm mode support. + title: The Language of word + description: `base.keys` manages mappings for operations on or in `.word` files. + summary: Module for managing keybindings with word mode support. --- The `base.keys` module configures an out-of-the-box Neovim experience by providing a base set of keys. -To disable base keys, see the next section. To remap the existing keys, see [here](https://github.com/nvim-dorm/dorm/wiki/User-keys#remapping-keys). +To disable base keys, see the next section. To remap the existing keys, see [here](https://github.com/nvim-word/word/wiki/User-keys#remapping-keys). -To find common problems, consult the [FAQ](https://github.com/nvim-dorm/dorm/wiki/User-keys#faq). +To find common problems, consult the [FAQ](https://github.com/nvim-word/word/wiki/User-keys#faq). ### Disabling base keys @@ -25,33 +25,33 @@ By base when you load the `base.keys` module all keys will be enabled. If you wo ### Remapping Keys To understand how to effectively remap keys, one must understand how keys are set. -dorm binds actions to various `` mappings that look like so: `(dorm...`. +word binds actions to various `` mappings that look like so: `(word...`. To remap a key, simply map an action somewhere in your configuration: ```lua -vim.keymap.set("n", "my-key-here", "(dorm.pivot.list.toggle)", {}) +vim.keymap.set("n", "my-key-here", "(word.pivot.list.toggle)", {}) ``` -dorm will recognize that the key has been bound by you and not bind its own key. +word will recognize that the key has been bound by you and not bind its own key. -#### Binding Keys for dorm Files Only +#### Binding Keys for word Files Only -This approach has a downside - all of dorm's keys are set on a per-buffer basis +This approach has a downside - all of word's keys are set on a per-buffer basis so that keys don't "overflow" into buffers you don't want them active in. -When you map a key using `vim.keymap.set`, you set a global key which is always active, even in non-dorm +When you map a key using `vim.keymap.set`, you set a global key which is always active, even in non-word files. There are two ways to combat this: -- Create a file under `/ftplugin/dorm.lua`: +- Create a file under `/ftplugin/word.lua`: ```lua - vim.keymap.set("n", "my-key-here", "(dorm.pivot.list.toggle)", { buffer = true }) + vim.keymap.set("n", "my-key-here", "(word.pivot.list.toggle)", { buffer = true }) ``` - Create an autocommand using `vim.api.nvim_create_autocmd`: ```lua vim.api.nvim_create_autocmd("Filetype", { - pattern = "dorm", + pattern = "word", callback = function() - vim.keymap.set("n", "my-key-here", "(dorm.pivot.list.toggle)", { buffer = true }) + vim.keymap.set("n", "my-key-here", "(word.pivot.list.toggle)", { buffer = true }) end, }) ``` @@ -61,14 +61,14 @@ This way, your remapped keys will never interfere with other files. ### Discovering Keys -A comprehensive list of all keys can be found on [this page!](https://github.com/nvim-dorm/dorm/wiki/base-keys) +A comprehensive list of all keys can be found on [this page!](https://github.com/nvim-word/word/wiki/base-keys) ## FAQ ### Some (or all) keys do not work -dorm refuses to bind keys when it knows they'll interfere with your configuration. -Run `:checkhealth dorm` to see a full list of what keys dorm has considered "conflicted" +word refuses to bind keys when it knows they'll interfere with your configuration. +Run `:checkhealth word` to see a full list of what keys word has considered "conflicted" or "rebound". If you see that *all* of your keys are in conflict, you're likely using a plugin that is mapping to your @@ -77,8 +77,8 @@ recommend updating to the latest version to resolve the errors. --]] -local dorm = require("dorm") -local mod = dorm.mod +local word = require("word") +local mod = word.mod local module = mod.create("keys") @@ -92,9 +92,9 @@ module.load = function() module.public.set_keys_for(false, preset.all) vim.api.nvim_create_autocmd("FileType", { - pattern = "dorm", + pattern = "word", callback = function(ev) - module.public.set_keys_for(ev.buf, preset.dorm) + module.public.set_keys_for(ev.buf, preset.word) end, }) end @@ -105,16 +105,16 @@ module.config.public = { base_keys = true, -- Which keybind preset to use. - -- Currently allows only a single value: `"dorm"`. - preset = "dorm", + -- Currently allows only a single value: `"word"`. + preset = "word", } ---@class base.keys module.public = { - --- Adds a set of base keys for dorm to bind. + --- Adds a set of base keys for word to bind. --- Should be used exclusively by external mod wanting to provide their own base keys. ---@param name string The name of the preset to extend (allows for providing base keys for various presets) - ---@param preset dorm.keys.preset The preset data itself. + ---@param preset word.keys.preset The preset data itself. extend_preset = function(name, preset) local original_preset = assert(module.private.presets[name], "provided preset doesn't exist!") @@ -133,7 +133,7 @@ module.public = { end extend(original_preset, preset) - module.public.bind_dorm_keys(vim.api.nvim_get_current_buf()) + module.public.bind_word_keys(vim.api.nvim_get_current_buf()) end, ---@param buffer number|boolean @@ -185,7 +185,7 @@ module.public = { end check_keys_for(preset.all) - check_keys_for(preset.dorm) + check_keys_for(preset.word) return { preset_exists = true, @@ -198,134 +198,134 @@ module.public = { module.private = { -- TODO: Move these to the "vim" preset - -- { "gd", "(dorm.esupports.hop.hop-link)", opts = { desc = "[dorm] Jump to Link" } }, - -- { "gf", "(dorm.esupports.hop.hop-link)", opts = { desc = "[dorm] Jump to Link" } }, - -- { "gF", "(dorm.esupports.hop.hop-link)", opts = { desc = "[dorm] Jump to Link" } }, + -- { "gd", "(word.esupports.hop.hop-link)", opts = { desc = "[word] Jump to Link" } }, + -- { "gf", "(word.esupports.hop.hop-link)", opts = { desc = "[word] Jump to Link" } }, + -- { "gF", "(word.esupports.hop.hop-link)", opts = { desc = "[word] Jump to Link" } }, presets = { - ---@class dorm.keys.preset - dorm = { + ---@class word.keys.preset + word = { all = { n = { - -- Create a new `.dorm` file to take notes in + -- Create a new `.word` file to take notes in -- ^New Note { "nn", - "(dorm.workspace.new-note)", - opts = { desc = "[dorm] Create New Note" }, + "(word.workspace.new-note)", + opts = { desc = "[word] Create New Note" }, }, }, }, - dorm = { + word = { n = { -- Mark the task under the cursor as "undone" -- ^mark Task as Undone { "tu", - "(dorm.qol.todo-items.todo.task-undone)", - opts = { desc = "[dorm] Mark as Undone" }, + "(word.qol.todo-items.todo.task-undone)", + opts = { desc = "[word] Mark as Undone" }, }, -- Mark the task under the cursor as "pending" -- ^mark Task as Pending { "tp", - "(dorm.qol.todo-items.todo.task-pending)", - opts = { desc = "[dorm] Mark as Pending" }, + "(word.qol.todo-items.todo.task-pending)", + opts = { desc = "[word] Mark as Pending" }, }, -- Mark the task under the cursor as "done" -- ^mark Task as Done { "td", - "(dorm.qol.todo-items.todo.task-done)", - opts = { desc = "[dorm] Mark as Done" }, + "(word.qol.todo-items.todo.task-done)", + opts = { desc = "[word] Mark as Done" }, }, -- Mark the task under the cursor as "on-hold" -- ^mark Task as on Hold { "th", - "(dorm.qol.todo-items.todo.task-on-hold)", - opts = { desc = "[dorm] Mark as On Hold" }, + "(word.qol.todo-items.todo.task-on-hold)", + opts = { desc = "[word] Mark as On Hold" }, }, -- Mark the task under the cursor as "cancelled" -- ^mark Task as Cancelled { "tc", - "(dorm.qol.todo-items.todo.task-cancelled)", - opts = { desc = "[dorm] Mark as Cancelled" }, + "(word.qol.todo-items.todo.task-cancelled)", + opts = { desc = "[word] Mark as Cancelled" }, }, -- Mark the task under the cursor as "recurring" -- ^mark Task as Recurring { "tr", - "(dorm.qol.todo-items.todo.task-recurring)", - opts = { desc = "[dorm] Mark as Recurring" }, + "(word.qol.todo-items.todo.task-recurring)", + opts = { desc = "[word] Mark as Recurring" }, }, -- Mark the task under the cursor as "important" -- ^mark Task as Important { "ti", - "(dorm.qol.todo-items.todo.task-important)", - opts = { desc = "[dorm] Mark as Important" }, + "(word.qol.todo-items.todo.task-important)", + opts = { desc = "[word] Mark as Important" }, }, -- Mark the task under the cursor as "ambiguous" -- ^mark Task as Ambiguous { "ta", - "(dorm.qol.todo-items.todo.task-ambiguous)", - opts = { desc = "[dorm] Mark as Ambigous" }, + "(word.qol.todo-items.todo.task-ambiguous)", + opts = { desc = "[word] Mark as Ambigous" }, }, -- Switch the task under the cursor between a select few states { "", - "(dorm.qol.todo-items.todo.task-cycle)", - opts = { desc = "[dorm] Cycle Task" }, + "(word.qol.todo-items.todo.task-cycle)", + opts = { desc = "[word] Cycle Task" }, }, -- Hop to the destination of the link under the cursor - { "", "(dorm.esupports.hop.hop-link)", opts = { desc = "[dorm] Jump to Link" } }, + { "", "(word.esupports.hop.hop-link)", opts = { desc = "[word] Jump to Link" } }, -- Same as ``, except open the destination in a vertical split { "", - "(dorm.esupports.hop.hop-link.vsplit)", - opts = { desc = "[dorm] Jump to Link (Vertical Split)" }, + "(word.esupports.hop.hop-link.vsplit)", + opts = { desc = "[word] Jump to Link (Vertical Split)" }, }, -- Promote an object non-recursively { ">.", - "(dorm.promo.promote)", - opts = { desc = "[dorm] Promote Object (Non-Recursively)" }, + "(word.promo.promote)", + opts = { desc = "[word] Promote Object (Non-Recursively)" }, }, -- Demote an object non-recursively - { "<,", "(dorm.promo.demote)", opts = { desc = "[dorm] Demote Object (Non-Recursively)" } }, + { "<,", "(word.promo.demote)", opts = { desc = "[word] Demote Object (Non-Recursively)" } }, -- Promote an object recursively { ">>", - "(dorm.promo.promote.nested)", - opts = { desc = "[dorm] Promote Object (Recursively)" }, + "(word.promo.promote.nested)", + opts = { desc = "[word] Promote Object (Recursively)" }, }, -- Demote an object recursively { "<<", - "(dorm.promo.demote.nested)", - opts = { desc = "[dorm] Demote Object (Recursively)" }, + "(word.promo.demote.nested)", + opts = { desc = "[word] Demote Object (Recursively)" }, }, -- Toggle a list from ordered <-> unordered -- ^List Toggle { "lt", - "(dorm.pivot.list.toggle)", - opts = { desc = "[dorm] Toggle (Un)ordered List" }, + "(word.pivot.list.toggle)", + opts = { desc = "[word] Toggle (Un)ordered List" }, }, -- Invert all items in a list @@ -334,20 +334,20 @@ module.private = { -- ^List Invert { "li", - "(dorm.pivot.list.invert)", - opts = { desc = "[dorm] Invert (Un)ordered List" }, + "(word.pivot.list.invert)", + opts = { desc = "[word] Invert (Un)ordered List" }, }, -- Insert a link to a date at the given position -- ^Insert Date - { "id", "(dorm.time.insert-date)", opts = { desc = "[dorm] Insert Date" } }, + { "id", "(word.time.insert-date)", opts = { desc = "[word] Insert Date" } }, -- Magnifies a code block to a separate buffer. -- ^Code Magnify { "cm", - "(dorm.looking-glass.magnify-code-block)", - opts = { desc = "[dorm] Magnify Code Block" }, + "(word.looking-glass.magnify-code-block)", + opts = { desc = "[word] Magnify Code Block" }, }, }, @@ -355,30 +355,30 @@ module.private = { -- Promote an object recursively { "", - "(dorm.promo.promote)", - opts = { desc = "[dorm] Promote Object (Recursively)" }, + "(word.promo.promote)", + opts = { desc = "[word] Promote Object (Recursively)" }, }, -- Demote an object recursively - { "", "(dorm.promo.demote)", opts = { desc = "[dorm] Demote Object (Recursively)" } }, + { "", "(word.promo.demote)", opts = { desc = "[word] Demote Object (Recursively)" } }, -- Create an iteration of e.g. a list item - { "", "(dorm.itero.next-iteration)", opts = { desc = "[dorm] Continue Object" } }, + { "", "(word.itero.next-iteration)", opts = { desc = "[word] Continue Object" } }, -- Insert a link to a date at the current cursor position -- ^Date { "", - "(dorm.time.insert-date.insert-mode)", - opts = { desc = "[dorm] Insert Date" }, + "(word.time.insert-date.insert-mode)", + opts = { desc = "[word] Insert Date" }, }, }, v = { -- Promote objects in range - { ">", "(dorm.promo.promote.range)", opts = { desc = "[dorm] Promote Objects in Range" } }, + { ">", "(word.promo.promote.range)", opts = { desc = "[word] Promote Objects in Range" } }, -- Demote objects in range - { "<", "(dorm.promo.demote.range)", opts = { desc = "[dorm] Demote Objects in Range" } }, + { "<", "(word.promo.demote.range)", opts = { desc = "[word] Demote Objects in Range" } }, }, }, }, diff --git a/lua/dorm/mod/media/module.lua b/lua/word/mod/media/module.lua similarity index 73% rename from lua/dorm/mod/media/module.lua rename to lua/word/mod/media/module.lua index c9239c2..6869936 100644 --- a/lua/dorm/mod/media/module.lua +++ b/lua/word/mod/media/module.lua @@ -1,4 +1,4 @@ -local d = require "dorm" +local d = require "word" local M = d.mod.create("media") diff --git a/lua/dorm/mod/metadata/module.lua b/lua/word/mod/metadata/module.lua similarity index 96% rename from lua/dorm/mod/metadata/module.lua rename to lua/word/mod/metadata/module.lua index 6101cec..865fc54 100644 --- a/lua/dorm/mod/metadata/module.lua +++ b/lua/word/mod/metadata/module.lua @@ -1,4 +1,4 @@ -local d = require("dorm") +local d = require("word") local lib, mod = d.lib, d.mod local module = mod.create("metadata") diff --git a/lua/dorm/mod/notes/module.lua b/lua/word/mod/notes/module.lua similarity index 95% rename from lua/dorm/mod/notes/module.lua rename to lua/word/mod/notes/module.lua index 5dc8b8e..50a10d6 100644 --- a/lua/dorm/mod/notes/module.lua +++ b/lua/word/mod/notes/module.lua @@ -2,25 +2,25 @@ file: notes title: Dear diary... description: The notes module allows you to take personal notes with zero friction. - summary: Easily track a notes within dorm. + summary: Easily track a notes within word. --- The notes module exposes a total of six commands. -The first three, `:Dorm notes today|yesterday|tomorrow`, allow you to access entries -for a given time relative to today. A file will be opened with the respective date as a `.dorm` file. +The first three, `:word notes today|yesterday|tomorrow`, allow you to access entries +for a given time relative to today. A file will be opened with the respective date as a `.word` file. -The fourth command, `:Dorm notes custom`, allows you to specify a custom date as an argument. +The fourth command, `:word notes custom`, allows you to specify a custom date as an argument. The date must be formatted according to the `YYYY-mm-dd` format, e.g. `2023-01-01`. -The `:Dorm notes template` command creates a template file which will be used as the base whenever +The `:word notes template` command creates a template file which will be used as the base whenever a new notes entry is created. -Last but not least, the `:Dorm notes toc open|update` commands open or create/update a Table of Contents +Last but not least, the `:word notes toc open|update` commands open or create/update a Table of Contents file found in the root of the notes. This file contains link to all other notes entries, alongside their titles. --]] -local dorm = require("dorm") -local config, lib, log, mod = dorm.config, dorm.lib, dorm.log, dorm.mod +local word = require("word") +local config, lib, log, mod = word.config, word.lib, word.log, word.mod local module = mod.create("notes") @@ -28,7 +28,7 @@ module.examples = { ["Changing TOC format to divide year in quarters"] = function() -- In your ["notes"] options, change toc_format to a function like this: - require("dorm").setup({ + require("word").setup({ load = { -- ... ["notes"] = { @@ -102,7 +102,7 @@ module.private = { ---@param time? number #The time to open the notes entry at as returned by `os.time()` ---@param custom_date? string #A YYYY-mm-dd string that specifies a date to open the diary at instead open_diary = function(time, custom_date) - -- TODO(vhyrro): Change this to use dorm dates! + -- TODO(vhyrro): Change this to use word dates! local workspace = module.config.public.workspace or module.required["workspace"].get_current_workspace()[1] local folder_name = module.config.public.notes_folder local template_name = module.config.public.template_name @@ -223,7 +223,7 @@ module.private = { assert(not err, lib.lazy_string_concat("Unable to generate TOC for directory '", folder_name, "' - ", err)) while true do - -- Name corresponds to either a YYYY-mm-dd.dorm file, or just the year ("nested" strategy) + -- Name corresponds to either a YYYY-mm-dd.word 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 @@ -251,7 +251,7 @@ module.private = { break end - -- If it's a .dorm file, also ensure it is a day entry + -- If it's a .word 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 }) @@ -288,7 +288,7 @@ module.private = { end -- Handles flat entries - -- If it is a .dorm file, but it's not any user generated file. + -- If it is a .word 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 @@ -389,12 +389,12 @@ module.config.public = { notes_folder = "notes", -- The strategy to use to create directories. - -- May be "flat" (`2022-03-02.dorm`), "nested" (`2022/03/02.dorm`), + -- May be "flat" (`2022-03-02.word`), "nested" (`2022/03/02.word`), -- 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 `:Dorm notes template`. + -- The name of the template file to use when running `:word notes template`. template_name = "template.md", -- Whether to apply the template file to new notes entries. diff --git a/lua/dorm/mod/pick/module.lua b/lua/word/mod/pick/module.lua similarity index 96% rename from lua/dorm/mod/pick/module.lua rename to lua/word/mod/pick/module.lua index 3b75368..bd5483d 100644 --- a/lua/dorm/mod/pick/module.lua +++ b/lua/word/mod/pick/module.lua @@ -1,4 +1,4 @@ -local d = require("dorm") +local d = require("word") local lib, mod = d.lib, d.mod local module = mod.create("pick") diff --git a/lua/dorm/mod/preview/module.lua b/lua/word/mod/preview/module.lua similarity index 86% rename from lua/dorm/mod/preview/module.lua rename to lua/word/mod/preview/module.lua index 2cdf968..ced354b 100644 --- a/lua/dorm/mod/preview/module.lua +++ b/lua/word/mod/preview/module.lua @@ -1,12 +1,16 @@ -local d = require "dorm" +local d = require "word" local M = d.mod.create("preview") +local mod, lib, u = d.mod, d.lib, d.utils + +u.ns("word-preview") + M.load = function() mod.await("cmd", function(cmd) cmd.add_commands_from_table({ - ["preview"] = { + preview = { subcommands = { update = { args = 0, diff --git a/lua/dorm/mod/publish/module.lua b/lua/word/mod/publish/module.lua similarity index 94% rename from lua/dorm/mod/publish/module.lua rename to lua/word/mod/publish/module.lua index 6986359..0788eef 100644 --- a/lua/dorm/mod/publish/module.lua +++ b/lua/word/mod/publish/module.lua @@ -1,4 +1,5 @@ -local d = require "dorm" +local d = require "word" +local mod = d.mod local M = d.mod.create("publish") diff --git a/lua/dorm/mod/resources/module.lua b/lua/word/mod/resources/module.lua similarity index 94% rename from lua/dorm/mod/resources/module.lua rename to lua/word/mod/resources/module.lua index be81a11..af7242b 100644 --- a/lua/dorm/mod/resources/module.lua +++ b/lua/word/mod/resources/module.lua @@ -1,4 +1,5 @@ -local d = require "dorm" +local d = require "word" +local mod = d.mod local M = d.mod.create("resources") diff --git a/lua/dorm/mod/run/module.lua b/lua/word/mod/run/module.lua similarity index 96% rename from lua/dorm/mod/run/module.lua rename to lua/word/mod/run/module.lua index 91715c5..70ed7a4 100644 --- a/lua/dorm/mod/run/module.lua +++ b/lua/word/mod/run/module.lua @@ -1,4 +1,4 @@ -local d = require("dorm") +local d = require("word") local lib, mod = d.lib, d.mod local M = mod.create("run") diff --git a/lua/word/mod/search/module.lua b/lua/word/mod/search/module.lua new file mode 100644 index 0000000..1ef23ff --- /dev/null +++ b/lua/word/mod/search/module.lua @@ -0,0 +1,139 @@ +local d = require("word") + +local lib, mod, cfg, u = d.lib, d.mod, d.config, d.utils + +u.ns("word-search") + +local M = mod.create("search") + +M.public = { + + files = function() + local pop = require("nui.popup") + local m = require("nui.menu") + local e = require("nui.input") + local d = require("nio.ui") + + e({ + position = "cursor", + enter = true, + focusable = true + }, { + default_value = "test", + on_change = function() + print("changed") + end, + on_submit = function() + print("submitted") + end, + on_close = function() + print("closed") + end, + prompt = "Enter a file name", + }) + d.select({ + items = { + { + value = "test", + display = "test" + }, + { + value = "test2", + display = "test2" + } + } + + }, { + format_item = function(item) + return item.display + end, + kind = "file", + prompt = "Select" + + }) + end +} + +M.load = function() + mod.await("cmd", function(cmd) + cmd.add_commands_from_table({ + search = { + subcommands = { + workspace = { + args = 1, + name = "search.workspace", + subcommands = { + current = { + name = "search.workspace.current", -- Note default workspace + }, + all = { + args = 0, + name = "search.workspace.all", + } + } + }, + todos = { + name = "search.todos", + args = 0, + }, + titles = { + name = "search.titles", + args = 0, + }, + }, + name = "search" + } + }) + end) +end + + + +M.setup = function() + return { + success = true, + requires = { + "workspace" + } + + } +end + +M.config.private = { + +} +M.config.public = { + +} +M.private = { + +} +M.events = {} + +M.events.defined = { + +} + +M.on_event = function(event) + if event.type == "cmd.events.search.todos" then + M.public["files"]() + elseif event.type == "cmd.events.search.titles" then + M.public["files"]() + elseif event.type == "cmd.events.search.workspace.all" then + M.public["files"]() + elseif event.type == "cmd.events.search.workspace.current" then + M.public["files"]() + end +end + +M.events.subscribed = { + cmd = { + ["search.workspace"] = true, + ["search.workspace.current"] = true, + ["search.workspace.all"] = true, + ["search.todos"] = true, + ["search.titles"] = true, + }, +} + +return M diff --git a/lua/dorm/mod/snippets/module.lua b/lua/word/mod/snippets/module.lua similarity index 96% rename from lua/dorm/mod/snippets/module.lua rename to lua/word/mod/snippets/module.lua index 017ca0a..cbfb57f 100644 --- a/lua/dorm/mod/snippets/module.lua +++ b/lua/word/mod/snippets/module.lua @@ -1,4 +1,4 @@ -local d = require("dorm") +local d = require("word") local lib, mod = d.lib, d.mod local module = mod.create("snippets") diff --git a/lua/dorm/mod/store/module.lua b/lua/word/mod/store/module.lua similarity index 93% rename from lua/dorm/mod/store/module.lua rename to lua/word/mod/store/module.lua index c6ad688..1b0994b 100644 --- a/lua/dorm/mod/store/module.lua +++ b/lua/word/mod/store/module.lua @@ -1,13 +1,13 @@ --[[ File: store Title: Store persistent data and query it easily with `base.store` - Summary: Deals with storing persistent data across dorm sessions. + Summary: Deals with storing persistent data across word sessions. Internal: true --- --]] -local dorm = require("dorm") -local mod = dorm.mod +local word = require("word") +local mod = word.mod local module = mod.create("store") @@ -21,7 +21,7 @@ end module.config.public = { -- Full path to store data (saved in mpack data format) - path = vim.fn.stdpath("data") .. "/dorm.mpack", + path = vim.fn.stdpath("data") .. "/word.mpack", } module.private = { diff --git a/lua/dorm/mod/sync/module.lua b/lua/word/mod/sync/module.lua similarity index 96% rename from lua/dorm/mod/sync/module.lua rename to lua/word/mod/sync/module.lua index ed6d955..504f1e5 100644 --- a/lua/dorm/mod/sync/module.lua +++ b/lua/word/mod/sync/module.lua @@ -1,4 +1,4 @@ -local d = require("dorm") +local d = require("word") local lib, mod = d.lib, d.mod local M = mod.create("sync") diff --git a/lua/dorm/mod/template/module.lua b/lua/word/mod/template/module.lua similarity index 96% rename from lua/dorm/mod/template/module.lua rename to lua/word/mod/template/module.lua index bb44b74..16658eb 100644 --- a/lua/dorm/mod/template/module.lua +++ b/lua/word/mod/template/module.lua @@ -1,4 +1,4 @@ -local d = require("dorm") +local d = require("word") local lib, mod = d.lib, d.mod local module = mod.create("template") diff --git a/lua/dorm/mod/time/module.lua b/lua/word/mod/time/module.lua similarity index 96% rename from lua/dorm/mod/time/module.lua rename to lua/word/mod/time/module.lua index 3ec16cd..b3684e0 100644 --- a/lua/dorm/mod/time/module.lua +++ b/lua/word/mod/time/module.lua @@ -1,7 +1,7 @@ --[[ file: time title: Hassle-Free Dates - summary: Parses and handles dates in dorm. + summary: Parses and handles dates in word. internal: true --- `core.time` is an internal module specifically designed @@ -13,11 +13,11 @@ and `to_lua_date(date) -> osdate`. This module exposes the following keybinds (see [`core.keybinds`](@core.keybinds) for instructions on mapping them): -- `dorm.time.insert-date` - Insert date at cursor position (called from normal mode) -- `dorm.time.insert-date.insert-mode` - Insert date at cursor position (called from insert mode) +- `word.time.insert-date` - Insert date at cursor position (called from normal mode) +- `word.time.insert-date.insert-mode` - Insert date at cursor position (called from insert mode) --]] -local d = require("dorm") +local d = require("word") local lib, modules, utils = d.lib, d.mod, d.utils local module = modules.create("time") @@ -241,7 +241,7 @@ module.public = { return os.date("*t", parsed) --[[@as osdate]] end, - --- Converts a lua `osdate` to a dorm date. + --- Converts a lua `osdate` to a word 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 @@ -292,7 +292,7 @@ module.public = { 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 dorm spec. + ---@param input string #The input which should follow the date specification found in the word spec. ---@return Date|string #The data extracted from the input or an error message parse_date = function(input) local weekdays = {} @@ -469,8 +469,8 @@ module.private = { } module.load = function() - vim.keymap.set("", "(dorm.time.insert-date)", lib.wrap(module.public.insert_date, false)) - vim.keymap.set("i", "(dorm.time.insert-date.insert-mode)", lib.wrap(module.public.insert_date, true)) + vim.keymap.set("", "(word.time.insert-date)", lib.wrap(module.public.insert_date, false)) + vim.keymap.set("i", "(word.time.insert-date.insert-mode)", lib.wrap(module.public.insert_date, true)) end return module diff --git a/lua/dorm/mod/todo/module.lua b/lua/word/mod/todo/module.lua similarity index 95% rename from lua/dorm/mod/todo/module.lua rename to lua/word/mod/todo/module.lua index 9ac58ba..15995a2 100644 --- a/lua/dorm/mod/todo/module.lua +++ b/lua/word/mod/todo/module.lua @@ -8,13 +8,13 @@ When an item with a TODO status has children with their own TODOs this module enables virtual text in the top level item and displays the progress of the subtasks. By base it displays in the format of `[completed/total] (progress%)`. --]] -local dorm = require("dorm") -local mod = dorm.mod +local word = require("word") +local mod = word.mod local module = mod.create("todo") module.private = { - namespace = vim.api.nvim_create_namespace("dorm/todo"), + namespace = vim.api.nvim_create_namespace("word/todo"), --- List of active buffers buffers = {}, @@ -73,7 +73,7 @@ end module.load = function() vim.api.nvim_create_autocmd("Filetype", { pattern = "markdown", - desc = "Attaches the TODO introspector to any dorm buffer.", + desc = "Attaches the TODO introspector to any word buffer.", callback = function(ev) local buf = ev.buf @@ -87,12 +87,12 @@ module.load = function() }) end ---- Attaches the introspector to a given dorm buffer. ---- Errors if the target buffer is not a dorm buffer. +--- Attaches the introspector to a given word buffer. +--- Errors if the target buffer is not a word buffer. ---@param buffer number #The buffer ID to attach to. function module.public.attach_introspector(buffer) if not vim.api.nvim_buf_is_valid(buffer) or vim.bo[buffer].filetype ~= "markdown" then - error(string.format("Could not attach to buffer %d, buffer is not a dorm file!", buffer)) + error(string.format("Could not attach to buffer %d, buffer is not a word file!", buffer)) end module.required["treesitter"].execute_query( diff --git a/lua/dorm/mod/track/module.lua b/lua/word/mod/track/module.lua similarity index 96% rename from lua/dorm/mod/track/module.lua rename to lua/word/mod/track/module.lua index d46ce4e..8528c19 100644 --- a/lua/dorm/mod/track/module.lua +++ b/lua/word/mod/track/module.lua @@ -1,4 +1,4 @@ -local d = require("dorm") +local d = require("word") local lib, mod = d.lib, d.mod local module = mod.create("track") diff --git a/lua/dorm/mod/treesitter/module.lua b/lua/word/mod/treesitter/module.lua similarity index 91% rename from lua/dorm/mod/treesitter/module.lua rename to lua/word/mod/treesitter/module.lua index 2c6c899..0bae018 100644 --- a/lua/dorm/mod/treesitter/module.lua +++ b/lua/word/mod/treesitter/module.lua @@ -1,7 +1,7 @@ --[[ file: Treesitter-Integration title: Snazzy Treesitter Integration - summary: A module designed to integrate Treesitter into dorm. + summary: A module designed to integrate Treesitter into word. embed: https://user-images.githubusercontent.com/76052559/151668244-9805afc4-8c50-4925-85ec-1098aff5ede6.gif internal: true --- @@ -11,14 +11,14 @@ This module exposes the following keybinds (see [`core.keybinds`](@core.keybinds) for instructions on mapping them): -- `dorm.treesitter.next.heading` - jump to the next heading -- `dorm.treesitter.next.link` - jump to the next link -- `dorm.treesitter.previous.heading` - jump to the previous heading -- `dorm.treesitter.previous.link` - jump to the previous link +- `word.treesitter.next.heading` - jump to the next heading +- `word.treesitter.next.link` - jump to the next link +- `word.treesitter.previous.heading` - jump to the previous heading +- `word.treesitter.previous.link` - jump to the previous link --]] -local dorm = require("dorm") -local lib, log, modules, utils = dorm.lib, dorm.log, dorm.mod, dorm.utils +local word = require("word") +local lib, log, modules, utils = word.lib, word.log, word.mod, word.utils local module = modules.create("treesitter") @@ -67,16 +67,16 @@ module.load = function() local parser_configs = require("nvim-treesitter.parsers").get_parser_configs() - -- parser_configs.dorm = { - -- install_info = module.config.public.parser_configs.dorm, + -- parser_configs.word = { + -- install_info = module.config.public.parser_configs.word, -- } - -- parser_configs.dorm_meta = { - -- install_info = module.config.public.parser_configs.dorm_meta, + -- parser_configs.word_meta = { + -- install_info = module.config.public.parser_configs.word_meta, -- } - modules.await("cmd", function(dormcmd) - dormcmd.add_commands_from_table({ + modules.await("cmd", function(wordcmd) + wordcmd.add_commands_from_table({ ["sync"] = { args = 0, name = "sync", @@ -90,7 +90,7 @@ module.load = function() pattern = "*.md", once = true, callback = function() - module.public.parser_path = vim.api.nvim_get_runtime_file("parser/dorm.so", false)[1] + module.public.parser_path = vim.api.nvim_get_runtime_file("parser/word.so", false)[1] if module.public.parser_path then return @@ -98,11 +98,11 @@ module.load = function() if module.config.public.install_parsers then require("nvim-treesitter.install").commands.TSInstallSync["run!"]("markdown", "markdown_inilne") - module.public.parser_path = vim.api.nvim_get_runtime_file("parser/dorm.so", false)[1] + module.public.parser_path = vim.api.nvim_get_runtime_file("parser/word.so", false)[1] else assert( false, - "dorm's parser is not installed! Run `:Dorm sync-parsers` to install it, then restart Neovim." + "word's parser is not installed! Run `:word sync-parsers` to install it, then restart Neovim." ) end end, @@ -113,22 +113,22 @@ module.load = function() vim.keymap.set( "", - "(dorm.treesitter.next.heading)", + "(word.treesitter.next.heading)", lib.wrap(module.public.goto_next_query_match, module.private.heading_query) ) vim.keymap.set( "", - "(dorm.treesitter.next.link)", + "(word.treesitter.next.link)", lib.wrap(module.public.goto_next_query_match, module.private.link_query) ) vim.keymap.set( "", - "(dorm.treesitter.previous.heading)", + "(word.treesitter.previous.heading)", lib.wrap(module.public.goto_previous_query_match, module.private.heading_query) ) vim.keymap.set( "", - "(dorm.treesitter.previous.link)", + "(word.treesitter.previous.link)", lib.wrap(module.public.goto_previous_query_match, module.private.link_query) ) end @@ -138,22 +138,22 @@ module.config.public = { -- 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 dorm parsers if they are not present. + --- If true will automatically install word 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 dorm parser. - -- dorm = { - -- url = "https://github.com/nvim-dorm/tree-sitter-dorm", + -- Configuration for the mainline word parser. + -- word = { + -- url = "https://github.com/nvim-word/tree-sitter-word", -- files = { "src/parser.c", "src/scanner.cc" }, -- branch = "main", -- revision = "6348056b999f06c2c7f43bb0a5aa7cfde5302712", -- }, -- Configuration for the metadata parser (used to parse the contents -- of `@document.meta` blocks). - -- dorm_meta = { - -- url = "https://github.com/nvim-dorm/tree-sitter-dorm-meta", + -- word_meta = { + -- url = "https://github.com/nvim-word/tree-sitter-word-meta", -- files = { "src/parser.c" }, -- branch = "main", -- revision = "a479d1ca05848d0b51dd25bc9f71a17e0108b240", @@ -265,7 +265,7 @@ module.public = { ---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 `dorm` if omitted + ---@param filetype string? file type of the file or `word` if omitted get_all_nodes_in_file = function(node_type, path, filetype) path = vim.fs.normalize(path) if not filetype then @@ -738,13 +738,13 @@ module.public = { get_document_metadata = function(source, no_trim) source = source or 0 - local dorm_parser, iter_src = module.public.get_ts_parser(source) - if not dorm_parser then + local word_parser, iter_src = module.public.get_ts_parser(source) + if not word_parser then return end - local dorm_tree = dorm_parser:parse()[1] - if not dorm_tree then + local word_tree = word_parser:parse()[1] + if not word_tree then return end @@ -803,7 +803,7 @@ module.public = { }) end - local dorm_query = utils.ts_parse_query( + local word_query = utils.ts_parse_query( "markdown", [[ (document @@ -816,7 +816,7 @@ module.public = { ) local meta_query = utils.ts_parse_query( - "dorm_meta", + "word_meta", [[ (metadata (pair @@ -828,8 +828,8 @@ module.public = { ) local meta_node - for id, node in dorm_query:iter_captures(dorm_tree:root(), iter_src) do - if dorm_query.captures[id] == "tag_name" then + for id, node in word_query:iter_captures(word_tree:root(), iter_src) do + if word_query.captures[id] == "tag_name" then local tag_name = trim(module.public.get_node_text(node, iter_src)) if tag_name == "document.meta" then meta_node = node:next_named_sibling() or vim.NIL @@ -844,15 +844,15 @@ module.public = { local meta_source = module.public.get_node_text(meta_node, iter_src) - local dorm_meta_parser = vim.treesitter.get_string_parser(meta_source, "dorm_meta") + local word_meta_parser = vim.treesitter.get_string_parser(meta_source, "word_meta") - local dorm_meta_tree = dorm_meta_parser:parse()[1] + local word_meta_tree = word_meta_parser:parse()[1] - if not dorm_meta_tree then + if not word_meta_tree then return end - for id, node in meta_query:iter_captures(dorm_meta_tree:root(), meta_source) do + for id, node in meta_query:iter_captures(word_meta_tree:root(), meta_source) do if meta_query.captures[id] == "key" then local key = trim(module.public.get_node_text(node, meta_source)) @@ -870,7 +870,7 @@ module.public = { return result end, - --- Parses a query and automatically executes it for dorm + --- Parses a query and automatically executes it for word ---@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 @@ -879,13 +879,13 @@ module.public = { ---@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 dorm_parser, iter_src = module.public.get_ts_parser(source) + local word_parser, iter_src = module.public.get_ts_parser(source) - if not dorm_parser then + if not word_parser then return false end - local root = dorm_parser:parse()[1]:root() + local root = word_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 @@ -895,13 +895,13 @@ module.public = { return true end, - ---Create a dorm TS parser from the given source + ---Create a word 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? dorm_parser + ---@return vim.treesitter.LanguageTree? word_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 dorm_parser + local word_parser local iter_src if type(source) ~= "string" and type(source) ~= "number" then source = tostring(source) @@ -912,27 +912,27 @@ module.public = { source = vim.uri_to_bufnr(vim.uri_from_fname(source)) else iter_src = io.open(source, "r"):read("*a") - dorm_parser = vim.treesitter.get_string_parser(iter_src, "markdown") + word_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 - dorm_parser = vim.treesitter.get_parser(source, "markdown") + word_parser = vim.treesitter.get_parser(source, "markdown") iter_src = source end - return dorm_parser, iter_src + return word_parser, iter_src end, } --- this fixes the problem of installing dorm ts parsers on macOS without resorting to using gcc -local function install_dorm_ts() +-- this fixes the problem of installing word ts parsers on macOS without resorting to using gcc +local function install_word_ts() local install = require("nvim-treesitter.install") if vim.fn.has("macunix") == 1 then - -- https://github.com/nvim-dorm/tree-sitter-dorm/issues/7 + -- https://github.com/nvim-word/tree-sitter-word/issues/7 -- (we have to force clang to c++11 mode on macOS manually) local shell = require("nvim-treesitter.shell_command_selectors") @@ -951,7 +951,7 @@ local function install_dorm_ts() end install.compilers = { cc } - -- install dorm parsers + -- install word parsers local ok, err = pcall(function() install.commands.TSInstallSync["run!"]("markdown") end) @@ -971,14 +971,14 @@ end module.on_event = function(event) if event.split_type[2] == "sync" then - local ok, err = pcall(install_dorm_ts) + local ok, err = pcall(install_word_ts) if not ok then - utils.notify(string.format([[Unable to auto-install dorm parser: %s]], err), vim.log.levels.WARN) + utils.notify(string.format([[Unable to auto-install word parser: %s]], err), vim.log.levels.WARN) end local install = require("nvim-treesitter.install") - install.commands.TSInstallSync["run!"]("dorm_meta") + install.commands.TSInstallSync["run!"]("word_meta") end end diff --git a/lua/dorm/mod/ui/module.lua b/lua/word/mod/ui/module.lua similarity index 96% rename from lua/dorm/mod/ui/module.lua rename to lua/word/mod/ui/module.lua index c147a7a..d1126f4 100644 --- a/lua/dorm/mod/ui/module.lua +++ b/lua/word/mod/ui/module.lua @@ -6,8 +6,8 @@ --- --]] -local dorm = require("dorm") -local log, mod = dorm.log, dorm.mod +local word = require("word") +local log, mod = word.log, word.mod local module = mod.create("ui", { "selection_popup", @@ -88,7 +88,7 @@ module.public = { 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 Dorm:// prepended to it) + ---@param name string the name of the buffer contained within the split (will have word:// prepended to it) ---@param config table? a table of