From 7b80bbdfc0b70ff7cbc1b5ae4f12907b2dbb278a Mon Sep 17 00:00:00 2001 From: Chris Pecunies Date: Sat, 16 Nov 2024 20:47:08 -0800 Subject: [PATCH] more scaffolding --- .github/ISSUE_TEMPLATE/general_issue.yml | 81 +++++++++++++++++ .github/workflows/docs.yml | 73 ++++++++++++++-- .github/workflows/release.yml | 30 +++++++ .luacheckrc | 20 ++++- .markdownlint.yaml | 18 ++++ .neoconf.json | 18 ++++ .null-ls_791419_flake.nix | 14 +++ Justfile | 14 +++ Makefile | 11 --- README.md | 73 ++++++++++++++-- assets/versions.json | 11 +++ flake.lock | 29 +++++-- flake.nix | 27 ++++-- lua/telescope/_extensions/choose/init.lua | 78 +++++++++++++++++ .../_extensions/{word/init.lua => word.lua} | 33 ++++--- .../_extensions/word/actions/init.lua | 0 .../_extensions/word/config/init.lua | 0 lua/telescope/_extensions/word/core/init.lua | 0 lua/telescope/_extensions/word/data/init.lua | 3 + .../_extensions/word/picker/init.lua | 0 lua/test/init.vim | 14 +++ lua/word/config/opts.lua | 10 +++ lua/word/config/version.lua | 1 + lua/word/core/init.lua | 0 lua/word/core/link/init.lua | 7 ++ lua/word/core/parse/time/init.lua | 0 lua/word/core/ref/init.lua | 0 lua/word/core/state/init.lua | 0 lua/word/core/tag/init.lua | 0 lua/word/graph/init.lua | 3 + lua/word/init.lua | 30 ++++--- lua/word/mod/cmd/commands/rename/init.lua | 0 lua/word/mod/job/init.lua | 1 + lua/word/mod/tag/init.lua | 0 lua/word/ui/hl/init.lua | 7 ++ plugin/word.lua | 25 ++++++ scripts/gendocs.lua | 10 +++ scripts/logchg.py | 56 ++++++++++++ scripts/logrel.py | 86 +++++++++++++++++++ scripts/release.sh | 23 +++++ scripts/test.sh | 81 +++++++++++++++++ selene.toml | 10 ++- word-scm-1.rockspec | 25 +++++- word.yml | 2 - 44 files changed, 847 insertions(+), 77 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/general_issue.yml create mode 100644 .github/workflows/release.yml create mode 100644 .markdownlint.yaml create mode 100644 .neoconf.json create mode 100644 .null-ls_791419_flake.nix create mode 100644 Justfile delete mode 100644 Makefile create mode 100644 assets/versions.json create mode 100644 lua/telescope/_extensions/choose/init.lua rename lua/telescope/_extensions/{word/init.lua => word.lua} (61%) create mode 100644 lua/telescope/_extensions/word/actions/init.lua create mode 100644 lua/telescope/_extensions/word/config/init.lua create mode 100644 lua/telescope/_extensions/word/core/init.lua create mode 100644 lua/telescope/_extensions/word/data/init.lua create mode 100644 lua/telescope/_extensions/word/picker/init.lua create mode 100644 lua/test/init.vim create mode 100644 lua/word/config/opts.lua create mode 100644 lua/word/config/version.lua create mode 100644 lua/word/core/init.lua create mode 100644 lua/word/core/link/init.lua create mode 100644 lua/word/core/parse/time/init.lua create mode 100644 lua/word/core/ref/init.lua create mode 100644 lua/word/core/state/init.lua create mode 100644 lua/word/core/tag/init.lua create mode 100644 lua/word/graph/init.lua create mode 100644 lua/word/mod/cmd/commands/rename/init.lua create mode 100644 lua/word/mod/job/init.lua create mode 100644 lua/word/mod/tag/init.lua create mode 100644 lua/word/ui/hl/init.lua create mode 100644 plugin/word.lua create mode 100644 scripts/gendocs.lua create mode 100644 scripts/logchg.py create mode 100644 scripts/logrel.py create mode 100644 scripts/release.sh delete mode 100644 word.yml diff --git a/.github/ISSUE_TEMPLATE/general_issue.yml b/.github/ISSUE_TEMPLATE/general_issue.yml new file mode 100644 index 0000000..f53a2a2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/general_issue.yml @@ -0,0 +1,81 @@ +--- +name: Non-package-related issue +description: Report an issue not related to installation or usage of packages + +body: + - type: markdown + attributes: + value: | + # Issue reporting guidelines + + 1. This is not a general support board for package usage questions (e.g. "How do I do X?"). For questions, please refer to [the discussion board](https://github.com/williamboman/mason.nvim/discussions/categories/q-a) first! :) + 1. Before reporting an issue, make sure that you meet the minimum requirements mentioned in the README. Also review `:checkhealth mason` for potential problems. + + --- + + - type: checkboxes + attributes: + label: I've searched open issues for similar requests + description: If possible, please contribute to any [open issues](https://github.com/williamboman/mason.nvim/issues?q=is%3Aissue) instead of opening a new one. + options: + - label: "Yes" + + - type: checkboxes + attributes: + label: I've recently downloaded the latest plugin version of mason.nvim + options: + - label: "Yes" + + - type: textarea + attributes: + label: Problem description + description: A clear and short description of 1) what the issue is, and 2) why you think it's an issue with mason.nvim. + validations: + required: true + + - type: textarea + attributes: + label: Expected behavior + description: A short description of the behavior you expected. + validations: + required: true + + - type: textarea + attributes: + label: Steps to reproduce + placeholder: | + 1. ... + 2. ... + validations: + required: true + + - type: textarea + attributes: + label: "Neovim version (>= 0.7)" + description: "Output of `nvim --version`" + placeholder: | + NVIM v0.7.0-dev + Build type: Release + LuaJIT 2.1.0-beta3 + validations: + required: true + + - type: input + attributes: + label: "Operating system/version" + description: "On Linux and Mac systems: `$ uname -a`" + validations: + required: true + + - type: textarea + attributes: + label: Healthcheck output + placeholder: ":checkhealth mason" + render: shell + validations: + required: true + + - type: textarea + attributes: + label: Screenshots + description: If applicable, add screenshots to help explain your problem diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index e6ee11e..950657e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,12 +1,71 @@ -name: docgen (oneday) - on: - pull_request: push: branches: - - master + - main +name: docs jobs: - steps: - - name: empty - run: echo "empty" + docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: panvimdoc + uses: kdheepak/panvimdoc@main + with: + vimdoc: word.lua + version: "Neovim >= 0.10.0" + demojify: true + treesitter: true + - name: Push changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "auto-generate vimdoc" + commit_user_name: "github-actions[bot]" + commit_user_email: "github-actions[bot]@users.noreply.github.com" + commit_author: "github-actions[bot] " +# name: docgen + +# on: +# push: +# branches: +# - master + +# jobs: +# docgen: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# with: +# token: ${{ secrets.GH_TOKEN }} +# - uses: actions/setup-go@v5 +# with: +# go-version: '^1.17.1' +# - name: Install md2vim +# run: go install git.foosoft.net/alex/md2vim@latest +# - name: Install Neovim +# uses: rhysd/action-setup-vim@v1 +# id: neovim +# with: +# neovim: true +# version: v0.9.5 +# - name: Install lemmy-help +# run: | +# curl -Lq https://github.com/numToStr/lemmy-help/releases/latest/download/lemmy-help-x86_64-unknown-linux-gnu.tar.gz | tar xz +# echo "$PWD" >> $GITHUB_PATH +# - name: Generate api docs +# run: make api_docs +# - name: Generate vim docs +# run: make docs +# - name: Commit changes +# env: +# GH_TOKEN: ${{ secrets.GH_TOKEN }} +# COMMIT_MSG: | +# [docgen] Update docs +# run: | +# rm lemmy-help +# git config user.name github-actions +# git config user.email github-actions@github.com +# git add doc/orgmode.txt +# git add doc/orgmode_api.txt +# # Only commit and push if we have changes +# git diff --quiet && git diff --staged --quiet || (git commit -m "${COMMIT_MSG}"; git push) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..90f53c2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,30 @@ +name: release + +on: + push: + branches: + - master + +jobs: + release: + name: release + runs-on: ubuntu-latest + steps: + - uses: google-github-actions/release-please-action@v3 + id: release + with: + token: ${{ secrets.GITHUB_TOKEN }} + release-type: simple + package-name: word.lua + extra-files: | + README.md + lua/word/util/version.lua + + - uses: actions/checkout@v4 + + - uses: rickstaa/action-create-tag@v1 + if: ${{ steps.release.outputs.release_created }} + with: + tag: stable + message: "Stable release: ${{ steps.release.outputs.tag_name }}" + force_push_tag: true diff --git a/.luacheckrc b/.luacheckrc index bd7c617..2d2d4b5 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,8 +1,21 @@ +std = luajit +cache = true +codes = true +self = false + +exclude_files = { + "_neovim/*", + "_runtime/*" +} + +read_globals = { + "vim" +} -- Global objects globals = { "_", "vim", - "dorm", + "word", "log", } @@ -10,7 +23,6 @@ std = "max+busted" ignore = { "631", -- max_line_length + "212", + "122" } - --- Don't report unused self arguments of methods. -self = false diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..5569683 --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,18 @@ +blanks_around_headings: + lines_below: 0 +ul_style: { style: sublist } +# not autofixable +ol-prefix: { style: ordered } +line-length: + tables: false + code_blocks: false +no-inline-html: + allowed_elements: [img, details, summary, kbd, a, br] + +#───────────────────────────────────────────────────────────────────────────── +# DISABLED +ul-indent: false # not compatible with using tabs +no-hard-tabs: false # taken care of by editorconfig +blanks-around-lists: false # space waster +first-line-heading: false # e.g., ignore-comments +no-emphasis-as-heading: false # sometimes useful diff --git a/.neoconf.json b/.neoconf.json new file mode 100644 index 0000000..a220e07 --- /dev/null +++ b/.neoconf.json @@ -0,0 +1,18 @@ +{ + "neoconf": { + "global_settings": "neoconf.json", + "import": {}, + "plugins": { + "lua_ls": { + "enabled_for_neovim_config": true, + "enabled": true + } + } + }, + "lspconfig": { + "lua_ls": { + "Lua.workspace.checkThirdParty": true, + "Lua.runtime.version": "LuaJIT" + } + } +} diff --git a/.null-ls_791419_flake.nix b/.null-ls_791419_flake.nix new file mode 100644 index 0000000..b103691 --- /dev/null +++ b/.null-ls_791419_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/Justfile b/Justfile new file mode 100644 index 0000000..20e8d07 --- /dev/null +++ b/Justfile @@ -0,0 +1,14 @@ +all: slint llint clean + +slint : + stylua --check . + +clean: + find --glob '*-E' -x rm + +llint: + luacheck . + + +version: + echo "0.1.0" diff --git a/Makefile b/Makefile deleted file mode 100644 index 66c47f0..0000000 --- a/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -NVIM_BIN ?= nvim - -clean: - fd --glob '*-E' -x rm - - - - - -test: - echo "" diff --git a/README.md b/README.md index a4fa880..3605257 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,11 @@ --- -`for only neovim currently, not vim` `for neovim 0.10+` ## Introduction -- **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]. +**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. @@ -21,11 +20,14 @@ ## Requirements -- [neovim 0.10+](https://neovim.io) +- must have at least [neovim 0.10+](https://neovim.io) -## Install +## Quickstart -### lazy.nvim +
+ +lazy.nvim + ```lua { @@ -33,29 +35,76 @@ lazy = false, version = false, config = true, + breanch = "master", opts = {}, + dependencies = { + "nvim-telescope/telescope.nvim", + "nvim-nio", + "pathlib.nvim", + "plenary-nvim", + } } ``` +
+ --- -### plug.vim +
+ + +plug.vim + ```vim +Plug "nvim-telescope/telescope.nvim" Plug "clpi/word.lua", { \ "branch" : "main", \ "do" : ":lua require('word').setup()" \ } ``` +
+ --- -### packer.nvim +
+Vundle + +```vim + Plugin 'nvim-telescope/telescope.nvim' + Plugin 'renerocksai/telekasten.nvim' +``` + +
+ +--- + +
+ + +dein.vim + + +```vim +call dein#add('clpi/word.lua') +``` + +
+ +--- + +
+ + +packer.nvim + ```lua use { "clp", rocks = { + "nvim-telescope/telescope.nvim", "nvim-nio", "nui.nvim", "plenary.nvim", @@ -68,6 +117,8 @@ use { } ``` +
+ ## Config check back! @@ -78,12 +129,13 @@ check back! ## Todo -- [ ] Bring at least a few scaffolded modules to functionality +- [ ] Bring at least a few scaffolded modules to functionality - [ ] Automate flake creation through GH Actions - [ ] Fix rudimentary commands ported over to bring to base functionality - [ ] Once at base functionality, clean up and refactor to bring to a `0.1.0` release - [ ] Allow optional choice of telescope or not - [ ] Add other package manager support +- [ ] **Support [blink-cmp] and** [nvim-cmp] and [magazine-cmp] when possible ## Support @@ -91,7 +143,9 @@ check back! ## Credits -`word.lua` is a project by [clpi](github.com/clpi) and is licensed under the [MIT](./LICENSE) license. +`word.lua` is a project by [clpi](github.com/clpi) and is licensed under the [MIT](./LICENSE) license. For information about **contributing**, please consult the [CONTRIBUTING.md](./CONTRIBUTING.md) file. + +special thanks goes to [nvim-neorg/neorg](https://github.com/nvim-neorg/neorg) for providing the inspiration and basis of this project. thank you and keep updated! @@ -100,5 +154,6 @@ thank you and keep updated! - [word.lua on dotfyle](https://dotfyle.com/plugins/clpi/word.lua) +

(back to top)

diff --git a/assets/versions.json b/assets/versions.json new file mode 100644 index 0000000..c8481e6 --- /dev/null +++ b/assets/versions.json @@ -0,0 +1,11 @@ +{ + "version": "0.1.0", + "stamp": "", + "hashes": { + "x86_64-linux": "", + "aarch64-linux": "", + "x86_64-darwin": "", + "aarch64-darwin": "", + "x86_64-windows": "" + } +} diff --git a/flake.lock b/flake.lock index bf53ed2..b74d184 100644 --- a/flake.lock +++ b/flake.lock @@ -2,23 +2,38 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1731676054, - "narHash": "sha256-OZiZ3m8SCMfh3B6bfGC/Bm4x3qc1m2SVEAlkV6iY7Yg=", - "owner": "nixos", + "lastModified": 1731799881, + "narHash": "sha256-GRlDXqmwJoW3F0Ymn0ETLsxujLD5idvdaDEzIjF5EEs=", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "5e4fbfb6b3de1aa2872b76d49fafc942626e2add", + "rev": "cd43d6867192ddfb98ba106065a89790e2722b3f", "type": "github" }, "original": { - "owner": "nixos", - "ref": "nixos-unstable", + "owner": "NixOS", "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "systems": "systems" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index b103691..e9b0fe3 100644 --- a/flake.nix +++ b/flake.nix @@ -1,14 +1,23 @@ { - 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; + description = "word.lua, the infinitely extensiblye markdown environment"; - packages.x86_64-linux.default = self.packages.x86_64-linux.hello; + inputs.nixpkgs.url = "github:NixOS/nixpkgs"; + inputs.systems.url = "github:nix-systems/default"; + outputs = { self, nixpkgs, systems }: let + supportedSystems = nixpkgs.lib.genAttrs (import systems); + forEachSystem = function: supportedSystems (system: + function nixpkgs.legacyPackages.${system}); + in { + devShells = forEachSystem (pkgs: { + default = pkgs.mkShell { + packages = [ + pkgs.stylua + pkgs.luaPackages.luacheck + pkgs.luajitPackages.vusted + pkgs.selene + ]; + }; + }); }; } diff --git a/lua/telescope/_extensions/choose/init.lua b/lua/telescope/_extensions/choose/init.lua new file mode 100644 index 0000000..c1d7577 --- /dev/null +++ b/lua/telescope/_extensions/choose/init.lua @@ -0,0 +1,78 @@ +local t = require("telescope") +return t.register_extension({ + setup = function(topts) + local spec_opts = vim.F.if_nil(topts.specific_opts, {}) + topts.specific_opts = nil + + if #topts == 1 and topts[1] ~= nil then + topts = topts[1] + end + + local pic = require("telescope.pickers") + local fdr = require("telescope.finders") + local cfv = require("telescope.config").values + local act = require("telescope.actions") + local ast = require("telescope.actions.state") + local str = require("plenary.strings") + local edi = require("telescope.pickers.entry_display") + local uti = require("telescope.utils") + + __TelescopeUISelectSpecificOpts = vim.F.if_nil( + __TelescopeUISelectSpecificOpts, + vim.tbl_extend("keep", spec_opts, { + ["codeaction"] = { + make_indexed = function(items) + local ix_items = {} + local widths = { + idx = 0, + command_title = 0, + client_name = 0 + } + for idx, item in ipairs(items) do + local client_id, title + client_id = item.ctx.client_id + title = item.action.title + local client = vim.lsp.get_client_by_id(client_id) + local ent = { + idx = idx, + add = { + command_title = title:gsub("\r\n", "\\r\\n"):gsub("\n", "\\n"), + client_name = client and client.name or "unknown" + }, + text = item, + } + table.insert(ix_items, ent) + widths.idx = math.max(widths.idx, #tostring(ent.idx)) + widths.command_title = math.max(widths.command_title, #ent.add.command_title) + widths.client_name = math.max(widths.client_name, #ent.add.client_name) + end + return ix_items, widths + end + }, + make_displayer = function(widths) + return edi.create { + separator = " ", + items = { + { width = widths.idx + 1 }, -- +1 for ":" suffix + { width = widths.command_title }, + { width = widths.client_name }, + }, + } + end, + make_display = function(displayer) + return function(e) + return displayer { + { e.value.idx .. ":", "TelescopePromptPrefix" }, + { e.value.add.command_title }, + { e.value.add.client_name, "TelescopeResultsComment" }, + } + end + end, + make_ordinal = function(e) + return e.idx .. e.add["command_title"] + end, + + }) + ) + end +}) diff --git a/lua/telescope/_extensions/word/init.lua b/lua/telescope/_extensions/word.lua similarity index 61% rename from lua/telescope/_extensions/word/init.lua rename to lua/telescope/_extensions/word.lua index 857062a..f76d875 100644 --- a/lua/telescope/_extensions/word/init.lua +++ b/lua/telescope/_extensions/word.lua @@ -1,15 +1,15 @@ -local tel = require("telescope") -local act = require("telescope.actions") -local set = require("telescope.actions.set") -local sta = require("telescope.actions.state") -local edi = require("telescope.pickers.entry_display") -local cfg = require("telescope.config") -local pic = require("telescope.pickers") -local fnd = require("telescope.finders") -local pre = require("telescope.previewers") -local srt = require("telescope.sorters") -local bui = require("telescope.builtin") -local win = require("telescope.pickers.window") +local hastel, tel = pcall(require, "telescope") +-- local act = require("telescope.actions") +-- local set = require("telescope.actions.set") +-- local sta = require("telescope.actions.state") +-- local edi = require("telescope.pickers.entry_display") +-- local cfg = require("telescope.config") +-- local pic = require("telescope.pickers") +-- local fnd = require("telescope.finders") +-- local pre = require("telescope.previewers") +-- local srt = require("telescope.sorters") +local hasbui, bui = pcall(require, "telescope.builtin") +-- local win = require("telescope.pickers.window") local has_word, word = pcall(require, "word") @@ -62,4 +62,11 @@ function M.setup() tel.load_extension("word") end -return M +-- return M +-- +return tel.register_extension { + -- setup = word.setup, + exports = { + -- word = require("telescope.builtin").find_files + } +} diff --git a/lua/telescope/_extensions/word/actions/init.lua b/lua/telescope/_extensions/word/actions/init.lua new file mode 100644 index 0000000..e69de29 diff --git a/lua/telescope/_extensions/word/config/init.lua b/lua/telescope/_extensions/word/config/init.lua new file mode 100644 index 0000000..e69de29 diff --git a/lua/telescope/_extensions/word/core/init.lua b/lua/telescope/_extensions/word/core/init.lua new file mode 100644 index 0000000..e69de29 diff --git a/lua/telescope/_extensions/word/data/init.lua b/lua/telescope/_extensions/word/data/init.lua new file mode 100644 index 0000000..88fc582 --- /dev/null +++ b/lua/telescope/_extensions/word/data/init.lua @@ -0,0 +1,3 @@ +local bi = require("telescope.builtin") +local act = require("telescope.actions") +local state = require("telescope.actions.state") diff --git a/lua/telescope/_extensions/word/picker/init.lua b/lua/telescope/_extensions/word/picker/init.lua new file mode 100644 index 0000000..e69de29 diff --git a/lua/test/init.vim b/lua/test/init.vim new file mode 100644 index 0000000..9a028c1 --- /dev/null +++ b/lua/test/init.vim @@ -0,0 +1,14 @@ +set display=lastline directory='' noswapfile + +let $word = getcwd() +let $help = getcwd() .. '/help' +let $deps = getcwd() .. '/deps' + +set rtp^=$word,$help +set packpath=$deps + +packloadall + + + + diff --git a/lua/word/config/opts.lua b/lua/word/config/opts.lua new file mode 100644 index 0000000..b1c8398 --- /dev/null +++ b/lua/word/config/opts.lua @@ -0,0 +1,10 @@ +M = {} + +M.setup_opts = function() + local o = vim.opt + o.conceallevel = 2 + o.concealcursor = [[nc]] + o.shellslash = true +end + +return M diff --git a/lua/word/config/version.lua b/lua/word/config/version.lua new file mode 100644 index 0000000..39ba7da --- /dev/null +++ b/lua/word/config/version.lua @@ -0,0 +1 @@ +return "0.1.0" diff --git a/lua/word/core/init.lua b/lua/word/core/init.lua new file mode 100644 index 0000000..e69de29 diff --git a/lua/word/core/link/init.lua b/lua/word/core/link/init.lua new file mode 100644 index 0000000..0ef8634 --- /dev/null +++ b/lua/word/core/link/init.lua @@ -0,0 +1,7 @@ +local async = require("plenary.async.control") +local win = require("plenary.window") +local w = require("plenary.strings") +local p = require("plenary.profile") +local dir = require("plenary.scandir") +local sched = vim.schedule +local chan = async.channel diff --git a/lua/word/core/parse/time/init.lua b/lua/word/core/parse/time/init.lua new file mode 100644 index 0000000..e69de29 diff --git a/lua/word/core/ref/init.lua b/lua/word/core/ref/init.lua new file mode 100644 index 0000000..e69de29 diff --git a/lua/word/core/state/init.lua b/lua/word/core/state/init.lua new file mode 100644 index 0000000..e69de29 diff --git a/lua/word/core/tag/init.lua b/lua/word/core/tag/init.lua new file mode 100644 index 0000000..e69de29 diff --git a/lua/word/graph/init.lua b/lua/word/graph/init.lua new file mode 100644 index 0000000..e619786 --- /dev/null +++ b/lua/word/graph/init.lua @@ -0,0 +1,3 @@ +G = {} + +return G diff --git a/lua/word/init.lua b/lua/word/init.lua index 06570bf..2a6a5ad 100644 --- a/lua/word/init.lua +++ b/lua/word/init.lua @@ -2,8 +2,9 @@ --- This file marks the beginning of the entire plugin. It's here that everything fires up and starts pumping. --- @brief ]] -local word = { +local W = { callbacks = require("word.util.callback"), + version = require("word.config.version"), config = require("word.config"), lsp = require("word.lsp"), cmd = require("word.cmd"), @@ -14,7 +15,7 @@ local word = { lib = require("word.util.lib") } -local config, log, mod, utils = word.config, word.log, word.mod, word.utils +local config, log, mod, utils = W.config, W.log, W.mod, W.utils --- @init "word.config" @@ -22,7 +23,7 @@ local config, log, mod, utils = word.config, word.log, word.mod, word.utils --- @param cfg word.configuration.user? A table that reflects the structure of `config.user_config`. --- @see config.user_config --- @see word.configuration.user -function word.setup(cfg) +function W.setup(cfg) -- Ensure that we are running Neovim 0.10+ assert(utils.is_minimum_version(0, 10, 0), "word requires at least Neovim version 0.10 to operate!") @@ -33,6 +34,7 @@ function word.setup(cfg) workspace = { config = { workspaces = { + default = "~/word", word = "~/word" } } @@ -48,7 +50,15 @@ function word.setup(cfg) -- With the explicit check `load = false` will issue an error. if cfg.load == nil then cfg.load = { - ["base"] = {}, + base = {}, + workspace = { + config = { + workspaces = { + default = "~/word", + word = "~/word" + } + } + } } end @@ -60,18 +70,18 @@ function word.setup(cfg) -- 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. - word.org_file_entered(false) + W.org_file_entered(false) else -- 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) + W.org_file_entered(true) end, {}) vim.api.nvim_create_autocmd("BufAdd", { pattern = "word", callback = function() - word.org_file_entered(false) + W.org_file_entered(false) end, }) end @@ -83,7 +93,7 @@ end --- 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 word.org_file_entered(manual, arguments) +function W.org_file_entered(manual, arguments) -- Extract the init list from the user config local init_list = config.user_config and config.user_config.load or {} @@ -155,9 +165,9 @@ end --- Returns whether or not word is loaded --- @return boolean -function word.is_loaded() +function W.is_loaded() return config.started end -- require("telescope").load_extension("word") -return word +return W diff --git a/lua/word/mod/cmd/commands/rename/init.lua b/lua/word/mod/cmd/commands/rename/init.lua new file mode 100644 index 0000000..e69de29 diff --git a/lua/word/mod/job/init.lua b/lua/word/mod/job/init.lua new file mode 100644 index 0000000..32382e8 --- /dev/null +++ b/lua/word/mod/job/init.lua @@ -0,0 +1 @@ +local uv = vim.uv diff --git a/lua/word/mod/tag/init.lua b/lua/word/mod/tag/init.lua new file mode 100644 index 0000000..e69de29 diff --git a/lua/word/ui/hl/init.lua b/lua/word/ui/hl/init.lua new file mode 100644 index 0000000..84557a5 --- /dev/null +++ b/lua/word/ui/hl/init.lua @@ -0,0 +1,7 @@ +H = {} + +H.add_hl_group = function(name, opts) + vim.api.nvim_set_hl(0, name, opts) +end + +return H diff --git a/plugin/word.lua b/plugin/word.lua new file mode 100644 index 0000000..f131ed8 --- /dev/null +++ b/plugin/word.lua @@ -0,0 +1,25 @@ +if vim.g.wordlua ~= nil then + return +else + vim.g.wordlua = true +end + +local api, lsp, fn = vim.api, vim.lsp, vim.fn + +if fn.has("nvim-0.10") ~= 1 then + local v = vim.version() +end + +local cmd = vim.api.nvim_create_user_command +local acmd = vim.api.nvim_create_autocmd + +cmd("WordInit", function() + require("telescope.builtin").find_files({ + + }) +end, { + desc = "Run a Word command", + range = true, + bang = false, + nargs = 0 +}) diff --git a/scripts/gendocs.lua b/scripts/gendocs.lua new file mode 100644 index 0000000..e707948 --- /dev/null +++ b/scripts/gendocs.lua @@ -0,0 +1,10 @@ +local files = { + "./../lua/word/init.lua", + "./../lua/word/core/init.lua", + "./../lua/word/mod/init.lua", + "./../lua/word/util/lib.lua", +} +local destination = 'doc/word_api.txt' + +vim.fn.system(('lemmy-help %s > %s'):format(table.concat(files, ' '), destination)) +vim.cmd([[qa!]]) diff --git a/scripts/logchg.py b/scripts/logchg.py new file mode 100644 index 0000000..3972bfd --- /dev/null +++ b/scripts/logchg.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 + +# encoding: utf-8 + +""" +Prepares changelog +""" + +import os +from pathlib import Path +from datetime import datetime + +TAG = os.environ["TAG"] +VER = TAG[1:] +CHG = Path("./../CHANGELOG.md") + + +def read_chglog() -> list[str]: + result: list[str] = [] + with CHG.open() as cl: + result = cl.readlines() + return result + + +def write_chglog(lns: list[str]): + with CHG.open("w") as cl: + cl.writelines(lns) + + +def main(): + ins_i = -1 + lns = read_chglog() + for i in range(len(lns)): + ln = lns[i] + if ln.startswith("## Unreleased"): + ins_i = i + 1 + elif ln.startswith(f"## [v{VER}]"): + print("CHANGELOG already updated") + return + elif ln.startswith("## [v"): + break + if ins_i < 0: + raise RuntimeError("Couldn't find unreleased section") + lns.insert(ins_i, "\n") + lns.insert(ins_i + 1, + f"## [v{VERSION}](https://github.com/clpi/word.lua/releases/tag/v{VERSION}) - " + f"{datetime.now().strftime('%Y-%m-%d')}\n", + + ) + write_chglog(lns) + # print(f"Readying CHANGELOG.md: {TAG}") + + + +if __name__ == "__main__": + main() diff --git a/scripts/logrel.py b/scripts/logrel.py new file mode 100644 index 0000000..3190829 --- /dev/null +++ b/scripts/logrel.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python3 + +# encoding: utf-8 + +""" +Prepares release notes upon release +""" + +import os + +from packaging.version import parse +from enum import StrEnum +from pathlib import Path + +TAG = os.environ["TAG"] + + +class MiscHeader(StrEnum): + UNREL = "### Unreleased" + + +class Header(StrEnum): + ADDED = "### Added" + CHANGED = "### Changed" + FIXED = "### Fixed" + REMOVED = "### Removed" + + def addto(self, s: str) -> str: + return self + s + + @staticmethod + def match(ln: str): + for h in Header: + if ln.startswith(h.value): + return h + return None + + +def open_changelog() -> str: + in_curr_sel = False + curr_notes: list[str] = [] + chglog = Path("./../CHANGELOG.md") + with chglog.open() as chg: + for ln in chg: + if ln.startswith("## "): + if ln.startswith("## Unreleased"): + continue + if ln.startswith(f"## [{TAG}]"): + in_curr_sel = True + continue + break + if in_curr_sel: + if h := Header.match(ln): + ln = h.addto(":*\n") + curr_notes.append(ln) + assert curr_notes + return "## What's new\n\n" + "".join(curr_notes).strip() + "\n" + + +def read_commits() -> str: + new_v = parse(TAG) + all_t = os.popen("git tag -l --sort=-v:refname").read().split("\n") + last_t: str | None = None + for t in all_t: + if not t.strip(): + continue + v = parse(t) + if new_v.pre is None and v.pre is not None: + continue + if v < new_v: + last_t = t + break + if last_t is not None: + cmts = os.popen(f"git log {last_t}..{TAG} --oneline --first-parent").read() + else: + cmts = os.popen("git log --oneline --first-parents").read() + return "## Commits\n\n" + cmts + + +def main(): + print(open_changelog()) + print(read_commits()) + + +if __name__ == "__main__": + main() diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100644 index 0000000..05b382e --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -e +git pull + +TAG=$(just version) + +export TAG + +read -r -p "Releasing $TAG -- continue? (Y/n) " pr + +if [[ $pr == "n" || $pr == "N" || $pr == "no" || $pr == "No" ]]; then + echo "OK! Cancelled." + exit 1 +else + python ./logchg.py + git add -A + git commit -m "chore(release): bump version to $TAG for release" || true + git push + echo "Creating new git tag $TAG" + git tag "$TAG" -m "$TAG" + git push --tags +fi diff --git a/scripts/test.sh b/scripts/test.sh index e69de29..7257189 100644 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash + +set -euo pipefall + +declare -r module="word" +declare -r packdir="./tests/site/pack/deps/start" +declare test_scope="${module}" +declare test_logs="" + +while [[ $# -gt 0 ]]; do + + case "${1}" in + --clean | -c) + shift + echo "[test] cleaning up env..." + rm -rf "${packdir}" + echo "[test] done." + ;; + *) + if [[ "${test_scope}" == "${module}" ]] && [[ "${1}" == "${module}/"* ]]; then + test_scope="${1}" + fi + shift + ;; + esac +done + +function setup_env() { + echo + echo "[test] setting up env..." + echo + if [[ ! -d "${packdir}" ]]; then + mkdir -p "${packdir}" + fi + if [[ ! -d "${packdir}/plenary.nvim" ]]; then + echo "[plug] installing plenary.nvim..." + git clone https://github.com/nvim-lua/plenary.nvim "${packdir}/plenary.nvim" + local -r plenary_353_patch="$(pwd)/scripts/plenary_353.patch" + git -C "${packdir}/plenary.nvim" apply "${plenary_353_patch}" + echo "[plug] done" + echo + fi + echo "[test] env ready" + echo +} + +luacov_init() { + luacov_dir="$(dirname "$(luarocks which luacov 2>/dev/null | head -1)")" + if [[ "${luacov_dir}" == "." ]]; then + luacov_dir="" + fi + + if test -n "${luacov_dir}"; then + rm -f luacov.*.out + export LUA_PATH=";;${luacov_dir}/?.lua" + fi +} +luacov_end() { + if test -n "${luacov_dir}"; then + if test -f "luacov.stats.out"; then + luacov + + echo + tail -n +$(($(grep -n "^Summary$" luacov.report.out | cut -d":" -f1) - 1)) luacov.report.out + fi + fi +} + +setup_env + +luacov_init + +if [[ -d "./tests/${test_scope}/" ]]; then + test_logs=$(nvim --headless --noplugin -u tests/init.lua -c "lua require('plenary.test_harness').test_directory('./tests/${test_scope}/', { minimal_init = 'tests/init.lua', sequential = true })") +elif [[ -f "./tests/${test_scope}_spec.lua" ]]; then + test_logs=$(nvim --headless --noplugin -u tests/init.lua -c "lua require('plenary.busted').run('./tests/${test_scope}_spec.lua')") +fi + +echo "${test_logs}" + +luacov_end diff --git a/selene.toml b/selene.toml index 5867a2a..5d24c69 100644 --- a/selene.toml +++ b/selene.toml @@ -1,4 +1,10 @@ -std="vim" +std = "lua51+vim" +exclude = [] + +[rules] +unused_variables = "allow" +shadowing = "allow" +mixed_table = "allow" [lints] -mixed_table="allow" +mixed_table = "allow" diff --git a/word-scm-1.rockspec b/word-scm-1.rockspec index a3119fe..510a260 100644 --- a/word-scm-1.rockspec +++ b/word-scm-1.rockspec @@ -1,12 +1,26 @@ -local MODREV, SPECREV = "scm", "-1" rockspec_format = "3.0" -package = "word" -version = MODREV .. SPECREV +package = "word.lua" +version = "0.1.0" +source = { + url = "git://github.com/clpi/word.lua", + tag = nil +} description = { summary = "Extensibility for everyone", + detailed = [[ + org for markdown for neovim + ]], + description = [[ + extensibility of org without the hassle of another syntax + ]], + homepage = "word.cli.st", + maintainer = "github.com/clpi", labels = { "wiki", "plugin", "neovim", "notes", "markdown" }, homepage = "https://github.com/clpi/word.lua", + labels = { + "wiki", "neovim", "notes", "org", "markdown" + }, license = "MIT", } @@ -34,6 +48,11 @@ test_dependencies = { "nvim-treesitter == 0.9.2", } +test = { + type = "command", + command = "scripts/test.sh" +} + build = { type = "builtin", copy_directories = { diff --git a/word.yml b/word.yml deleted file mode 100644 index 74434a2..0000000 --- a/word.yml +++ /dev/null @@ -1,2 +0,0 @@ -name: word.lua -publish: false