├── .github ├── dependabot.yml └── workflows │ ├── lint.yml │ ├── panvimdoc.yml │ └── release-please.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── doc ├── .gitkeep ├── neorg-agenda.txt ├── neorg-extras.txt ├── neorg-roam.txt └── tags ├── docs ├── neorg-agenda.md └── neorg-roam.md ├── lua └── neorg │ └── modules │ └── external │ ├── agenda │ └── module.lua │ ├── many-mans │ └── module.lua │ └── roam │ └── module.lua └── test ├── capture_edge_cases.norg ├── rg_for_all_tasks.txt └── rg_for_block_text.txt /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | # Maintain dependencies for GitHub Actions 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "weekly" 8 | open-pull-requests-limit: 10 9 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Linting and style checking 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | permissions: 9 | contents: write 10 | pull-requests: write 11 | 12 | jobs: 13 | stylua: 14 | name: stylua 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v4 18 | - uses: JohnnyMorganz/stylua-action@v4 19 | with: 20 | token: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }} 21 | version: latest # NOTE: we recommend pinning to a specific version in case of formatting changes 22 | # CLI arguments 23 | args: -v --verify . 24 | 25 | - uses: stefanzweifel/git-auto-commit-action@v5 26 | with: 27 | commit_message: "chore: autoformat with stylua" 28 | branch: ${{ github.ref }} 29 | 30 | - name: Push changes 31 | uses: ad-m/github-push-action@master 32 | with: 33 | github_token: ${{ secrets.GITHUB_TOKEN }} 34 | branch: ${{ github.ref }} 35 | -------------------------------------------------------------------------------- /.github/workflows/panvimdoc.yml: -------------------------------------------------------------------------------- 1 | name: panvimdoc 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | paths: 7 | - README.md 8 | - .github/workflows/panvimdoc.yml 9 | 10 | permissions: 11 | contents: write 12 | 13 | jobs: 14 | docs: 15 | runs-on: ubuntu-latest 16 | name: pandoc to vimdoc 17 | steps: 18 | - uses: actions/checkout@v4 19 | - uses: kdheepak/panvimdoc@main 20 | with: 21 | vimdoc: ${{ github.event.repository.name }} 22 | - uses: stefanzweifel/git-auto-commit-action@v5 23 | with: 24 | commit_message: "chore: Auto-generate docs" 25 | branch: ${{ github.head_ref }} 26 | -------------------------------------------------------------------------------- /.github/workflows/release-please.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | 6 | permissions: 7 | contents: write 8 | pull-requests: write 9 | 10 | name: release-please 11 | 12 | jobs: 13 | release-please: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: googleapis/release-please-action@v4 17 | with: 18 | # this assumes that you have created a personal access token 19 | # (PAT) and configured it as a GitHub action secret named 20 | # `MY_RELEASE_PLEASE_TOKEN` (this secret name is not important). 21 | token: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }} 22 | # this is a built-in strategy in release-please, see "Action Inputs" 23 | # for more options 24 | release-type: simple 25 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [0.7.0](https://github.com/juniorsundar/neorg-extras/compare/v0.6.0...v0.7.0) (2025-02-09) 4 | 5 | 6 | ### Features 7 | 8 | * **agenda:** Add `workspace` option for neorg-agenda ([#53](https://github.com/juniorsundar/neorg-extras/issues/53)) ([19102d0](https://github.com/juniorsundar/neorg-extras/commit/19102d07b067cca7b92dd37aad0be3adf23f4b30)) 9 | * **node:** Autogen names can be snake_cased (default: false) ([#51](https://github.com/juniorsundar/neorg-extras/issues/51)) ([ec20393](https://github.com/juniorsundar/neorg-extras/commit/ec20393536bdda5bc7e834f28a401c08c51c1cad)) 10 | * **roam:** Support for `snacks.picker` in Roam ([#54](https://github.com/juniorsundar/neorg-extras/issues/54)) ([d2ae729](https://github.com/juniorsundar/neorg-extras/commit/d2ae7290159e7bdfcb5aab483d3f59b242e7e914)) 11 | 12 | 13 | ### Bug Fixes 14 | 15 | * **fzf-lua:** Opening blocks+backlinks hang prompt ([868da79](https://github.com/juniorsundar/neorg-extras/commit/868da79e6e1e3ab9e3a7e6175cbc4713ec06359d)) 16 | 17 | 18 | ### Miscellaneous Chores 19 | 20 | * release 0.6.1 ([1bbb56b](https://github.com/juniorsundar/neorg-extras/commit/1bbb56bc8dbba73288e93106581fb93784d1c293)) 21 | * release 0.7.0 ([3a56160](https://github.com/juniorsundar/neorg-extras/commit/3a56160375c6c87de7201684df06d6a5769e7fc7)) 22 | 23 | ## [0.7.0](https://github.com/juniorsundar/neorg-extras/compare/v0.6.0...v0.7.0) (2025-02-09) 24 | 25 | 26 | ### Features 27 | 28 | * **agenda:** Add `workspace` option for neorg-agenda ([#53](https://github.com/juniorsundar/neorg-extras/issues/53)) ([19102d0](https://github.com/juniorsundar/neorg-extras/commit/19102d07b067cca7b92dd37aad0be3adf23f4b30)) 29 | * **node:** Autogen names can be snake_cased (default: false) ([#51](https://github.com/juniorsundar/neorg-extras/issues/51)) ([ec20393](https://github.com/juniorsundar/neorg-extras/commit/ec20393536bdda5bc7e834f28a401c08c51c1cad)) 30 | * **roam:** Support for `snacks.picker` in Roam ([#54](https://github.com/juniorsundar/neorg-extras/issues/54)) ([d2ae729](https://github.com/juniorsundar/neorg-extras/commit/d2ae7290159e7bdfcb5aab483d3f59b242e7e914)) 31 | 32 | 33 | ### Bug Fixes 34 | 35 | * **fzf-lua:** Opening blocks+backlinks hang prompt ([868da79](https://github.com/juniorsundar/neorg-extras/commit/868da79e6e1e3ab9e3a7e6175cbc4713ec06359d)) 36 | 37 | 38 | ### Miscellaneous Chores 39 | 40 | * release 0.6.1 ([1bbb56b](https://github.com/juniorsundar/neorg-extras/commit/1bbb56bc8dbba73288e93106581fb93784d1c293)) 41 | * release 0.7.0 ([3a56160](https://github.com/juniorsundar/neorg-extras/commit/3a56160375c6c87de7201684df06d6a5769e7fc7)) 42 | 43 | ## [0.7.0](https://github.com/juniorsundar/neorg-extras/compare/v0.6.0...v0.7.0) (2025-02-09) 44 | 45 | 46 | ### Features 47 | 48 | * **agenda:** Add `workspace` option for neorg-agenda ([#53](https://github.com/juniorsundar/neorg-extras/issues/53)) ([19102d0](https://github.com/juniorsundar/neorg-extras/commit/19102d07b067cca7b92dd37aad0be3adf23f4b30)) 49 | * **node:** Autogen names can be snake_cased (default: false) ([#51](https://github.com/juniorsundar/neorg-extras/issues/51)) ([ec20393](https://github.com/juniorsundar/neorg-extras/commit/ec20393536bdda5bc7e834f28a401c08c51c1cad)) 50 | * **roam:** Support for `snacks.picker` in Roam ([#54](https://github.com/juniorsundar/neorg-extras/issues/54)) ([d2ae729](https://github.com/juniorsundar/neorg-extras/commit/d2ae7290159e7bdfcb5aab483d3f59b242e7e914)) 51 | 52 | 53 | ### Bug Fixes 54 | 55 | * **fzf-lua:** Opening blocks+backlinks hang prompt ([868da79](https://github.com/juniorsundar/neorg-extras/commit/868da79e6e1e3ab9e3a7e6175cbc4713ec06359d)) 56 | 57 | 58 | ### Miscellaneous Chores 59 | 60 | * release 0.6.1 ([1bbb56b](https://github.com/juniorsundar/neorg-extras/commit/1bbb56bc8dbba73288e93106581fb93784d1c293)) 61 | * release 0.7.0 ([3a56160](https://github.com/juniorsundar/neorg-extras/commit/3a56160375c6c87de7201684df06d6a5769e7fc7)) 62 | 63 | ## [0.6.0](https://github.com/juniorsundar/neorg-extras/compare/v0.5.1...v0.6.0) (2025-01-01) 64 | 65 | 66 | ### Features 67 | 68 | * **capture:** Capture notes and tasks ([#47](https://github.com/juniorsundar/neorg-extras/issues/47)) ([1adeefb](https://github.com/juniorsundar/neorg-extras/commit/1adeefb001f497d4829839180ed524c9da645e4a)) 69 | * **roam:** Can set `roam_base_directory` instead of default `vault` ([8da3083](https://github.com/juniorsundar/neorg-extras/commit/8da30833b9d535580a1cc71198e05c4db34f5821)) 70 | 71 | 72 | ### Bug Fixes 73 | 74 | * **buff-man:** Properly deleting new tab with task view ([9bc1511](https://github.com/juniorsundar/neorg-extras/commit/9bc1511c3b3e77cfb88dabaa5b07857b372d1bad)) 75 | * **documentation:** Removing some old commands ([1ac654a](https://github.com/juniorsundar/neorg-extras/commit/1ac654aa82d8219430acaf7fd33d3a35b67f8c67)) 76 | * **fzf-lua:** `<C-n>` wasn't properly closing fzf prompt ([#50](https://github.com/juniorsundar/neorg-extras/issues/50)) ([88f27d6](https://github.com/juniorsundar/neorg-extras/commit/88f27d6ca7bb866665e9b2104abdb7fb1e138742)) 77 | * **fzf-lua:** `<CR>` didn't clear fzf-lua prompt ([02e5261](https://github.com/juniorsundar/neorg-extras/commit/02e52619b5728130f377fdd4d43bb44508e57322)) 78 | * **fzf-lua:** Interruption when selecting workspace ([d1d9618](https://github.com/juniorsundar/neorg-extras/commit/d1d9618115cd6775d76770db6610db7b942e3c95)) 79 | * **fzf-lua:** workspace-selector wasn't closing promt ([141c0e9](https://github.com/juniorsundar/neorg-extras/commit/141c0e92b9d74b6c83da199a00aa78ba33fce9c0)) 80 | * **roam_base_directory:** Edge case when ~= "" ([ab6d590](https://github.com/juniorsundar/neorg-extras/commit/ab6d5906bbc88ca49430294d8acd66a69e14ac59)) 81 | * Spaces in files/folder/node names effects search ([e262d81](https://github.com/juniorsundar/neorg-extras/commit/e262d81ddb4a40cbf735243efec8635befe28406)) 82 | * **week-number:** Was one less than it was supposed to ([512462e](https://github.com/juniorsundar/neorg-extras/commit/512462ed8721ecc111d8cb23d9d49e3b6617f23c)) 83 | 84 | ## [0.5.1](https://github.com/juniorsundar/neorg-extras/compare/v0.5.0...v0.5.1) (2024-11-07) 85 | 86 | 87 | ### Bug Fixes 88 | 89 | * **agenda-views:** Populate current buffer and window first ([5e49efd](https://github.com/juniorsundar/neorg-extras/commit/5e49efde21def688ce7b0a60dd68698f0865bc18)) 90 | * **backlinks:** Escaping lines that start with @ in backlinks block ([#46](https://github.com/juniorsundar/neorg-extras/issues/46)) ([ab20194](https://github.com/juniorsundar/neorg-extras/commit/ab20194ec7618ecd151445a95e5f7e0803032a8c)) 91 | * **backlinks:** Issue with window ID resolved ([2d06525](https://github.com/juniorsundar/neorg-extras/commit/2d06525234f081dd83db44c6762e83599e1dadbd)) 92 | * **buff-man:** Clean agenda view window upon quit ([2bc8edf](https://github.com/juniorsundar/neorg-extras/commit/2bc8edf33c759279515352a0fd1475a194c784fa)) 93 | * **cycle_task:** Save on task cycle to account for buffer change ([b9132d3](https://github.com/juniorsundar/neorg-extras/commit/b9132d3f9c8d0fb65c8bb609be34634339efedab)) 94 | * Documentation to load configs ([49b6c91](https://github.com/juniorsundar/neorg-extras/commit/49b6c9142fe82aebff22f1708369d63d93b0fcbe)) 95 | * **property_metadata:** Exec auto-indent command on specified buffer ([2bd28ad](https://github.com/juniorsundar/neorg-extras/commit/2bd28ad24ec2bf572b3866c2394061af52eff149)) 96 | * **workspace-selector:** `<C-i>` opens the index properly ([0f429e2](https://github.com/juniorsundar/neorg-extras/commit/0f429e26ba86cd788af517f5e57ae16fb379e35f)) 97 | 98 | ## [0.5.0](https://github.com/juniorsundar/neorg-extras/compare/v0.4.0...v0.5.0) (2024-10-16) 99 | 100 | 101 | ### ⚠ BREAKING CHANGES 102 | 103 | * **treesitter_fold:** Added folding for code blocks 104 | * **backlinks:** Better backlinks buffer ([#39](https://github.com/juniorsundar/neorg-extras/issues/39)) 105 | 106 | ### Features 107 | 108 | * **backlinks:** Better backlinks buffer ([#39](https://github.com/juniorsundar/neorg-extras/issues/39)) ([d93fa7d](https://github.com/juniorsundar/neorg-extras/commit/d93fa7df3373d2048269557668d2610563f7a8e4)) 109 | * **treesitter_fold:** Added folding for code blocks ([d93fa7d](https://github.com/juniorsundar/neorg-extras/commit/d93fa7df3373d2048269557668d2610563f7a8e4)) 110 | 111 | 112 | ### Bug Fixes 113 | 114 | * **workspace_selector:** Wasn't setting workspace with Fzf-Lua ([f7a45ef](https://github.com/juniorsundar/neorg-extras/commit/f7a45ef0b5fc833516921bcbaea65e11d80ba22d)) 115 | 116 | 117 | ### Miscellaneous Chores 118 | 119 | * release 0.5.0 ([0d44a16](https://github.com/juniorsundar/neorg-extras/commit/0d44a161f1d8053ceebb4e4d952f988194ea50f2)) 120 | 121 | ## [0.4.1](https://github.com/juniorsundar/neorg-extras/compare/v0.4.0...v0.4.1) (2024-10-16) 122 | 123 | 124 | ### Bug Fixes 125 | 126 | * **workspace_selector:** Wasn't setting workspace with Fzf-Lua ([f7a45ef](https://github.com/juniorsundar/neorg-extras/commit/f7a45ef0b5fc833516921bcbaea65e11d80ba22d)) 127 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | # [Neorg](https://github.com/nvim-neorg/neorg)Extras 6 | 7 | Neorg add-on to streamline organising your life in plain-text. 8 | 9 |
10 |
11 |
12 |
13 | 14 | # System Prerequisites 15 | 16 | - ripgrep [`rg`](https://github.com/BurntSushi/ripgrep) 17 | - fd [`fd`](https://github.com/sharkdp/fd) 18 | 19 | # Installation 20 | 21 | This works alongside your [Neorg](https://github.com/andreadev-it/neorg-module-tutorials/blob/main/introduction.md#adding-it-to-neorg) installation. 22 | 23 | ## `lazy.nvim` 24 | 25 | ```lua 26 | return { 27 | "nvim-neorg/neorg", 28 | dependencies = { 29 | { 30 | "juniorsundar/neorg-extras", 31 | -- tag = "*" -- Always a safe bet to track current latest release 32 | }, 33 | -- FOR Neorg-Roam Features 34 | --- OPTION 1: Telescope 35 | "nvim-telescope/telescope.nvim", 36 | "nvim-lua/plenary.nvim", 37 | -- OR OPTION 2: Fzf-Lua 38 | "ibhagwan/fzf-lua", 39 | -- OR OPTION 3: Snacks 40 | "folke/snacks.nvim" 41 | }, 42 | config = function() 43 | require('neorg').setup({ 44 | load = { 45 | -- MANDATORY 46 | ["external.many-mans"] = { 47 | config = { 48 | metadata_fold = true, -- If want @data property ... @end to fold 49 | code_fold = true, -- If want @code ... @end to fold 50 | } 51 | }, 52 | -- OPTIONAL 53 | ["external.agenda"] = { 54 | config = { 55 | workspace = nil, -- or set to "tasks_workspace" to limit agenda search to just that workspace 56 | } 57 | }, 58 | ["external.roam"] = { 59 | config = { 60 | fuzzy_finder = "Telescope", -- OR "Fzf" OR "Snacks". Defaults to "Telescope" 61 | fuzzy_backlinks = false, -- Set to "true" for backlinks in fuzzy finder instead of buffer 62 | roam_base_directory = "", -- Directory in current workspace to store roam nodes 63 | node_name_randomiser = false, -- Tokenise node name suffix for more randomisation 64 | node_name_snake_case = false, -- snake_case the names if node_name_randomiser = false 65 | } 66 | }, 67 | } 68 | }) 69 | 70 | -- I add this line here because I want to open 71 | -- up the default Neorg workspace whenever a Neovim instance 72 | -- is started 73 | require("neorg.core").modules.get_module("core.dirman").set_workspace("default") 74 | end 75 | } 76 | ``` 77 | 78 | ## Others 79 | 80 | I don't use any other plugin managers. I haven't tested this with any others. 81 | If anyone happens to test it with `packer`, `rocks.nvim`, etc., please feel free 82 | to create a pull request. 83 | 84 | # [Neorg-Roam](./docs/neorg-roam.md) 85 | 86 | At the moment, this feature relies heavily on the a 3rd-Party Fuzzy Finder like 87 | ([Snacks.picker](https://github.com/folke/snacks.nvim), 88 | [Telescope](https://github.com/nvim-telescope/telescope.nvim) or 89 | [Fzf-Lua](https://github.com/ibhagwan/fzf-lua)). 90 | I have plans to liberate this plugin from this need, but that 91 | is something way down in the future after I have implemented the required basic 92 | features. So, for the moment, users of this plugin will have to bear with this 93 | dependency. 94 | 95 | Also note that there are a lot of similarities in this plugin with [`nvim-neorg/neorg-telescope`](https://github.com/nvim-neorg/neorg-telescope). 96 | It implements these features much better than I do, and more cleanly that I do. 97 | If you are comfortable using that, then you can install it along side this 98 | plugin and simply skip the Neorg-Roam feature-set. 99 | 100 | # [Neorg-Agenda](./docs/neorg-agenda.md) 101 | 102 | In order to organise your life in plain-text, you need to be able to open up 103 | your backlog of work... right? Neorg devs have a GTD system in their pipeline, 104 | but to create anything great you need to invest a lot of time. I am an 105 | inherently impatient person, so I decided to build something temporary that I 106 | can use in the meantime. 107 | 108 | ## Rationale 109 | 110 | I don't want to deviate excessively and create new grammar to accommodate my 111 | GTD because if, in the future, Neorg gains its own builtin GTD feature, I want 112 | to minimise issues of backwards compatibility. The last thing I want is to go 113 | through all my old files and remove artifacts that will interfere with the new 114 | and definitely superior GTD implementation. 115 | 116 | ## Views 117 | 118 | A new buffer that contains all the tasks in your workspace. Note that it will 119 | only consider tasks that are prefixed with a heading tag: 120 | 121 | ```norg 122 | * ( ) This task is recoginsed 123 | 124 | - ( ) This task is not ... yet 125 | ``` 126 | 127 | So if you are someone who prefers to use a bullet based task listing strategy, 128 | this may not be the plugin for you. 129 | 130 | # To-Do 131 | 132 | ## Primary 133 | 134 | - [x] Deadline and time based scheduling 135 | - [x] Sorting by dates, tags, etc. 136 | - [x] Sorting by date and priority (default) 137 | - [x] Sorting by tags 138 | - [ ] Better UI for property tag population (especially dates and times) 139 | - [x] Wrapper around task changer to auto-generate property metadata 140 | - [ ] Alternate views (open to discussion) 141 | - [ ] Permalinking for Neorg-Roam 142 | - [x] Better UI for Backlinks (Telescope/Fuzzy finder is too distracting) 143 | 144 | ## Secondary 145 | 146 | - [ ] Generating graphs for organising tasks 147 | - [ ] Kanban? 148 | -------------------------------------------------------------------------------- /doc/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juniorsundar/neorg-extras/ec3fe9ef6c491e0e93306c427c6f5cc6b6a0d028/doc/.gitkeep -------------------------------------------------------------------------------- /doc/neorg-agenda.txt: -------------------------------------------------------------------------------- 1 | *neorg-agenda.txt* For Last change: 2025 January 01 2 | 3 | ============================================================================== 4 | Table of Contents *neorg-agenda-table-of-contents* 5 | 6 | 1. Page View |neorg-agenda-page-view| 7 | 2. Day View (TM) |neorg-agenda-day-view-(tm)| 8 | 3. Tag View |neorg-agenda-tag-view| 9 | 4. The Property Metadata |neorg-agenda-the-property-metadata| 10 | 5. Sorting-out my Life |neorg-agenda-sorting-out-my-life| 11 | 6. Interactive Task Cycling |neorg-agenda-interactive-task-cycling| 12 | 7. Links |neorg-agenda-links| 13 | 14 | ============================================================================== 15 | 1. Page View *neorg-agenda-page-view* 16 | 17 | This will show all tasks filtered by the provided task states and turn it into 18 | a paginated view. 19 | 20 | `Neorg agenda page ` 21 | 22 | You can list out all possible Neorg task states: 23 | 24 | - `ambiguous` 25 | - `cancelled` 26 | - `done` 27 | - `hold` 28 | - `pending` 29 | - `important` 30 | - `recurring` 31 | - `undone` 32 | 33 | **Examples** 34 | 35 | `Neorg agenda page undone pending` <- Will open agenda view with all pending 36 | and undone tasks in current workspace. 37 | 38 | Tasks are currently segregated by the nodes they are found in. You can hit 39 | `` over the node names to navigate to those nodes as they are hyperlinks. 40 | 41 | The agenda view can be closed with `q`. 42 | 43 | 44 | ============================================================================== 45 | 2. Day View (TM) *neorg-agenda-day-view-(tm)* 46 | 47 | This will sort tasks according to a day view. Something similar to `org-agenda` 48 | but with my own flavour. 49 | 50 | Note that the method I am using to assign "metadata" to tasks is not the 51 | official way to do things. That is still awaiting an update of the tree-sitter 52 | parser. I don’t know how long that will take. And as someone who wants to 53 | organise their life yesterday, I can’t afford to wait that long. Hence: 54 | 55 | `Neorg agenda day` 56 | 57 | You will notice that all of your tasks in the workspace are uncategorised. This 58 | is because we haven’t added the property `ranged_verbatim_tag` that is used 59 | in this plugin-plugin (plugin^2?) to define the sorting categories for the 60 | agenda. You can populate the property tag by checking out |neorg-agenda-this|. 61 | 62 | 63 | ============================================================================== 64 | 3. Tag View *neorg-agenda-tag-view* 65 | 66 | You can also sort tasks by tags. This is useful if you want to sort them 67 | according to projects or pertinent categories. Make sure to include tags in the 68 | property metadata under your tasks if you want these to be sorted. 69 | 70 | `Neorg agenda tag` 71 | 72 | 73 | ============================================================================== 74 | 4. The Property Metadata *neorg-agenda-the-property-metadata* 75 | 76 | >norg 77 | @data property 78 | started: YYYY-MM-DD|HH:MM 79 | completed: YYYY-MM-DD|HH:MM 80 | deadline: YYYY-MM-DD|HH:MM 81 | tag: tag1, tag2, ... 82 | priority: A/B/C ... 83 | @end 84 | < 85 | 86 | There is tree-sitter folding for the `ranged_verbatim_tag` labeled `data`. So 87 | it no longer will take up your visual space. 88 | 89 | Of course, this plug(plugin)in(?) makes your life a lot easier by exposing the 90 | following function: 91 | 92 | `Neorg update_property_metadata` 93 | 94 | This function doesn’t discriminate between task headings or regular headings 95 | (at the moment… I will fix that later). 96 | 97 | This function is multi-purpose: 98 | 99 | 1. It can add the property tag to the current heading if it doesn’t have one 100 | already. 101 | 2. It will update the property tag under the current heading if it has one 102 | already 103 | 104 | 105 | ============================================================================== 106 | 5. Sorting-out my Life *neorg-agenda-sorting-out-my-life* 107 | 108 | I would suggest that you open your Day View (TM) and start going through your 109 | uncategorised tasks and start assigning them a started and deadline property. 110 | Maybe add a tag? You could also add a property (but I haven’t implemented 111 | support for finer sorting yet). 112 | 113 | 114 | ============================================================================== 115 | 6. Interactive Task Cycling *neorg-agenda-interactive-task-cycling* 116 | 117 | Manually changing task states and updating metadata to reflect that can grow 118 | tedious after a point. Its basically doing the same thing twice. And who wants 119 | to waste time looking at a clock and writing down the time to log their tasks? 120 | Vim is (after all) all about reducing redundancy and wasted time, and so the 121 | command: 122 | 123 | `Neorg cycle_task` 124 | 125 | Compresses task state update and property metadata update into one. Calling 126 | this function on a heading that is or isn’t a task will initiate the 127 | interactive task cycling process. The general sequencing of task states are as 128 | follows: 129 | 130 | >txt 131 | # Task Transitions 132 | undone -> cancelled 133 | undone -> pending -> done 134 | undone -> pending -> cancelled 135 | undone -> pending -> hold -> pending -> done 136 | undone -> pending -> hold -> pending -> cancelled 137 | 138 | undone -> ambiguous -> cancelled 139 | undone -> ambiguous -> pending -> done 140 | undone -> ambiguous -> pending -> cancelled 141 | undone -> ambiguous -> pending -> hold -> pending -> done 142 | undone -> ambiguous -> pending -> hold -> pending -> cancelled 143 | undone -> important -> cancelled 144 | undone -> important -> pending -> done 145 | undone -> important -> pending -> cancelled 146 | undone -> important -> pending -> hold -> pending -> done 147 | undone -> important -> pending -> hold -> pending -> cancelled 148 | 149 | undone -> recurring -> done 150 | undone -> recurring -> cancelled 151 | < 152 | 153 | Furthermore, the time properties are populated automatically given the 154 | following state changes: - When creating task -> populate deadline - When 155 | leaving undone -> populate started - When entering cancelled or done -> 156 | populate completed 157 | 158 | With this command, I hope that users will waste less time manually messing 159 | around with the property metadata, and focus more on getting things done. 160 | 161 | ============================================================================== 162 | 7. Links *neorg-agenda-links* 163 | 164 | 1. *Neorg Page View*: https://i.imgur.com/DdVAiQX.png 165 | 2. *Neorg Day View*: https://i.imgur.com/Qaptzbq.png 166 | 3. *Neorg Tag View*: https://i.imgur.com/GEspcD3.png 167 | 168 | Generated by panvimdoc 169 | 170 | vim:tw=78:ts=8:noet:ft=help:norl: 171 | -------------------------------------------------------------------------------- /doc/neorg-extras.txt: -------------------------------------------------------------------------------- 1 | *neorg-extras.txt* For NVIM v0.8.0 Last change: 2025 March 02 2 | 3 | ============================================================================== 4 | Table of Contents *neorg-extras-table-of-contents* 5 | 6 | 1. System Prerequisites |neorg-extras-system-prerequisites| 7 | 2. Installation |neorg-extras-installation| 8 | - lazy.nvim |neorg-extras-installation-lazy.nvim| 9 | - Others |neorg-extras-installation-others| 10 | 3. Neorg-Roam |neorg-extras-neorg-roam| 11 | 4. Neorg-Agenda |neorg-extras-neorg-agenda| 12 | - Rationale |neorg-extras-neorg-agenda-rationale| 13 | - Views |neorg-extras-neorg-agenda-views| 14 | 5. To-Do |neorg-extras-to-do| 15 | - Primary |neorg-extras-to-do-primary| 16 | - Secondary |neorg-extras-to-do-secondary| 17 | 18 | 19 | 20 | ============================================================================== 21 | 1. System Prerequisites *neorg-extras-system-prerequisites* 22 | 23 | - ripgrep `rg` 24 | - fd `fd` 25 | 26 | 27 | ============================================================================== 28 | 2. Installation *neorg-extras-installation* 29 | 30 | This works alongside your Neorg 31 | 32 | installation. 33 | 34 | 35 | LAZY.NVIM *neorg-extras-installation-lazy.nvim* 36 | 37 | >lua 38 | return { 39 | "nvim-neorg/neorg", 40 | dependencies = { 41 | { 42 | "juniorsundar/neorg-extras", 43 | -- tag = "*" -- Always a safe bet to track current latest release 44 | }, 45 | -- FOR Neorg-Roam Features 46 | --- OPTION 1: Telescope 47 | "nvim-telescope/telescope.nvim", 48 | "nvim-lua/plenary.nvim", 49 | -- OR OPTION 2: Fzf-Lua 50 | "ibhagwan/fzf-lua", 51 | -- OR OPTION 3: Snacks 52 | "folke/snacks.nvim" 53 | }, 54 | config = function() 55 | require('neorg').setup({ 56 | load = { 57 | -- MANDATORY 58 | ["external.many-mans"] = { 59 | config = { 60 | metadata_fold = true, -- If want @data property ... @end to fold 61 | code_fold = true, -- If want @code ... @end to fold 62 | } 63 | }, 64 | -- OPTIONAL 65 | ["external.agenda"] = { 66 | config = { 67 | workspace = nil, -- or set to "tasks_workspace" to limit agenda search to just that workspace 68 | } 69 | }, 70 | ["external.roam"] = { 71 | config = { 72 | fuzzy_finder = "Telescope", -- OR "Fzf" OR "Snacks". Defaults to "Telescope" 73 | fuzzy_backlinks = false, -- Set to "true" for backlinks in fuzzy finder instead of buffer 74 | roam_base_directory = "", -- Directory in current workspace to store roam nodes 75 | node_name_randomiser = false, -- Tokenise node name suffix for more randomisation 76 | node_name_snake_case = false, -- snake_case the names if node_name_randomiser = false 77 | } 78 | }, 79 | } 80 | }) 81 | 82 | -- I add this line here because I want to open 83 | -- up the default Neorg workspace whenever a Neovim instance 84 | -- is started 85 | require("neorg.core").modules.get_module("core.dirman").set_workspace("default") 86 | end 87 | } 88 | < 89 | 90 | 91 | OTHERS *neorg-extras-installation-others* 92 | 93 | I don’t use any other plugin managers. I haven’t tested this with any 94 | others. If anyone happens to test it with `packer`, `rocks.nvim`, etc., please 95 | feel free to create a pull request. 96 | 97 | 98 | ============================================================================== 99 | 3. Neorg-Roam *neorg-extras-neorg-roam* 100 | 101 | At the moment, this feature relies heavily on the a 3rd-Party Fuzzy Finder like 102 | (Snacks.picker , Telescope 103 | or Fzf-Lua 104 | ). I have plans to liberate this plugin 105 | from this need, but that is something way down in the future after I have 106 | implemented the required basic features. So, for the moment, users of this 107 | plugin will have to bear with this dependency. 108 | 109 | Also note that there are a lot of similarities in this plugin with 110 | `nvim-neorg/neorg-telescope` . 111 | It implements these features much better than I do, and more cleanly that I do. 112 | If you are comfortable using that, then you can install it along side this 113 | plugin and simply skip the Neorg-Roam feature-set. 114 | 115 | 116 | ============================================================================== 117 | 4. Neorg-Agenda *neorg-extras-neorg-agenda* 118 | 119 | In order to organise your life in plain-text, you need to be able to open up 120 | your backlog of work… right? Neorg devs have a GTD system in their pipeline, 121 | but to create anything great you need to invest a lot of time. I am an 122 | inherently impatient person, so I decided to build something temporary that I 123 | can use in the meantime. 124 | 125 | 126 | RATIONALE *neorg-extras-neorg-agenda-rationale* 127 | 128 | I don’t want to deviate excessively and create new grammar to accommodate my 129 | GTD because if, in the future, Neorg gains its own builtin GTD feature, I want 130 | to minimise issues of backwards compatibility. The last thing I want is to go 131 | through all my old files and remove artifacts that will interfere with the new 132 | and definitely superior GTD implementation. 133 | 134 | 135 | VIEWS *neorg-extras-neorg-agenda-views* 136 | 137 | A new buffer that contains all the tasks in your workspace. Note that it will 138 | only consider tasks that are prefixed with a heading tag: 139 | 140 | >norg 141 | * ( ) This task is recoginsed 142 | 143 | - ( ) This task is not ... yet 144 | < 145 | 146 | So if you are someone who prefers to use a bullet based task listing strategy, 147 | this may not be the plugin for you. 148 | 149 | 150 | ============================================================================== 151 | 5. To-Do *neorg-extras-to-do* 152 | 153 | 154 | PRIMARY *neorg-extras-to-do-primary* 155 | 156 | - ☒ Deadline and time based scheduling 157 | - ☒ Sorting by dates, tags, etc. 158 | - ☒ Sorting by date and priority (default) 159 | - ☒ Sorting by tags 160 | - ☐ Better UI for property tag population (especially dates and times) 161 | - ☒ Wrapper around task changer to auto-generate property metadata 162 | - ☐ Alternate views (open to discussion) 163 | - ☐ Permalinking for Neorg-Roam 164 | - ☒ Better UI for Backlinks (Telescope/Fuzzy finder is too distracting) 165 | 166 | 167 | SECONDARY *neorg-extras-to-do-secondary* 168 | 169 | - ☐ Generating graphs for organising tasks 170 | - ☐ Kanban? 171 | 172 | Generated by panvimdoc 173 | 174 | vim:tw=78:ts=8:noet:ft=help:norl: 175 | -------------------------------------------------------------------------------- /doc/neorg-roam.txt: -------------------------------------------------------------------------------- 1 | *neorg-roam.txt* For Last change: 2025 January 01 2 | 3 | ============================================================================== 4 | Table of Contents *neorg-roam-table-of-contents* 5 | 6 | 1. Set Workspace |neorg-roam-set-workspace| 7 | - Function |neorg-roam-set-workspace-function| 8 | - Default Mappings |neorg-roam-set-workspace-default-mappings| 9 | 2. Nodes |neorg-roam-nodes| 10 | - Rationale |neorg-roam-nodes-rationale| 11 | - Use-Case |neorg-roam-nodes-use-case| 12 | - Function |neorg-roam-nodes-function| 13 | - Default Mappings |neorg-roam-nodes-default-mappings| 14 | 3. Blocks |neorg-roam-blocks| 15 | - Rationale |neorg-roam-blocks-rationale| 16 | - Use-Case |neorg-roam-blocks-use-case| 17 | - Function |neorg-roam-blocks-function| 18 | - Default Mappings |neorg-roam-blocks-default-mappings| 19 | 4. Backlinks |neorg-roam-backlinks| 20 | - Rationale |neorg-roam-backlinks-rationale| 21 | - Use-Case |neorg-roam-backlinks-use-case| 22 | - Function |neorg-roam-backlinks-function| 23 | - Default Mappings |neorg-roam-backlinks-default-mappings| 24 | 5. Capture |neorg-roam-capture| 25 | - Rationale |neorg-roam-capture-rationale| 26 | - Use-Case |neorg-roam-capture-use-case| 27 | - Function |neorg-roam-capture-function| 28 | - Default Mappings |neorg-roam-capture-default-mappings| 29 | 30 | ============================================================================== 31 | 1. Set Workspace *neorg-roam-set-workspace* 32 | 33 | 34 | FUNCTION *neorg-roam-set-workspace-function* 35 | 36 | `Neorg roam select_workspace` 37 | 38 | 39 | DEFAULT MAPPINGS *neorg-roam-set-workspace-default-mappings* 40 | 41 | -------------------------------------------------------------------------- 42 | Mappings Action 43 | ---------- --------------------------------------------------------------- 44 | Sets workspace. 45 | 46 | Sets workspace and opens the index.norg file in the workspace 47 | if it exists. 48 | -------------------------------------------------------------------------- 49 | 50 | ============================================================================== 51 | 2. Nodes *neorg-roam-nodes* 52 | 53 | 54 | RATIONALE *neorg-roam-nodes-rationale* 55 | 56 | Nodes are defined as the individual pages within a workspace. The node name is 57 | defined as the `title` in the page metadata. The node filename is irrelevant 58 | and should only be unique. 59 | 60 | True to the `org-roam` or `logseq` mindset. You shouldn’t have to worry about 61 | organising your workspace files, because you won’t be navigating your 62 | file-tree to find them. Relations should be made using linking rather than 63 | sorting. 64 | 65 | **Example** If you want to sort your nodes according to projects. Create one 66 | (1) node with the "Projects" title and other nodes with titles corresponding to 67 | your project names and include their links in the "Projects" node. You can go 68 | to your projects by either directly opening that node from your fuzzy finder or 69 | opening "Projects" and opening the corresponding project node from the inserted 70 | link. 71 | 72 | You need to agree to this philosophy of managing your work to take full 73 | advantage of this feature. 74 | 75 | 76 | USE-CASE *neorg-roam-nodes-use-case* 77 | 78 | You want to navigate to a node in your workspace. 79 | 80 | You want to insert the node into your cursor location as a link. 81 | 82 | The node you want doesn’t exist yet, and you want to create one with the 83 | title currently present in the Telescope search. This will drop the new node 84 | with unique filename into a `roam_base_directory` folder in the workspace root. 85 | 86 | 87 | FUNCTION *neorg-roam-nodes-function* 88 | 89 | `Neorg roam node` 90 | 91 | 92 | DEFAULT MAPPINGS *neorg-roam-nodes-default-mappings* 93 | 94 | ---------------------------------------------------------------------------- 95 | Mappings Action 96 | ---------- ----------------------------------------------------------------- 97 | Open to selected node. 98 | 99 | Inserts hovering node into cursor location. Node’s title will be 100 | concealing alias. Eg: {:$/workspace/path/tonode:}[Title]. 101 | 102 | Creates new node with title of text in search bar and unique node 103 | name. 104 | ---------------------------------------------------------------------------- 105 | 106 | ============================================================================== 107 | 3. Blocks *neorg-roam-blocks* 108 | 109 | 110 | RATIONALE *neorg-roam-blocks-rationale* 111 | 112 | Blocks are defined as the headings within a workspace. The block name is 113 | defined as the heading text. 114 | 115 | In `logseq`, the block is considered a first-class citizen. In `org-roam` it 116 | could be, as long as you assign a unique ID property to said block. The benefit 117 | of this is that even if the block is changed, any hyperlink to the block will 118 | be unaffected. 119 | 120 | This isn’t a particular feature like that in Neorg as of yet. There may be 121 | something like this in the future. 122 | 123 | 124 | [!NOTE] TODO find ways to treat blocks as first-class citizens. 125 | 126 | USE-CASE *neorg-roam-blocks-use-case* 127 | 128 | You want to navigate to a block in your workspace. 129 | 130 | You want to insert the block into your cursor location as a link. 131 | 132 | 133 | FUNCTION *neorg-roam-blocks-function* 134 | 135 | `Neorg roam block` 136 | 137 | 138 | DEFAULT MAPPINGS *neorg-roam-blocks-default-mappings* 139 | 140 | Mappings Action 141 | ---------- ---------------------------------------------- 142 | Open to selected block. 143 | Inserts hovering block into cursor location. 144 | 145 | ============================================================================== 146 | 4. Backlinks *neorg-roam-backlinks* 147 | 148 | 149 | RATIONALE *neorg-roam-backlinks-rationale* 150 | 151 | Since we are swearing off the file-tree, we need a way to conveniently navigate 152 | between nodes. The backlinks offer us an insight into the ways we can get to 153 | the current node. 154 | 155 | There are two options to view backlinks. Depending on whether to the 156 | configuration `fuzzy_backlinks` is set to `false` or `true`: - `false` - 157 | (default) Opens the backlinks as a vertical-split buffer. - `true` - Opens the 158 | backlinks within the selected fuzzy-finder. 159 | 160 | As a buffer, the entries are **folded**. You can unfold then to reveal a 161 | preview from where the backlinks are extracted. This isn’t necessary with the 162 | fuzzy-finder as it can be configured to show an automatic preview. 163 | 164 | 165 | USE-CASE *neorg-roam-backlinks-use-case* 166 | 167 | You want to determine all backlinks to current node, preview them, and navigate 168 | to them. 169 | 170 | 171 | FUNCTION *neorg-roam-backlinks-function* 172 | 173 | `Neorg roam backlinks` 174 | 175 | 176 | DEFAULT MAPPINGS *neorg-roam-backlinks-default-mappings* 177 | 178 | -------------------------------------------------------------------------- 179 | Mappings Action 180 | ---------- --------------------------------------------------------------- 181 | Open to selected backlink location. 182 | 183 | -------------------------------------------------------------------------- 184 | 185 | ============================================================================== 186 | 5. Capture *neorg-roam-capture* 187 | 188 | 189 | RATIONALE *neorg-roam-capture-rationale* 190 | 191 | Its common to forgot things. Just so you don’t, why not capture it? 192 | 193 | Capturing shouldn’t be difficult, it should be accessible from anywhere. And 194 | getting the captured information shouldn’t be difficult either. 195 | 196 | 197 | USE-CASE *neorg-roam-capture-use-case* 198 | 199 | There are two primary types of use-cases: 1. Capturing idea/task/content 2. 200 | Capturing annotation 201 | 202 | **In case (1)** You are working and suddenly remember a task you need to 203 | accomplish. Simply call `Neorg roam capture todo`. This will open a temporary 204 | buffer where you can capture the task. Once closed, it will append this content 205 | into your daily journal for the day. 206 | 207 | **In case (2)** There’s a really cool code snippet that you want to use at a 208 | later time. Simply select the range in "visual" mode and call `'<,'>Neorg roam 209 | capture selection`. Annotate as you wish and close the buffer. It will be 210 | appended into your daily journal for the day. 211 | 212 | 213 | FUNCTION *neorg-roam-capture-function* 214 | 215 | `Neorg roam capture ` 216 | 217 | 218 | [!NOTE] The following functions are templated. The templates are generated in 219 | "/.capture-templates". 220 | `Neorg roam capture todo` `Neorg roam capture note` `Neorg roam capture 221 | meeting` `Neorg roam capture selection` 222 | You can add more templates into this directory. 223 | 224 | DEFAULT MAPPINGS *neorg-roam-capture-default-mappings* 225 | 226 | In the capture buffer. 227 | 228 | Mappings Action 229 | ------------ ------------------------------------------- 230 | Commit captured content to daily journal. 231 | q Close capture buffer and delete content. 232 | 233 | Generated by panvimdoc 234 | 235 | vim:tw=78:ts=8:noet:ft=help:norl: 236 | -------------------------------------------------------------------------------- /doc/tags: -------------------------------------------------------------------------------- 1 | neorg-extras-installation neorg-extras.txt /*neorg-extras-installation* 2 | neorg-extras-installation-lazy.nvim neorg-extras.txt /*neorg-extras-installation-lazy.nvim* 3 | neorg-extras-installation-others neorg-extras.txt /*neorg-extras-installation-others* 4 | neorg-extras-links neorg-extras.txt /*neorg-extras-links* 5 | neorg-extras-neorg-agenda neorg-extras.txt /*neorg-extras-neorg-agenda* 6 | neorg-extras-neorg-agenda-interactive-task-cycling neorg-extras.txt /*neorg-extras-neorg-agenda-interactive-task-cycling* 7 | neorg-extras-neorg-agenda-rationale neorg-extras.txt /*neorg-extras-neorg-agenda-rationale* 8 | neorg-extras-neorg-agenda-the-property-metadata neorg-extras.txt /*neorg-extras-neorg-agenda-the-property-metadata* 9 | neorg-extras-neorg-agenda-views neorg-extras.txt /*neorg-extras-neorg-agenda-views* 10 | neorg-extras-neorg-roam neorg-extras.txt /*neorg-extras-neorg-roam* 11 | neorg-extras-neorg-roam-backlinks neorg-extras.txt /*neorg-extras-neorg-roam-backlinks* 12 | neorg-extras-neorg-roam-blocks neorg-extras.txt /*neorg-extras-neorg-roam-blocks* 13 | neorg-extras-neorg-roam-nodes neorg-extras.txt /*neorg-extras-neorg-roam-nodes* 14 | neorg-extras-neorg-roam-set-workspace neorg-extras.txt /*neorg-extras-neorg-roam-set-workspace* 15 | neorg-extras-system-prerequisites neorg-extras.txt /*neorg-extras-system-prerequisites* 16 | neorg-extras-table-of-contents neorg-extras.txt /*neorg-extras-table-of-contents* 17 | neorg-extras-to-do neorg-extras.txt /*neorg-extras-to-do* 18 | neorg-extras-to-do-primary neorg-extras.txt /*neorg-extras-to-do-primary* 19 | neorg-extras-to-do-secondary neorg-extras.txt /*neorg-extras-to-do-secondary* 20 | neorg-extras.txt neorg-extras.txt /*neorg-extras.txt* 21 | -------------------------------------------------------------------------------- /docs/neorg-agenda.md: -------------------------------------------------------------------------------- 1 | # Page View 2 | 3 | ![Neorg Page View](https://i.imgur.com/DdVAiQX.png) 4 | 5 | This will show all tasks filtered by the provided task states and turn it into 6 | a paginated view. 7 | 8 | `Neorg agenda page ` 9 | 10 | You can list out all possible Neorg task states: 11 | 12 | - `ambiguous` 13 | - `cancelled` 14 | - `done` 15 | - `hold` 16 | - `pending` 17 | - `important` 18 | - `recurring` 19 | - `undone` 20 | 21 | **Examples** 22 | 23 | `Neorg agenda page undone pending` <- Will open agenda view with all pending 24 | and undone tasks in current workspace. 25 | 26 | Tasks are currently segregated by the nodes they are found in. You can hit 27 | `` over the node names to navigate to those nodes as they are hyperlinks. 28 | 29 | The agenda view can be closed with `q`. 30 | 31 | # Day View (TM) 32 | 33 | ![Neorg Day View](https://i.imgur.com/Qaptzbq.png) 34 | 35 | This will sort tasks according to a day view. Something similar to 36 | `org-agenda` but with my own flavour. 37 | 38 | Note that the method I am using to assign "metadata" to tasks is not the 39 | official way to do things. That is still awaiting an update of the tree-sitter 40 | parser. I don't know how long that will take. And as someone who wants to 41 | organise their life yesterday, I can't afford to wait that long. Hence: 42 | 43 | `Neorg agenda day` 44 | 45 | You will notice that all of your tasks in the workspace are uncategorised. This 46 | is because we haven't added the property `ranged_verbatim_tag` that is used 47 | in this plugin-plugin (plugin^2?) to define the sorting categories for the 48 | agenda. You can populate the property tag by checking out [this](#the-property-metadata). 49 | 50 | # Tag View 51 | 52 | ![Neorg Tag View](https://i.imgur.com/GEspcD3.png) 53 | 54 | You can also sort tasks by tags. This is useful if you want to sort them 55 | according to projects or pertinent categories. Make sure to include tags in the 56 | property metadata under your tasks if you want these to be sorted. 57 | 58 | `Neorg agenda tag` 59 | 60 | # The Property Metadata 61 | 62 | ```norg 63 | @data property 64 | started: YYYY-MM-DD|HH:MM 65 | completed: YYYY-MM-DD|HH:MM 66 | deadline: YYYY-MM-DD|HH:MM 67 | tag: tag1, tag2, ... 68 | priority: A/B/C ... 69 | @end 70 | ``` 71 | 72 | There is tree-sitter folding for the `ranged_verbatim_tag` labeled `data`. 73 | So it no longer will take up your visual space. 74 | 75 | Of course, this plug(plugin)in(?) makes your life a lot easier by exposing the 76 | following function: 77 | 78 | `Neorg update_property_metadata` 79 | 80 | This function doesn't discriminate between task headings or regular headings 81 | (at the moment... I will fix that later). 82 | 83 | This function is multi-purpose: 84 | 85 | 1. It can add the property tag to the current heading if it doesn't have one 86 | already. 87 | 2. It will update the property tag under the current heading if it has one 88 | already 89 | 90 | # Sorting-out my Life 91 | 92 | I would suggest that you open your Day View (TM) and start going through your 93 | uncategorised tasks and start assigning them a started and deadline property. 94 | Maybe add a tag? You could also add a property (but I haven't implemented 95 | support for finer sorting yet). 96 | 97 | # Interactive Task Cycling 98 | 99 | Manually changing task states and updating metadata to reflect that can grow 100 | tedious after a point. Its basically doing the same thing twice. And who wants 101 | to waste time looking at a clock and writing down the time to log their tasks? 102 | Vim is (after all) all about reducing redundancy and wasted time, and so the 103 | command: 104 | 105 | `Neorg cycle_task` 106 | 107 | Compresses task state update and property metadata update into one. Calling 108 | this function on a heading that is or isn't a task will initiate the 109 | interactive task cycling process. The general sequencing of task states are as 110 | follows: 111 | 112 | ```txt 113 | # Task Transitions 114 | undone -> cancelled 115 | undone -> pending -> done 116 | undone -> pending -> cancelled 117 | undone -> pending -> hold -> pending -> done 118 | undone -> pending -> hold -> pending -> cancelled 119 | 120 | undone -> ambiguous -> cancelled 121 | undone -> ambiguous -> pending -> done 122 | undone -> ambiguous -> pending -> cancelled 123 | undone -> ambiguous -> pending -> hold -> pending -> done 124 | undone -> ambiguous -> pending -> hold -> pending -> cancelled 125 | undone -> important -> cancelled 126 | undone -> important -> pending -> done 127 | undone -> important -> pending -> cancelled 128 | undone -> important -> pending -> hold -> pending -> done 129 | undone -> important -> pending -> hold -> pending -> cancelled 130 | 131 | undone -> recurring -> done 132 | undone -> recurring -> cancelled 133 | ``` 134 | 135 | Furthermore, the time properties are populated automatically given the 136 | following state changes: 137 | - When creating task -> populate deadline 138 | - When leaving undone -> populate started 139 | - When entering cancelled or done -> populate completed 140 | 141 | With this command, I hope that users will waste less time manually messing 142 | around with the property metadata, and focus more on getting things done. 143 | 144 | -------------------------------------------------------------------------------- /docs/neorg-roam.md: -------------------------------------------------------------------------------- 1 | # Set Workspace 2 | 3 | ## Function 4 | 5 | `Neorg roam select_workspace` 6 | 7 | ## Default Mappings 8 | 9 | | Mappings | Action | 10 | |----------|-------------------------------------------------------------------------------| 11 | | `` | Sets workspace. | 12 | | `` | Sets workspace and opens the `index.norg` file in the workspace if it exists. | 13 | 14 | # Nodes 15 | 16 | ## Rationale 17 | 18 | Nodes are defined as the individual pages within a workspace. The node name is 19 | defined as the `title` in the page metadata. The node filename is irrelevant 20 | and should only be unique. 21 | 22 | True to the `org-roam` or `logseq` mindset. You shouldn't have to worry 23 | about organising your workspace files, because you won't be navigating your 24 | file-tree to find them. Relations should be made using linking rather than 25 | sorting. 26 | 27 | **Example** If you want to sort your nodes according to projects. Create one 28 | (1) node with the "Projects" title and other nodes with titles corresponding to 29 | your project names and include their links in the "Projects" node. You can go 30 | to your projects by either directly opening that node from your fuzzy finder or 31 | opening "Projects" and opening the corresponding project node from the inserted 32 | link. 33 | 34 | You need to agree to this philosophy of managing your work to take full 35 | advantage of this feature. 36 | 37 | ## Use-Case 38 | 39 | You want to navigate to a node in your workspace. 40 | 41 | You want to insert the node into your cursor location as a link. 42 | 43 | The node you want doesn't exist yet, and you want to create one with the title 44 | currently present in the Telescope search. This will drop the new node with 45 | unique filename into a `roam_base_directory` folder in the workspace root. 46 | 47 | ## Function 48 | 49 | `Neorg roam node` 50 | 51 | ## Default Mappings 52 | 53 | | Mappings | Action | 54 | |----------|-------------------------------------------------------------------------------------------------------------------------------| 55 | | `` | Open to selected node.| 56 | | ``| Inserts hovering node into cursor location. Node's title will be concealing alias. Eg: `{:$/workspace/path/tonode:}[Title]`.| 57 | | `` | Creates new node with title of text in search bar and unique node name. | 58 | 59 | # Blocks 60 | 61 | ## Rationale 62 | 63 | Blocks are defined as the headings within a workspace. The block name is 64 | defined as the heading text. 65 | 66 | In `logseq`, the block is considered a first-class citizen. In `org-roam` it 67 | could be, as long as you assign a unique ID property to said block. The benefit 68 | of this is that even if the block is changed, any hyperlink to the block will 69 | be unaffected. 70 | 71 | This isn't a particular feature like that in Neorg as of yet. There may be 72 | something like this in the future. 73 | 74 | > [!NOTE] 75 | > TODO find ways to treat blocks as first-class citizens. 76 | 77 | ## Use-Case 78 | 79 | You want to navigate to a block in your workspace. 80 | 81 | You want to insert the block into your cursor location as a link. 82 | 83 | ## Function 84 | 85 | `Neorg roam block` 86 | 87 | ## Default Mappings 88 | 89 | | Mappings | Action | 90 | |----------|----------------------------------------------| 91 | | `` | Open to selected block.| 92 | | `` | Inserts hovering block into cursor location. | 93 | 94 | # Backlinks 95 | 96 | ## Rationale 97 | 98 | Since we are swearing off the file-tree, we need a way to conveniently navigate 99 | between nodes. The backlinks offer us an insight into the ways we can get to 100 | the current node. 101 | 102 | There are two options to view backlinks. Depending on whether to the 103 | configuration `fuzzy_backlinks` is set to `false` or `true`: 104 | - `false` - (default) Opens the backlinks as a vertical-split buffer. 105 | - `true` - Opens the backlinks within the selected fuzzy-finder. 106 | 107 | As a buffer, the entries are **folded**. You can unfold then to reveal a 108 | preview from where the backlinks are extracted. This isn't necessary with the 109 | fuzzy-finder as it can be configured to show an automatic preview. 110 | 111 | ## Use-Case 112 | 113 | You want to determine all backlinks to current node, preview them, and navigate to them. 114 | 115 | ## Function 116 | 117 | `Neorg roam backlinks` 118 | 119 | ## Default Mappings 120 | 121 | | Mappings | Action | 122 | |----------|-------------------------------------------------------------------------------| 123 | | `` | Open to selected backlink location. | 124 | 125 | # Capture 126 | 127 | ## Rationale 128 | 129 | Its common to forgot things. Just so you don't, why not capture it? 130 | 131 | Capturing shouldn't be difficult, it should be accessible from anywhere. And 132 | getting the captured information shouldn't be difficult either. 133 | 134 | ## Use-Case 135 | 136 | There are two primary types of use-cases: 137 | 1. Capturing idea/task/content 138 | 2. Capturing annotation 139 | 140 | **In case (1)** 141 | You are working and suddenly remember a task you need to accomplish. Simply 142 | call `Neorg roam capture todo`. This will open a temporary buffer where you 143 | can capture the task. Once closed, it will append this content into your daily 144 | journal for the day. 145 | 146 | **In case (2)** 147 | There's a really cool code snippet that you want to use at a later time. Simply 148 | select the range in "visual" mode and call `'<,'>Neorg roam capture selection`. 149 | Annotate as you wish and close the buffer. It will be appended into your daily 150 | journal for the day. 151 | 152 | ## Function 153 | 154 | `Neorg roam capture ` 155 | 156 | > [!NOTE] 157 | > The following functions are templated. The templates are generated in 158 | > "/.capture-templates". 159 | > 160 | > `Neorg roam capture todo` 161 | > `Neorg roam capture note` 162 | > `Neorg roam capture meeting` 163 | > `Neorg roam capture selection` 164 | > 165 | > You can add more templates into this directory. 166 | 167 | ## Default Mappings 168 | 169 | In the capture buffer. 170 | 171 | | Mappings | Action | 172 | |--------------|------------------------------------------| 173 | | `` | Commit captured content to daily journal.| 174 | | `q` | Close capture buffer and delete content. | 175 | 176 | -------------------------------------------------------------------------------- /lua/neorg/modules/external/agenda/module.lua: -------------------------------------------------------------------------------- 1 | local neorg = require("neorg.core") 2 | local module = neorg.modules.create("external.agenda") 3 | 4 | module.setup = function() 5 | return { 6 | success = true, 7 | requires = { 8 | "core.neorgcmd", 9 | "core.dirman", 10 | "core.integrations.treesitter", 11 | "external.many-mans", 12 | }, 13 | } 14 | end 15 | 16 | module.config.public = { 17 | workspace = nil, 18 | } 19 | 20 | module.load = function() 21 | module.required["core.neorgcmd"].add_commands_from_table({ 22 | ["agenda"] = { 23 | args = 1, 24 | subcommands = { 25 | ["page"] = { 26 | min_args = 1, 27 | max_args = 8, 28 | complete = { 29 | { 30 | "done", 31 | "pending", 32 | "undone", 33 | "hold", 34 | "important", 35 | "cancelled", 36 | "recurring", 37 | "ambiguous", 38 | }, 39 | { 40 | "done", 41 | "pending", 42 | "undone", 43 | "hold", 44 | "important", 45 | "cancelled", 46 | "recurring", 47 | "ambiguous", 48 | }, 49 | { 50 | "done", 51 | "pending", 52 | "undone", 53 | "hold", 54 | "important", 55 | "cancelled", 56 | "recurring", 57 | "ambiguous", 58 | }, 59 | { 60 | "done", 61 | "pending", 62 | "undone", 63 | "hold", 64 | "important", 65 | "cancelled", 66 | "recurring", 67 | "ambiguous", 68 | }, 69 | { 70 | "done", 71 | "pending", 72 | "undone", 73 | "hold", 74 | "important", 75 | "cancelled", 76 | "recurring", 77 | "ambiguous", 78 | }, 79 | { 80 | "done", 81 | "pending", 82 | "undone", 83 | "hold", 84 | "important", 85 | "cancelled", 86 | "recurring", 87 | "ambiguous", 88 | }, 89 | { 90 | "done", 91 | "pending", 92 | "undone", 93 | "hold", 94 | "important", 95 | "cancelled", 96 | "recurring", 97 | "ambiguous", 98 | }, 99 | { 100 | "done", 101 | "pending", 102 | "undone", 103 | "hold", 104 | "important", 105 | "cancelled", 106 | "recurring", 107 | "ambiguous", 108 | }, 109 | }, 110 | name = "external.agenda.page", 111 | }, 112 | ["day"] = { 113 | args = 0, 114 | name = "external.agenda.day", 115 | }, 116 | ["tag"] = { 117 | args = 0, 118 | name = "external.agenda.tag", 119 | }, 120 | }, 121 | }, 122 | }) 123 | end 124 | 125 | module.events.subscribed = { 126 | ["core.neorgcmd"] = { 127 | ["external.agenda.page"] = true, 128 | ["external.agenda.day"] = true, 129 | ["external.agenda.tag"] = true, 130 | }, 131 | } 132 | 133 | module.private = { 134 | -- Sort function specifically for today's tasks by hour and minute 135 | sort_today_tasks = function(a, b) 136 | local a_time = os.time({ 137 | year = tonumber(a.deadline.year) or 2024, 138 | month = tonumber(a.deadline.month) or 8, 139 | day = tonumber(a.deadline.day) or 12, 140 | hour = tonumber(a.deadline.hour) or 0, 141 | min = tonumber(a.deadline.minute) or 0, 142 | sec = 0, 143 | }) 144 | local b_time = os.time({ 145 | year = tonumber(b.deadline.year) or 2024, 146 | month = tonumber(b.deadline.month) or 8, 147 | day = tonumber(b.deadline.day) or 12, 148 | hour = tonumber(b.deadline.hour) or 0, 149 | min = tonumber(b.deadline.minute) or 0, 150 | sec = 0, 151 | }) 152 | return a_time < b_time 153 | end, 154 | 155 | -- Sort function to prioritize by time to deadline and priority 156 | sort_by_time_and_priority = function(a, b) 157 | local current_time = os.time() 158 | local time_a = os.time({ 159 | year = tonumber(a.deadline.year) or 2024, 160 | month = tonumber(a.deadline.month) or 8, 161 | day = tonumber(a.deadline.day) or 12, 162 | hour = tonumber(a.deadline.hour) or 0, 163 | min = tonumber(a.deadline.minute) or 0, 164 | sec = 0, 165 | }) - current_time 166 | local time_b = os.time({ 167 | year = tonumber(b.deadline.year) or 2024, 168 | month = tonumber(b.deadline.month) or 8, 169 | day = tonumber(b.deadline.day) or 12, 170 | hour = tonumber(b.deadline.hour) or 0, 171 | min = tonumber(b.deadline.minute) or 0, 172 | sec = 0, 173 | }) - current_time 174 | 175 | if time_a ~= time_b then 176 | return time_a < time_b 177 | end 178 | 179 | local priority_a = a.priority or "Z" 180 | local priority_b = b.priority or "Z" 181 | return priority_a < priority_b 182 | end, 183 | 184 | --- Due to repetition of overdue, this_week and next_week lines, 185 | --- we create a function that can repeatedly generate the buffer lines. 186 | --- @param task table 187 | --- @param curr_time integer 188 | --- @return table 189 | format_task_line = function(task, curr_time) 190 | local time_str = "" 191 | if task.deadline then 192 | -- Define the task deadline time 193 | local task_time = os.time({ 194 | year = tonumber(task.deadline.year) or 2024, 195 | month = tonumber(task.deadline.month) or 8, 196 | day = tonumber(task.deadline.day) or 12, 197 | }) 198 | 199 | -- Flag to check if the task deadline is today 200 | local is_today = (task.deadline.year - tonumber(os.date("%Y")) == 0) 201 | and (task.deadline.month - tonumber(os.date("%m")) == 0) 202 | and (task.deadline.day - tonumber(os.date("%d")) == 0) 203 | 204 | local years_diff = 0 205 | local months_diff = 0 206 | local days_diff = 0 207 | 208 | if is_today then 209 | time_str = "*" 210 | .. "{:" 211 | .. task.filename 212 | .. ":" 213 | .. string.gsub(task.task, "%b()", "") 214 | .. "}[" 215 | .. task.deadline.hour 216 | .. ":" 217 | .. task.deadline.minute 218 | .. "]*" 219 | else 220 | -- Calculate differences 221 | if task_time > curr_time then 222 | years_diff = os.date("*t", task_time).year - os.date("*t", curr_time).year 223 | months_diff = os.date("*t", task_time).month - os.date("*t", curr_time).month 224 | days_diff = os.date("*t", task_time).day - os.date("*t", curr_time).day 225 | else 226 | years_diff = os.date("*t", curr_time).year - os.date("*t", task_time).year 227 | months_diff = os.date("*t", curr_time).month - os.date("*t", task_time).month 228 | days_diff = os.date("*t", curr_time).day - os.date("*t", task_time).day + 1 -- Difference offset 229 | end 230 | 231 | -- Handle negative days 232 | if days_diff < 0 then 233 | months_diff = months_diff - 1 234 | local previous_month_time = os.time({ 235 | year = os.date("*t", task_time).year, 236 | month = os.date("*t", task_time).month - 1, 237 | day = 1, 238 | }) 239 | days_diff = days_diff 240 | + os.date( 241 | "*t", 242 | os.time({ 243 | year = os.date("*t", previous_month_time).year, 244 | month = os.date("*t", previous_month_time).month, 245 | day = 0, 246 | }) 247 | ).day 248 | end 249 | 250 | -- Handle negative months 251 | if months_diff < 0 then 252 | years_diff = years_diff - 1 253 | months_diff = months_diff + 12 254 | end 255 | 256 | -- Create the time difference string 257 | time_str = "*{:" .. task.filename .. ":" .. string.gsub(task.task, "^(%*+)%s*%b()%s*", "%1 ") .. "}[" 258 | local time_diff_str = "" 259 | if years_diff > 0 then 260 | time_diff_str = time_diff_str .. years_diff .. "y" 261 | end 262 | if months_diff > 0 then 263 | time_diff_str = time_diff_str .. months_diff .. "m" 264 | end 265 | if days_diff > 0 then 266 | time_diff_str = time_diff_str .. days_diff .. "d" 267 | end 268 | local text_padding = 9 - #time_diff_str 269 | 270 | -- Pad the time string to align 271 | time_str = time_str .. time_diff_str .. "]*" .. string.rep(" ", text_padding) 272 | end 273 | else 274 | time_str = "*{:" .. task.filename .. ":" .. string.gsub(task.task, "%b()", "") .. "}[unscheduled]*" 275 | end 276 | 277 | local task_state_str = "\\[" .. task.state .. "\\] " .. (task.task):match("%)%s*(.+)") 278 | 279 | local priority_str = " " 280 | if task.priority ~= "" and task.priority ~= nil then 281 | priority_str = priority_str .. "*" .. task.priority .. "*" 282 | else 283 | priority_str = priority_str .. " " 284 | end 285 | priority_str = priority_str .. " " 286 | 287 | local line_str = " " .. time_str 288 | line_str = line_str .. " ::" .. priority_str 289 | line_str = line_str .. ":: " .. task_state_str 290 | 291 | return line_str 292 | end, 293 | 294 | --- Adds the header and trailing line breaks to encapsulate the task lines 295 | --- @param buf_lines table 296 | --- @param header string 297 | --- @param tasks table 298 | --- @param curr_time integer 299 | insert_task_lines = function(buf_lines, header, tasks, curr_time) 300 | table.insert(buf_lines, "** " .. header) 301 | for _, task in ipairs(tasks) do 302 | table.insert(buf_lines, module.private.format_task_line(task, curr_time)) 303 | end 304 | table.insert(buf_lines, "") 305 | table.insert(buf_lines, "") 306 | end, 307 | } 308 | 309 | module.public = { 310 | --- Generate agenda from Neorg files 311 | ---@param input_list table 312 | page_view = function(input_list) 313 | local task_list = module.required["external.many-mans"]["task-man"].filter_tasks(input_list) 314 | 315 | -- Create and display agenda buffer 316 | local buffer_lines = {} 317 | local current_file = nil 318 | 319 | local year = tonumber(os.date("%Y")) 320 | local month = tonumber(os.date("%m")) 321 | local day = tonumber(os.date("%d")) 322 | 323 | local timetable = { 324 | year = year, 325 | month = month, 326 | day = day, 327 | hour = 0, 328 | min = 0, 329 | sec = 0, 330 | } 331 | 332 | -- Get the current weekday and adjust it to treat Monday as the start of the week 333 | local current_weekday = tonumber(os.date("%w", os.time(timetable))) 334 | current_weekday = (current_weekday == 0) and 7 or current_weekday -- Adjust Sunday (0) to be the last day of the week (7) 335 | 336 | table.insert(buffer_lines, "") 337 | table.insert(buffer_lines, "") 338 | table.insert(buffer_lines, "___") 339 | table.insert(buffer_lines, "* Today's Schedule") 340 | table.insert( 341 | buffer_lines, 342 | " " 343 | .. os.date("%A", os.time(timetable)) 344 | .. " == " 345 | .. year 346 | .. "-" 347 | .. month 348 | .. "-" 349 | .. day 350 | .. " == wk" 351 | .. os.date("%U", os.time(timetable)) 352 | ) 353 | table.insert(buffer_lines, "___") 354 | table.insert(buffer_lines, "") 355 | table.insert(buffer_lines, "") 356 | -- Format and insert tasks into the buffer 357 | for _, entry in ipairs(task_list) do 358 | if current_file ~= entry.filename then 359 | if current_file then 360 | table.insert(buffer_lines, "") 361 | end 362 | local file_metadata = 363 | module.required["external.many-mans"]["meta-man"].extract_file_metadata(entry.filename) 364 | -- table.insert(buffer_lines, "___") 365 | table.insert(buffer_lines, "") 366 | if file_metadata then 367 | table.insert(buffer_lines, "{:" .. entry.filename .. ":}[" .. file_metadata.title .. "]") 368 | else 369 | table.insert(buffer_lines, "{:" .. entry.filename .. ":}") 370 | end 371 | current_file = entry.filename 372 | end 373 | table.insert(buffer_lines, entry.task) 374 | end 375 | table.insert(buffer_lines, "") 376 | -- table.insert(buffer_lines, "___") 377 | 378 | -- Write formatted lines to the buffer 379 | local _, _ = module.required["external.many-mans"]["buff-man"].create_view_buffer(buffer_lines) 380 | end, 381 | 382 | --- Generate the Agenda Day View 383 | day_view = function() 384 | local year = tonumber(os.date("%Y")) 385 | local month = tonumber(os.date("%m")) 386 | local day = tonumber(os.date("%d")) 387 | 388 | local timetable = { 389 | year = year, 390 | month = month, 391 | day = day, 392 | hour = 0, 393 | min = 0, 394 | sec = 0, 395 | } 396 | 397 | -- Get the current weekday and adjust it to treat Monday as the start of the week 398 | local current_weekday = tonumber(os.date("%w", os.time(timetable))) 399 | current_weekday = (current_weekday == 0) and 7 or current_weekday -- Adjust Sunday (0) to be the last day of the week (7) 400 | 401 | -- Calculate the start of the week (Monday) 402 | local start_of_week_timestamp = os.time(timetable) - ((current_weekday - 1) * 24 * 60 * 60) 403 | local end_of_week_timestamp = start_of_week_timestamp + (6 * 24 * 60 * 60) -- End of the week (Sunday) 404 | 405 | -- Calculate the end of next week (Sunday of the next week) 406 | local end_of_next_week_timestamp = end_of_week_timestamp + (7 * 24 * 60 * 60) 407 | 408 | local current_time = os.time() 409 | 410 | local buffer_lines = {} 411 | table.insert(buffer_lines, "") 412 | table.insert(buffer_lines, "") 413 | table.insert(buffer_lines, "___") 414 | table.insert(buffer_lines, "* Today's Schedule") 415 | table.insert( 416 | buffer_lines, 417 | " " 418 | .. os.date("%A", os.time(timetable)) 419 | .. " == " 420 | .. year 421 | .. "-" 422 | .. month 423 | .. "-" 424 | .. day 425 | .. " == wk" 426 | .. os.date("%U", os.time(timetable)) + 1 427 | ) 428 | table.insert(buffer_lines, "___") 429 | table.insert(buffer_lines, "") 430 | table.insert(buffer_lines, "") 431 | 432 | local workspace = module.required["core.dirman"].get_workspace(module.config.public.workspace) 433 | local base_directory 434 | if workspace ~= nil then 435 | base_directory = workspace:tostring() 436 | end 437 | local task_list = module.required["external.many-mans"]["task-man"].filter_tasks({ 438 | "undone", 439 | "pending", 440 | "hold", 441 | "important", 442 | "ambiguous", 443 | }, base_directory) 444 | 445 | local today = {} 446 | local overdue = {} 447 | local this_week = {} 448 | local next_week = {} 449 | local scheduled = {} 450 | local miscellaneous = {} 451 | 452 | -- Categorize and sort tasks 453 | for _, task in ipairs(task_list) do 454 | if 455 | task.deadline 456 | and tonumber(task.deadline.year) 457 | and tonumber(task.deadline.month) 458 | and tonumber(task.deadline.day) 459 | then 460 | local task_time = os.time({ 461 | year = tonumber(task.deadline.year) or 2024, 462 | month = tonumber(task.deadline.month) or 8, 463 | day = tonumber(task.deadline.day) or 12, 464 | hour = 0, 465 | min = 0, 466 | sec = 0, 467 | }) 468 | 469 | if task_time < current_time then 470 | if 471 | tonumber(task.deadline.day) == day 472 | and tonumber(task.deadline.month) == month 473 | and tonumber(task.deadline.year) == year 474 | then 475 | table.insert(today, task) 476 | else 477 | table.insert(overdue, task) 478 | end 479 | elseif task_time <= end_of_week_timestamp then 480 | table.insert(this_week, task) 481 | elseif task_time <= end_of_next_week_timestamp then 482 | table.insert(next_week, task) 483 | elseif task_time > end_of_next_week_timestamp then 484 | table.insert(scheduled, task) 485 | else 486 | table.insert(miscellaneous, task) 487 | end 488 | else 489 | table.insert(miscellaneous, task) 490 | end 491 | end 492 | 493 | -- Sort each category 494 | table.sort(today, module.private.sort_today_tasks) 495 | table.sort(overdue, module.private.sort_by_time_and_priority) 496 | table.sort(scheduled, module.private.sort_by_time_and_priority) 497 | table.sort(next_week, module.private.sort_by_time_and_priority) 498 | table.sort(this_week, module.private.sort_by_time_and_priority) 499 | 500 | module.private.insert_task_lines(buffer_lines, "Today", today, current_time) 501 | module.private.insert_task_lines(buffer_lines, "Overdue", overdue, current_time) 502 | module.private.insert_task_lines(buffer_lines, "This Week", this_week, current_time) 503 | module.private.insert_task_lines(buffer_lines, "Next Week", next_week, current_time) 504 | module.private.insert_task_lines(buffer_lines, "Scheduled", scheduled, current_time) 505 | 506 | table.insert(buffer_lines, "** Miscellaneous") 507 | for _, task in ipairs(miscellaneous) do 508 | local unscheduled_str = "*" 509 | unscheduled_str = unscheduled_str 510 | .. "{:" 511 | .. task.filename 512 | .. ":" 513 | .. string.gsub(task.task, "%b()", "") 514 | .. "}[unscheduled]*" 515 | 516 | local task_str = "\\[" .. task.state .. "\\] " .. (task.task):match("%)%s*(.+)") 517 | local tags_str = "`untagged`" 518 | local priority_str = "*unprioritised*" 519 | local line_str = " " .. unscheduled_str 520 | line_str = line_str .. " :: " .. priority_str 521 | line_str = line_str .. " :: " .. task_str 522 | line_str = line_str .. " :: " .. tags_str 523 | table.insert(buffer_lines, line_str) 524 | end 525 | 526 | local _, _ = module.required["external.many-mans"]["buff-man"].create_view_buffer(buffer_lines) 527 | end, 528 | 529 | --- Generate Tag View 530 | tag_view = function() 531 | local year = tonumber(os.date("%Y")) 532 | local month = tonumber(os.date("%m")) 533 | local day = tonumber(os.date("%d")) 534 | 535 | local timetable = { 536 | year = year, 537 | month = month, 538 | day = day, 539 | hour = 0, 540 | min = 0, 541 | sec = 0, 542 | } 543 | 544 | -- Get the current weekday and adjust it to treat Monday as the start of the week 545 | local current_weekday = tonumber(os.date("%w", os.time(timetable))) 546 | current_weekday = (current_weekday == 0) and 7 or current_weekday -- Adjust Sunday (0) to be the last day of the week (7) 547 | 548 | local current_time = os.time() 549 | 550 | local buffer_lines = {} 551 | table.insert(buffer_lines, "") 552 | table.insert(buffer_lines, "") 553 | table.insert(buffer_lines, "___") 554 | table.insert(buffer_lines, "* Today's Schedule") 555 | table.insert( 556 | buffer_lines, 557 | " " 558 | .. os.date("%A", os.time(timetable)) 559 | .. " == " 560 | .. year 561 | .. "-" 562 | .. month 563 | .. "-" 564 | .. day 565 | .. " == wk" 566 | .. os.date("%U", os.time(timetable)) 567 | ) 568 | table.insert(buffer_lines, "___") 569 | table.insert(buffer_lines, "") 570 | table.insert(buffer_lines, "") 571 | 572 | local task_list = module.required["external.many-mans"]["task-man"].filter_tasks({ 573 | "undone", 574 | "pending", 575 | "hold", 576 | "important", 577 | "ambiguous", 578 | }) 579 | local tag_task_table = {} 580 | tag_task_table["untagged"] = {} 581 | for _, task in ipairs(task_list) do 582 | if task.tag then 583 | for _, tag in ipairs(task.tag) do 584 | if not tag_task_table[tag] then 585 | tag_task_table[tag] = {} 586 | end 587 | table.insert(tag_task_table[tag], task) 588 | end 589 | else 590 | table.insert(tag_task_table["untagged"], task) 591 | end 592 | end 593 | 594 | for key, tasks in pairs(tag_task_table) do 595 | module.private.insert_task_lines(buffer_lines, "`" .. key .. "`", tasks, current_time) 596 | end 597 | 598 | local _, _ = module.required["external.many-mans"]["buff-man"].create_view_buffer(buffer_lines) 599 | end, 600 | } 601 | 602 | module.on_event = function(event) 603 | -- vim.notify(vim.inspect(event)) 604 | if event.split_type[2] == "external.agenda.page" then 605 | module.public.page_view(event.content) 606 | elseif event.split_type[2] == "external.agenda.day" then 607 | module.public.day_view() 608 | elseif event.split_type[2] == "external.agenda.tag" then 609 | module.public.tag_view() 610 | end 611 | end 612 | 613 | return module 614 | -------------------------------------------------------------------------------- /lua/neorg/modules/external/many-mans/module.lua: -------------------------------------------------------------------------------- 1 | local neorg = require("neorg.core") 2 | local module = neorg.modules.create("external.many-mans") -- Wish death upon me 3 | -- Blood in my eye, dog, and I can't see 4 | -- I'm tryin' to be what I'm destined to be 5 | -- And neorg's tryin' to take my life away 6 | -- https://www.youtube.com/watch?v=5D3crqpClPY 7 | 8 | module.setup = function() 9 | return { 10 | success = true, 11 | requires = { 12 | "core.neorgcmd", 13 | "core.integrations.treesitter", 14 | "core.dirman", 15 | "core.qol.todo_items", 16 | "core.esupports.hop", 17 | "core.journal", 18 | }, 19 | } 20 | end 21 | 22 | module.config.public = { 23 | metadata_fold = true, 24 | code_fold = true, 25 | } 26 | 27 | module.load = function() 28 | module.required["core.neorgcmd"].add_commands_from_table({ 29 | ["update_property_metadata"] = { 30 | args = 0, 31 | name = "external.many-mans.meta-man.update_property_metadata", 32 | }, 33 | ["cycle_task"] = { 34 | args = 0, 35 | name = "external.many-mans.task-man.cycle_task", 36 | }, 37 | }) 38 | 39 | if module.config.public.metadata_fold or module.config.public.code_fold then 40 | module.public["meta-man"].setup_treesitter_folding() 41 | end 42 | end 43 | 44 | module.events.subscribed = { 45 | ["core.neorgcmd"] = { 46 | ["external.many-mans.meta-man.update_property_metadata"] = true, 47 | ["external.many-mans.task-man.cycle_task"] = true, 48 | }, 49 | } 50 | 51 | module.private = { 52 | get_heading_node_tree = function(bufnr) 53 | local parser = vim.treesitter.get_parser(bufnr, "norg") 54 | local tree = parser:parse()[1] 55 | 56 | -- Get the current cursor position 57 | local cursor_row, _ = unpack(vim.api.nvim_win_get_cursor(0)) 58 | cursor_row = cursor_row - 1 59 | 60 | -- Define the query for all heading levels 61 | local heading_query_string = [[ 62 | (heading6) @heading6 63 | (heading5) @heading5 64 | (heading4) @heading4 65 | (heading3) @heading3 66 | (heading2) @heading2 67 | (heading1) @heading1 68 | ]] 69 | 70 | -- Create the query object for headings 71 | local heading_query = vim.treesitter.query.parse("norg", heading_query_string) 72 | 73 | local node_tree = {} 74 | for _, node, _, _ in heading_query:iter_captures(tree:root(), bufnr, 0, -1) do 75 | local row1, _, row2, _ = node:range() 76 | if row1 <= cursor_row and row2 >= cursor_row then 77 | table.insert(node_tree, node) 78 | end 79 | end 80 | return node_tree 81 | end, 82 | 83 | -- Search for a pattern in the current buffer 84 | search_pattern = function(pattern) 85 | local lines = vim.api.nvim_buf_get_lines(0, 0, -1, true) 86 | for i, line in ipairs(lines) do 87 | if string.find(line, pattern) then 88 | return i 89 | end 90 | end 91 | return -1 92 | end, 93 | } 94 | 95 | module.public = { 96 | -- Helps know what to look for 97 | ["meta-man"] = { 98 | setup_treesitter_folding = function() 99 | local property_query = [[ 100 | (ranged_verbatim_tag 101 | name: (tag_name) @name (#eq? @name "data")) @fold 102 | ]] 103 | local code_query = [[ 104 | (ranged_verbatim_tag 105 | name: (tag_name) @name (#eq? @name "code")) @fold 106 | ]] 107 | local neorg_query = "" 108 | 109 | local neorg_folds_file = "" 110 | for _, rtp in ipairs(vim.fn.split(vim.opt.rtp["_value"], ",")) do 111 | neorg_folds_file = rtp .. "/queries/norg/folds.scm" 112 | if vim.fn.filereadable(neorg_folds_file) == 1 then 113 | neorg_query = table.concat(vim.fn.readfile(neorg_folds_file), "\n") 114 | end 115 | end 116 | if neorg_query ~= "" then 117 | local combined_query = neorg_query 118 | if module.config.public.metadata_fold then 119 | combined_query = combined_query .. "\n" .. property_query .. "\n" 120 | end 121 | if module.config.public.code_fold then 122 | combined_query = combined_query .. "\n" .. code_query .. "\n" 123 | end 124 | local _ = require("nvim-treesitter.parsers").get_parser_configs().norg 125 | vim.treesitter.query.set("norg", "folds", combined_query) 126 | else 127 | vim.notify("Failed to find Neorg Tree-sitter query file in runtimepath.", vim.log.levels.WARN) 128 | end 129 | end, 130 | 131 | is_present_property_metadata = function(bufnr) 132 | bufnr = bufnr or vim.api.nvim_get_current_buf() 133 | local parser = vim.treesitter.get_parser(bufnr, "norg") 134 | local tree = parser:parse()[1] 135 | 136 | -- Define the query for ranged_verbatim_tag 137 | local verbatim_query_string = [[ 138 | (ranged_verbatim_tag 139 | name: (tag_name) @tag_name 140 | (tag_parameters 141 | (tag_param) @tag_parameter)) 142 | ]] 143 | 144 | local verbatim_query = vim.treesitter.query.parse("norg", verbatim_query_string) 145 | 146 | local node_tree = module.private.get_heading_node_tree(bufnr) 147 | local is_ranged_verbatim = false 148 | local is_property = false 149 | local property_line = nil 150 | local heading_line = nil 151 | if #node_tree > 0 then 152 | heading_line, _, _, _ = node_tree[#node_tree]:range() 153 | heading_line = heading_line + 1 154 | end 155 | for child in node_tree[#node_tree]:iter_children() do 156 | local hrow1, _, _, _ = child:range() 157 | if child:type() == "ranged_verbatim_tag" then 158 | for _, node, _, _ in verbatim_query:iter_captures(tree:root(), bufnr, 0, -1) do 159 | local vrow1, _, _, _ = node:range() 160 | if hrow1 == vrow1 then 161 | local node_text = vim.treesitter.get_node_text(node, bufnr) 162 | if node_text == "data" then 163 | is_ranged_verbatim = true 164 | else 165 | is_property = true 166 | property_line = vrow1 + 1 167 | end 168 | end 169 | end 170 | end 171 | end 172 | if is_ranged_verbatim and is_property then 173 | return true, property_line, heading_line 174 | else 175 | return false, property_line, heading_line 176 | end 177 | end, 178 | 179 | -- Reads a specific line from a file 180 | read_line = function(file, line_number) 181 | local current_line = 0 182 | for line in file:lines() do 183 | current_line = current_line + 1 184 | if current_line == line_number then 185 | return line 186 | end 187 | end 188 | return nil 189 | end, 190 | 191 | encode_metadata_text = function(metadata_text) 192 | local task_value = {} 193 | if metadata_text then 194 | for _, entry in ipairs(metadata_text) do 195 | for line in string.gmatch(entry, "[^\r\n]+") do 196 | local key, value = line:match("^%s*([^:]+):%s*(.*)") 197 | if key == "started" or key == "completed" or key == "deadline" then 198 | local year, month, day, hour, minute = 199 | string.match(value, "(%d%d%d%d)%-(%d%d)%-(%d%d)|(%d%d):(%d%d)") 200 | task_value[key] = { 201 | year = year, 202 | month = month, 203 | day = day, 204 | hour = hour, 205 | minute = minute, 206 | } 207 | elseif key == "tag" then 208 | local tags = {} 209 | for tag in string.gmatch(value, "%s*(%w+)%s*") do 210 | table.insert(tags, tag) 211 | end 212 | task_value[key] = tags 213 | else 214 | task_value[key] = value 215 | end 216 | end 217 | end 218 | end 219 | return task_value 220 | end, 221 | 222 | -- Extracts agenda data from a file, starting from a specific line 223 | extract_property_metadata = function(filename, line_number) 224 | local file = io.open(filename, "r") 225 | if not file then 226 | vim.notify("Error opening file: " .. filename, vim.log.levels.ERROR) 227 | return nil 228 | end 229 | 230 | local next_line = module.public["meta-man"].read_line(file, line_number + 1) 231 | local agenda_lines = nil 232 | if next_line and string.match(next_line, "@data property") then 233 | agenda_lines = {} 234 | for line in file:lines() do 235 | if string.match(line, "@end") then 236 | break 237 | end 238 | table.insert(agenda_lines, line) 239 | end 240 | file:close() 241 | else 242 | file:close() 243 | end 244 | return module.public["meta-man"].encode_metadata_text(agenda_lines) 245 | end, 246 | 247 | push_new_property_metadata_string = function(row, props) 248 | local bufnr = vim.api.nvim_get_current_buf() 249 | local text = {} 250 | 251 | table.insert(text, "@data property") 252 | for key, value in pairs(props) do 253 | table.insert(text, key .. ": " .. value) 254 | end 255 | table.insert(text, "@end") 256 | 257 | local push_text = table.concat(text, "\n") 258 | local lines = vim.split(push_text, "\n") 259 | vim.api.nvim_buf_set_lines(bufnr, row, row, false, lines) 260 | vim.api.nvim_buf_call(bufnr, function() 261 | vim.cmd(string.format("%d,%dnormal! ==", row + 1, row + #lines)) 262 | end) 263 | end, 264 | 265 | delete_property_metadata = function(row, bufnr) 266 | local total_lines = vim.api.nvim_buf_line_count(bufnr) 267 | 268 | for i = row, total_lines do 269 | local line = vim.api.nvim_buf_get_lines(bufnr, i - 1, i, false)[1] 270 | if line:match("@end") then 271 | vim.api.nvim_buf_set_lines(bufnr, row, i, false, {}) 272 | break 273 | end 274 | end 275 | end, 276 | 277 | fetch_updated_property_metadata = function(prop_table) 278 | local fields = { started = false, completed = false, deadline = false, tag = false, priority = false } 279 | if prop_table ~= nil then 280 | for key, value in pairs(prop_table) do 281 | -- Mark field as true if value is nil 282 | if value == nil then 283 | fields[key] = true 284 | goto continue 285 | end 286 | -- Mark field as true if value is an empty table 287 | if type(value) == "table" and next(value) == nil then 288 | fields[key] = true 289 | goto continue 290 | end 291 | -- Mark field as true if value is an empty string 292 | if value == "" then 293 | fields[key] = true 294 | end 295 | ::continue:: 296 | end 297 | 298 | local prop_string = {} 299 | for key, value in pairs(fields) do 300 | if key == "started" or key == "deadline" or key == "completed" then 301 | if value or not prop_table[key] then 302 | vim.ui.input( 303 | { prompt = "Enter " .. key .. " date-time (YYYY-MM-DD|HH:MM): " }, 304 | function(input) 305 | if input ~= "" then 306 | prop_string[key] = input 307 | end 308 | end 309 | ) 310 | else 311 | local text = prop_table[key].year 312 | .. "-" 313 | .. prop_table[key].month 314 | .. "-" 315 | .. prop_table[key].day 316 | .. "|" 317 | .. prop_table[key].hour 318 | .. ":" 319 | .. prop_table[key].minute 320 | vim.ui.input( 321 | { prompt = "Enter " .. key .. " date-time (YYYY-MM-DD|HH:MM): ", default = text }, 322 | function(input) 323 | if input ~= "" then 324 | prop_string[key] = input 325 | end 326 | end 327 | ) 328 | end 329 | elseif key == "tag" then 330 | if value or not prop_table[key] then 331 | vim.ui.input({ prompt = "Enter comma-separated tags (tag1, tag2, ...): " }, function(input) 332 | if input ~= "" then 333 | prop_string[key] = input 334 | end 335 | end) 336 | else 337 | local tags = table.concat(prop_table[key], ", ") 338 | vim.ui.input( 339 | { prompt = "Enter comma-separated tags (tag1, tag2, ...): ", default = tags }, 340 | function(input) 341 | if input ~= "" then 342 | prop_string[key] = input 343 | end 344 | end 345 | ) 346 | end 347 | else 348 | if value or not prop_table[key] then 349 | vim.ui.input({ prompt = "Enter priority (A/B/C/...): " }, function(input) 350 | if input ~= "" then 351 | prop_string[key] = input 352 | end 353 | end) 354 | else 355 | vim.ui.input( 356 | { prompt = "Enter priority (A/B/C/...): ", default = prop_table[key] }, 357 | function(input) 358 | if input ~= "" then 359 | prop_string[key] = input 360 | end 361 | end 362 | ) 363 | end 364 | end 365 | end 366 | return prop_string 367 | end 368 | return {} 369 | end, 370 | 371 | generate_property_metadata = function() 372 | local prop_table = {} 373 | local started = vim.fn.input("Enter started date-time (YYYY-MM-DD|HH:MM): ") 374 | local deadline = vim.fn.input("Enter deadline date-time (YYYY-MM-DD|HH:MM): ") 375 | local completed = vim.fn.input("Enter completed date-time (YYYY-MM-DD|HH:MM): ") 376 | local tag = vim.fn.input("Enter comma-separated tags (tag1, tag2, ...): ") 377 | local priority = vim.fn.input("Enter priority (A/B/C/...): ") 378 | 379 | if started ~= "" then 380 | prop_table["started"] = started 381 | end 382 | if deadline ~= "" then 383 | prop_table["deadline"] = deadline 384 | end 385 | if completed ~= "" then 386 | prop_table["completed"] = completed 387 | end 388 | if tag ~= "" then 389 | prop_table["tag"] = tag 390 | end 391 | if priority ~= "" then 392 | prop_table["priority"] = priority 393 | end 394 | 395 | return prop_table 396 | end, 397 | 398 | update_property_metadata = function(inject_custom) 399 | local bufnr = vim.api.nvim_get_current_buf() 400 | local cursor_pos = vim.api.nvim_win_get_cursor(0) 401 | local full_path = vim.api.nvim_buf_get_name(0) 402 | -- Create a new floating window with the same buffer 403 | local opts = { 404 | relative = "cursor", 405 | width = 1, 406 | height = 1, 407 | row = 1, 408 | col = 0, 409 | style = "minimal", 410 | focusable = false, 411 | } 412 | local win = vim.api.nvim_open_win(bufnr, true, opts) 413 | vim.api.nvim_win_set_cursor(win, { cursor_pos[1], 0 }) 414 | 415 | -- Check if there is property metadata 416 | local value, property_line, heading_line = module.public["meta-man"].is_present_property_metadata(bufnr) 417 | 418 | vim.api.nvim_win_close(win, true) 419 | vim.api.nvim_win_set_cursor(0, cursor_pos) 420 | if value then 421 | local prop_table = module.public["meta-man"].extract_property_metadata(full_path, heading_line) 422 | if inject_custom and type(inject_custom) == "table" then 423 | for key, custom_value in pairs(inject_custom) do 424 | prop_table[key] = custom_value 425 | end 426 | end 427 | local prop_string = module.public["meta-man"].fetch_updated_property_metadata(prop_table) 428 | module.public["meta-man"].delete_property_metadata(heading_line, bufnr) 429 | module.public["meta-man"].push_new_property_metadata_string(heading_line, prop_string) 430 | else 431 | local prop_table = module.public["meta-man"].generate_property_metadata() 432 | module.public["meta-man"].push_new_property_metadata_string(heading_line, prop_table) 433 | end 434 | end, 435 | 436 | -- Function to extract metadata from a Neorg file. 437 | -- This function reads the entire content of a Neorg file and attempts to extract 438 | -- the metadata block defined between "@document.meta" and "@end". If the metadata 439 | -- is found, it decodes the metadata into a table; otherwise, it returns nil. 440 | extract_file_metadata = function(norg_address) 441 | local file = io.open(norg_address, "r") 442 | if not file then 443 | print("Could not open file: " .. norg_address) 444 | return nil 445 | end 446 | 447 | local content = file:read("*all") 448 | file:close() 449 | 450 | -- Search for the metadata block within the file content 451 | local metadata_block = content:match("@document%.meta(.-)@end") 452 | if not metadata_block then 453 | print("No metadata found in file: " .. norg_address) 454 | return nil 455 | end 456 | 457 | local metadata = {} 458 | local in_categories = false 459 | local categories = {} 460 | 461 | -- Iterate through each line of the metadata block 462 | for line in metadata_block:gmatch("[^\r\n]+") do 463 | if in_categories then 464 | if line:match("%]") then 465 | in_categories = false 466 | metadata["categories"] = categories 467 | categories = {} 468 | else 469 | table.insert(categories, line:match("%s*(.-)%s*$")) 470 | end 471 | else 472 | local key, value = line:match("^%s*(%w+):%s*(.-)%s*$") 473 | if key and value then 474 | if key == "categories" then 475 | in_categories = true 476 | local initial_values = value:match("%[(.-)%]") 477 | if initial_values then 478 | for item in initial_values:gmatch("[^,%s]+") do 479 | table.insert(categories, item) 480 | end 481 | in_categories = false 482 | metadata["categories"] = categories 483 | categories = {} 484 | end 485 | else 486 | metadata[key] = value 487 | end 488 | end 489 | end 490 | end 491 | return metadata 492 | end, 493 | }, 494 | 495 | -- Gets stuff done 496 | ["task-man"] = { 497 | -- Define state mappings 498 | state_to_symbol_mapping = { 499 | done = "x", 500 | cancelled = "_", 501 | pending = "-", 502 | hold = "=", 503 | undone = " ", 504 | important = "!", 505 | recurring = "+", 506 | ambiguous = "?", 507 | }, 508 | 509 | symbol_to_icon_mapping = { 510 | ["x"] = "󰄬", 511 | ["_"] = "", 512 | ["-"] = "󰥔", 513 | ["="] = "", 514 | [" "] = "×", 515 | ["!"] = "⚠", 516 | ["+"] = "↺", 517 | ["?"] = "", 518 | }, 519 | 520 | -- Define the possible task states and their transitions 521 | task_transitions = { 522 | undone = { 523 | "cancelled", 524 | "pending", 525 | "ambiguous", 526 | "important", 527 | "recurring", 528 | }, 529 | pending = { 530 | "done", 531 | "cancelled", 532 | "on-hold", 533 | }, 534 | hold = { 535 | "pending", 536 | }, 537 | ambiguous = { 538 | "cancelled", 539 | "pending", 540 | }, 541 | important = { 542 | "cancelled", 543 | "pending", 544 | }, 545 | recurring = { 546 | "done", 547 | "cancelled", 548 | }, 549 | cancelled = {}, 550 | done = {}, 551 | }, 552 | 553 | blacklist_states = function(input_list) 554 | local filtered_state_icons = {} 555 | for state, symbol in pairs(module.public["task-man"].state_to_symbol_mapping) do 556 | if not vim.tbl_contains(input_list, state) then 557 | filtered_state_icons[symbol] = module.public["task-man"].symbol_to_icon_mapping[symbol] 558 | end 559 | end 560 | return filtered_state_icons 561 | end, 562 | 563 | find_tasks_in_workspace = function(base_directory) 564 | local rg_command = [[rg '^\*{1,8} \(\s*(-?)\s*x*\?*!*_*\+*=*\)' --glob '*.norg' --line-number ]] 565 | .. base_directory 566 | return vim.fn.systemlist(rg_command) 567 | end, 568 | 569 | parse_task_line = function(line) 570 | local file, lnum, text = line:match("([^:]+):(%d+):(.*)") 571 | local task_state = text:match("%((.)%)") 572 | return file, tonumber(lnum), text, task_state 573 | end, 574 | 575 | add_agenda_data = function(task) 576 | local agenda_data = module.public["meta-man"].extract_property_metadata(task.filename, task.lnum) 577 | if agenda_data then 578 | for key, value in pairs(agenda_data) do 579 | task[key] = value 580 | end 581 | end 582 | return task 583 | end, 584 | 585 | filter_tasks = function(input_list, base_directory) 586 | local blacklisted_state_icons = module.public["task-man"].blacklist_states(input_list) 587 | if base_directory == nil then 588 | base_directory = module.required["core.dirman"].get_current_workspace()[2] 589 | end 590 | local lines = module.public["task-man"].find_tasks_in_workspace(base_directory) 591 | 592 | -- Filter and map tasks 593 | local task_list = {} 594 | for _, line in ipairs(lines) do 595 | local file, lnum, text, task_state_symbol = module.public["task-man"].parse_task_line(line) 596 | if not blacklisted_state_icons[task_state_symbol] and file and lnum and text then 597 | local task = { 598 | state = module.public["task-man"].symbol_to_icon_mapping[task_state_symbol], 599 | filename = file, 600 | lnum = lnum, 601 | task = text, 602 | } 603 | table.insert(task_list, module.public["task-man"].add_agenda_data(task)) 604 | end 605 | end 606 | 607 | return task_list 608 | end, 609 | 610 | --- Get the state of the current task 611 | get_task_state = function(bufnr) 612 | bufnr = bufnr or vim.api.nvim_get_current_buf() 613 | local node_tree = module.private.get_heading_node_tree(bufnr) 614 | local curr_heading = nil 615 | if #node_tree > 0 then 616 | curr_heading = vim.treesitter.get_node_text(node_tree[#node_tree], bufnr) 617 | else 618 | vim.notify("Not under a heading", vim.log.levels.WARN) 619 | return nil, nil 620 | end 621 | -- Take out the state 622 | local state = curr_heading:match("%((.)") 623 | local task_row, _, _, _ = node_tree[#node_tree]:range() 624 | for key, value in pairs(module.public["task-man"].state_to_symbol_mapping) do 625 | if state == value then 626 | return key, task_row + 1 627 | end 628 | end 629 | return "none", task_row + 1 630 | end, 631 | 632 | --- A wrapper around task toggler 633 | --- Needs to handle task cycling in a more interactive way. 634 | --- get current -> offer options for next 635 | -- # Task Transitions 636 | -- undone -> cancelled 637 | -- undone -> pending -> done 638 | -- undone -> pending -> cancelled 639 | -- undone -> pending -> hold -> pending -> done 640 | -- undone -> pending -> hold -> pending -> cancelled 641 | -- 642 | -- undone -> ambiguous -> cancelled 643 | -- undone -> ambiguous -> pending -> done 644 | -- undone -> ambiguous -> pending -> cancelled 645 | -- undone -> ambiguous -> pending -> hold -> pending -> done 646 | -- undone -> ambiguous -> pending -> hold -> pending -> cancelled 647 | -- undone -> important -> cancelled 648 | -- undone -> important -> pending -> done 649 | -- undone -> important -> pending -> cancelled 650 | -- undone -> important -> pending -> hold -> pending -> done 651 | -- undone -> important -> pending -> hold -> pending -> cancelled 652 | -- 653 | -- undone -> recurring -> done 654 | -- undone -> recurring -> cancelled 655 | -- 656 | -- When creating task -> populate deadline 657 | -- When leaving undone -> populate started 658 | -- When entering cancelled or done -> populate completed 659 | cycle_task = function() 660 | local task_state, task_row = module.public["task-man"].get_task_state(vim.api.nvim_get_current_buf()) 661 | if not task_state or task_state == "done" or task_state == "cancelled" then 662 | return 663 | elseif task_state == "none" then 664 | module.required["core.qol.todo_items"]["task-undone"]() 665 | local prop_table = { deadline = "", tag = "", priority = "" } 666 | vim.ui.input({ prompt = "Enter deadline date-time (YYYY-MM-DD|HH:MM): " }, function(input) 667 | if input ~= "" then 668 | prop_table["deadline"] = input 669 | end 670 | end) 671 | vim.ui.input({ prompt = "Enter comma-separated tags (tag1, tag2, ...): " }, function(input) 672 | if input ~= "" then 673 | prop_table["tag"] = input 674 | end 675 | end) 676 | vim.ui.input({ prompt = "Enter priority (A/B/C/...): " }, function(input) 677 | if input ~= "" then 678 | prop_table["priority"] = input 679 | end 680 | end) 681 | module.public["meta-man"].push_new_property_metadata_string(task_row, prop_table) 682 | else 683 | local options = module.public["task-man"].task_transitions[task_state] 684 | local prompt = "Transition from '" .. task_state .. "' to ->\n" 685 | vim.ui.select(options, { prompt = prompt }, function(choice) 686 | if not choice then 687 | return 688 | end 689 | module.required["core.qol.todo_items"]["task-" .. choice]() 690 | local updated_prop_table = {} 691 | if task_state == "undone" then 692 | local started_date_time = os.date("*t") 693 | local datetime_table = { 694 | year = string.format("%04d", started_date_time.year), 695 | month = string.format("%02d", started_date_time.month), 696 | day = string.format("%02d", started_date_time.day), 697 | hour = string.format("%02d", started_date_time.hour), 698 | minute = string.format("%02d", started_date_time.min), 699 | } 700 | updated_prop_table["started"] = datetime_table 701 | end 702 | if choice == "cancelled" or choice == "done" then 703 | local completed_date_time = os.date("*t") 704 | local datetime_table = { 705 | year = string.format("%04d", completed_date_time.year), 706 | month = string.format("%02d", completed_date_time.month), 707 | day = string.format("%02d", completed_date_time.day), 708 | hour = string.format("%02d", completed_date_time.hour), 709 | minute = string.format("%02d", completed_date_time.min), 710 | } 711 | updated_prop_table["completed"] = datetime_table 712 | end 713 | module.public["meta-man"].update_property_metadata(updated_prop_table) 714 | end) 715 | end 716 | vim.cmd([[write!]]) 717 | end, 718 | }, 719 | 720 | -- Too stronk! 721 | ["buff-man"] = { 722 | buf = nil, 723 | win = nil, 724 | default_winopts = { 725 | { "wrap", nil }, 726 | { "conceallevel", nil }, 727 | { "number", nil }, 728 | { "relativenumber", nil }, 729 | }, 730 | 731 | --- Navigates to a specific task in a Neorg file and opens it at the correct line. 732 | --- Parses the current Neorg link under the cursor, finds the corresponding task 733 | --- in the target file using `ripgrep`, and opens the file at the task's line. 734 | open_to_target_task = function() 735 | -- Wrapping around the esupports.hop module to get the link 736 | local parsed_link = module.required["core.esupports.hop"].parse_link( 737 | module.required["core.esupports.hop"].extract_link_node(), 738 | vim.api.nvim_get_current_buf() 739 | ) 740 | if not parsed_link then 741 | return 742 | end 743 | 744 | -- Since its always going to be a task, we can rg with ') ' and filename 745 | -- to get file row 746 | if parsed_link.link_location_text then 747 | local search = "rg -n -o --no-filename --fixed-strings " 748 | .. "') " 749 | .. parsed_link.link_location_text 750 | .. "' " 751 | .. parsed_link.link_file_text 752 | .. " | cut -d: -f1" 753 | local row = tonumber(vim.fn.system(search):match("^%s*(.-)%s*$")) 754 | vim.cmd("bdelete!") 755 | vim.cmd("edit +" .. row .. " " .. parsed_link.link_file_text) 756 | else 757 | vim.cmd("bdelete!") 758 | vim.cmd("edit " .. parsed_link.link_file_text) 759 | end 760 | 761 | vim.api.nvim_buf_delete(module.public["buff-man"].buf, { force = true }) 762 | module.public["buff-man"].win = nil 763 | end, 764 | 765 | --- Navigates to a specific backlink in a Neorg file and opens it at the specified location. 766 | --- Parses the current Neorg link under the cursor, checks if it points to a specific line 767 | --- number or file. If line number specified, opens the file at that line; otherwise, opens the file normally. 768 | --- Additionally, restores buffer window options to default and cleans up the buffer state. 769 | open_to_target_backlink = function() 770 | -- Wrapping around the esupports.hop module to get the link 771 | local parsed_link = module.required["core.esupports.hop"].parse_link( 772 | module.required["core.esupports.hop"].extract_link_node(), 773 | vim.api.nvim_get_current_buf() 774 | ) 775 | if not parsed_link then 776 | return 777 | end 778 | 779 | for _, opt in ipairs(module.public["buff-man"].default_winopts) do 780 | vim.api.nvim_set_option_value(opt[1], opt[2], { win = module.public["buff-man"].win }) 781 | end 782 | 783 | vim.cmd("bdelete!") 784 | 785 | if parsed_link.link_type == "line_number" then 786 | vim.cmd("edit +" .. parsed_link.link_location_text .. " " .. parsed_link.link_file_text) 787 | else 788 | vim.cmd("edit " .. parsed_link.link_file_text) 789 | end 790 | end, 791 | 792 | write_capture_to_journal = function(capture_kind) 793 | local function format_capture_text(text) 794 | -- Convert to lowercase and capitalize the first letter 795 | local formatted_text = text:lower():gsub("^%l", string.upper) 796 | 797 | -- Replace underscores with spaces 798 | formatted_text = formatted_text:gsub("_", " ") 799 | 800 | -- Capitalize the first letter of each word 801 | formatted_text = formatted_text:gsub("(%w[%w]*)", function(word) 802 | return word:sub(1, 1):upper() .. word:sub(2) 803 | end) 804 | 805 | return formatted_text 806 | end 807 | 808 | -- Get the content of the buffer as a list of lines 809 | local lines = vim.api.nvim_buf_get_lines(vim.api.nvim_get_current_buf(), 0, -1, true) 810 | vim.cmd("q!") 811 | 812 | module.required["core.journal"].diary_today() 813 | -- require("neorg.modules.core.journal.module")["private"].diary_today() 814 | 815 | -- Process: 816 | -- - Search for heading under Capture Kind in current buffer 817 | -- -- If exists then paste the content in a level underneath it (after elevating) 818 | -- -- If it doesn't exist then paste content with a new heading. 819 | 820 | local capture_heading = format_capture_text(capture_kind) 821 | local position = module.private.search_pattern("* " .. capture_heading) 822 | vim.notify(tostring(position), vim.log.levels.INFO) 823 | 824 | local promoted_lines = {} 825 | -- Iterate over each line in the input table. 826 | for i, line in ipairs(lines) do 827 | promoted_lines[i] = line:gsub("^(%*+)", function(match) 828 | return match .. "*" 829 | end) 830 | end 831 | local heading_name = "" 832 | if position == -1 then 833 | heading_name = "* " .. capture_kind:gsub("^%l", string.upper) 834 | end 835 | table.insert(promoted_lines, 1, heading_name) 836 | local content = table.concat(promoted_lines, "\n") 837 | 838 | vim.api.nvim_buf_set_lines(vim.api.nvim_get_current_buf(), position, position, true, promoted_lines) 839 | vim.fn.setreg("n", content) 840 | end, 841 | 842 | --- Standard buffer to display agendas 843 | ---@param buffer_lines string[] 844 | ---@return integer buffer_number 845 | ---@return integer window_number 846 | create_view_buffer = function(buffer_lines) 847 | -- Populate the default_winopts table with current window options 848 | module.public["buff-man"].win = vim.api.nvim_get_current_win() 849 | module.public["buff-man"].buf = vim.api.nvim_get_current_buf() 850 | for _, opt in ipairs(module.public["buff-man"].default_winopts) do 851 | opt[2] = vim.api.nvim_get_option_value(opt[1], { win = module.public["buff-man"].win }) 852 | end 853 | 854 | vim.cmd("tabnew") 855 | module.public["buff-man"].buf = vim.api.nvim_get_current_buf() 856 | module.public["buff-man"].win = vim.api.nvim_get_current_win() 857 | vim.api.nvim_buf_set_lines(module.public["buff-man"].buf, 0, -1, false, buffer_lines) 858 | 859 | -- Set buffer options for display and interaction 860 | vim.api.nvim_set_option_value("filetype", "norg", { buf = module.public["buff-man"].buf }) 861 | vim.api.nvim_set_option_value("modifiable", false, { buf = module.public["buff-man"].buf }) 862 | vim.api.nvim_set_option_value("swapfile", false, { buf = module.public["buff-man"].buf }) 863 | vim.api.nvim_set_option_value("buftype", "nofile", { buf = module.public["buff-man"].buf }) 864 | vim.api.nvim_set_option_value("bufhidden", "delete", { buf = module.public["buff-man"].buf }) 865 | vim.api.nvim_set_option_value("readonly", true, { buf = module.public["buff-man"].buf }) 866 | vim.api.nvim_set_option_value("wrap", false, { win = module.public["buff-man"].win }) 867 | vim.api.nvim_set_option_value("conceallevel", 2, { win = module.public["buff-man"].win }) 868 | vim.api.nvim_set_option_value("number", false, { win = module.public["buff-man"].win }) 869 | vim.api.nvim_set_option_value("relativenumber", false, { win = module.public["buff-man"].win }) 870 | 871 | vim.api.nvim_buf_set_keymap(module.public["buff-man"].buf, "n", "", "", { 872 | noremap = true, 873 | silent = true, 874 | callback = module.public["buff-man"].open_to_target_task, 875 | }) 876 | vim.api.nvim_buf_set_keymap(module.public["buff-man"].buf, "n", "q", "", { 877 | noremap = true, 878 | silent = true, 879 | callback = function() 880 | -- Restore the original window options when closing 881 | for _, opt in ipairs(module.public["buff-man"].default_winopts) do 882 | vim.api.nvim_set_option_value(opt[1], opt[2], { win = module.public["buff-man"].win }) 883 | end 884 | vim.cmd("bdelete!") 885 | end, 886 | }) 887 | 888 | return module.public["buff-man"].buf, module.public["buff-man"].win 889 | end, 890 | 891 | --- Standard buffer to display backlinks 892 | ---@param buffer_lines string[] 893 | ---@return integer buffer_number 894 | ---@return integer window_number 895 | create_backlinks_buffer = function(buffer_lines) 896 | module.public["buff-man"].buf = vim.api.nvim_create_buf(true, true) 897 | 898 | vim.cmd("vsplit") 899 | 900 | -- Get the new window ID and set the buffer in the new split 901 | module.public["buff-man"].win = vim.api.nvim_get_current_win() 902 | vim.api.nvim_win_set_buf(module.public["buff-man"].win, module.public["buff-man"].buf) 903 | 904 | vim.api.nvim_buf_set_lines(module.public["buff-man"].buf, 0, -1, false, buffer_lines) 905 | 906 | -- Set buffer options for display and interaction 907 | vim.api.nvim_set_option_value("filetype", "norg", { buf = module.public["buff-man"].buf }) 908 | vim.api.nvim_set_option_value("modifiable", false, { buf = module.public["buff-man"].buf }) 909 | vim.api.nvim_set_option_value("swapfile", false, { buf = module.public["buff-man"].buf }) 910 | vim.api.nvim_set_option_value("buftype", "nofile", { buf = module.public["buff-man"].buf }) 911 | vim.api.nvim_set_option_value("bufhidden", "delete", { buf = module.public["buff-man"].buf }) 912 | vim.api.nvim_set_option_value("readonly", true, { buf = module.public["buff-man"].buf }) 913 | vim.api.nvim_set_option_value("wrap", false, { win = module.public["buff-man"].win }) 914 | vim.api.nvim_set_option_value("conceallevel", 2, { win = module.public["buff-man"].win }) 915 | vim.api.nvim_set_option_value("number", false, { win = module.public["buff-man"].win }) 916 | vim.api.nvim_set_option_value("relativenumber", false, { win = module.public["buff-man"].win }) 917 | 918 | vim.cmd("set foldlevel=1") 919 | -- Set keymaps for the buffer 920 | vim.api.nvim_buf_set_keymap(module.public["buff-man"].buf, "n", "", "", { 921 | noremap = true, 922 | silent = true, 923 | callback = module.public["buff-man"].open_to_target_backlink, 924 | }) 925 | vim.api.nvim_buf_set_keymap(module.public["buff-man"].buf, "n", "q", "", { 926 | noremap = true, 927 | silent = true, 928 | callback = function() 929 | -- Restore the original window options when closing 930 | if vim.api.nvim_win_is_valid(module.public["buff-man"].win) then 931 | for _, opt in ipairs(module.public["buff-man"].default_winopts) do 932 | vim.api.nvim_set_option_value(opt[1], opt[2], { win = module.public["buff-man"].win }) 933 | end 934 | end 935 | vim.api.nvim_buf_delete(module.public["buff-man"].buf, { force = true }) 936 | module.public["buff-man"].win = nil 937 | end, 938 | }) 939 | 940 | return module.public["buff-man"].buf, module.public["buff-man"].win 941 | end, 942 | 943 | --- Standard buffer for capture 944 | ---@param buffer_lines string[] 945 | ---@return integer buffer_number 946 | ---@return integer window_number 947 | create_capture_buffer = function(buffer_lines, split_kind, capture_kind) 948 | -- vim.api.nvim_command(split_kind) 949 | -- 950 | -- vim.cmd("edit /tmp/" .. capture_kind .. ".norg") 951 | vim.cmd(split_kind .. " /tmp/" .. capture_kind .. os.date("%H%M%S") .. ".norg") 952 | module.public["buff-man"].buf = vim.api.nvim_get_current_buf() 953 | module.public["buff-man"].win = vim.api.nvim_get_current_win() 954 | vim.api.nvim_win_set_buf(module.public["buff-man"].win, module.public["buff-man"].buf) 955 | vim.api.nvim_set_option_value("filetype", "norg", { buf = module.public["buff-man"].buf }) 956 | 957 | vim.api.nvim_buf_set_lines(module.public["buff-man"].buf, 0, -1, false, buffer_lines) 958 | 959 | -- Set keymaps for the buffer 960 | vim.api.nvim_buf_set_keymap(module.public["buff-man"].buf, "n", "", "", { 961 | noremap = true, 962 | silent = true, 963 | callback = module.public["buff-man"].open_to_target_backlink, 964 | }) 965 | vim.api.nvim_buf_set_keymap(module.public["buff-man"].buf, "n", "q", "", { 966 | noremap = true, 967 | silent = true, 968 | callback = function() 969 | -- Restore the original window options when closing 970 | if vim.api.nvim_win_is_valid(module.public["buff-man"].win) then 971 | for _, opt in ipairs(module.public["buff-man"].default_winopts) do 972 | vim.api.nvim_set_option_value(opt[1], opt[2], { win = module.public["buff-man"].win }) 973 | end 974 | end 975 | vim.api.nvim_buf_delete(module.public["buff-man"].buf, { force = true }) 976 | module.public["buff-man"].win = nil 977 | end, 978 | }) 979 | 980 | vim.api.nvim_buf_set_keymap(module.public["buff-man"].buf, "n", "", "", { 981 | noremap = true, 982 | silent = true, 983 | callback = function() 984 | module.public["buff-man"].write_capture_to_journal(capture_kind) 985 | end, 986 | }) 987 | return module.public["buff-man"].buf, module.public["buff-man"].win 988 | end, 989 | }, 990 | } 991 | 992 | module.on_event = function(event) 993 | -- vim.notify(vim.inspect(event)) 994 | if event.split_type[2] == "external.many-mans.meta-man.update_property_metadata" then 995 | module.public["meta-man"].update_property_metadata() 996 | elseif event.split_type[2] == "external.many-mans.task-man.cycle_task" then 997 | module.public["task-man"].cycle_task() 998 | end 999 | end 1000 | 1001 | return module 1002 | -------------------------------------------------------------------------------- /lua/neorg/modules/external/roam/module.lua: -------------------------------------------------------------------------------- 1 | local neorg = require("neorg.core") 2 | local module = neorg.modules.create("external.roam") 3 | 4 | module.setup = function() 5 | return { 6 | success = true, 7 | requires = { 8 | "core.neorgcmd", 9 | "core.dirman", 10 | "core.integrations.treesitter", 11 | "external.many-mans", 12 | }, 13 | } 14 | end 15 | 16 | module.config.public = { 17 | fuzzy_finder = "Telescope", -- or "Fzf" or "Snacks" 18 | fuzzy_backlinks = false, 19 | roam_base_directory = "", 20 | node_name_randomiser = false, 21 | node_name_snake_case = false, 22 | } 23 | 24 | module.load = function() 25 | module.required["core.neorgcmd"].add_commands_from_table({ 26 | ["roam"] = { 27 | args = 1, 28 | subcommands = { 29 | ["node"] = { 30 | min_args = 0, 31 | name = "external.roam.node", 32 | }, 33 | ["block"] = { 34 | args = 0, 35 | name = "external.roam.block", 36 | }, 37 | ["backlinks"] = { 38 | args = 0, 39 | name = "external.roam.backlinks", 40 | }, 41 | ["select_workspace"] = { 42 | args = 0, 43 | name = "external.roam.select_workspace", 44 | }, 45 | ["capture"] = { 46 | min_args = 1, 47 | max_args = 2, 48 | complete = { 49 | { 50 | "todo", 51 | "note", 52 | "meeting", 53 | "selection", 54 | }, 55 | }, 56 | name = "external.roam.capture", 57 | }, 58 | }, 59 | }, 60 | }) 61 | end 62 | 63 | module.events.subscribed = { 64 | ["core.neorgcmd"] = { 65 | ["external.roam.node"] = true, 66 | ["external.roam.block"] = true, 67 | ["external.roam.backlinks"] = true, 68 | ["external.roam.select_workspace"] = true, 69 | ["external.roam.capture"] = true, 70 | }, 71 | } 72 | 73 | module.private = { 74 | 75 | default_capture_templates = { 76 | ["todo"] = [[]], 77 | ["note"] = [[]], 78 | ["meeting"] = [[ 79 | * Meeting name 80 | 81 | ** Attendees 82 | 83 | ** Goal 84 | 85 | ** Agenda 86 | 87 | ** Minutes 88 | ]], 89 | ["selection"] = [[]], 90 | }, 91 | 92 | generate_default_capture_templates = function() 93 | local current_workspace = module.required["core.dirman"].get_current_workspace()[2] 94 | local dir_path = current_workspace .. "/.capture-templates" 95 | 96 | local ok, _, code = os.rename(dir_path, dir_path) 97 | if not ok and code == 2 then 98 | vim.fn.mkdir(current_workspace .. "/.capture-templates", "p") 99 | end 100 | 101 | for key, value in pairs(module.private.default_capture_templates) do 102 | local file_path = dir_path .. "/" .. key .. ".norg" 103 | 104 | local file = vim.fn.filereadable(file_path) 105 | if file ~= 1 then 106 | vim.cmd("edit " .. file_path) 107 | vim.api.nvim_buf_set_lines(0, 0, -1, false, vim.split(value, "\n")) 108 | vim.cmd("w") 109 | vim.cmd("bd") 110 | end 111 | end 112 | end, 113 | 114 | verify_default_capture_templates = function() 115 | local function key_exists(key, table_of_strings) 116 | for _, value in ipairs(table_of_strings) do 117 | if value == key then 118 | return true 119 | end 120 | end 121 | return false 122 | end 123 | 124 | local current_workspace = module.required["core.dirman"].get_current_workspace()[2] 125 | local dir_path = current_workspace .. "/.capture-templates" 126 | 127 | local ok, _, code = os.rename(dir_path, dir_path) 128 | if not ok and code == 2 then 129 | return false 130 | end 131 | 132 | local template_files = {} 133 | for name, type in vim.fs.dir(dir_path) do 134 | if type == "file" and name:match("%.norg$") then 135 | local base_name = name:gsub("%.norg$", "") 136 | table.insert(template_files, base_name) 137 | end 138 | end 139 | 140 | for key, _ in pairs(module.private.default_capture_templates) do 141 | if not key_exists(key, template_files) then 142 | return false 143 | end 144 | end 145 | 146 | return true 147 | end, 148 | 149 | get_fuzzy_finder_modules = function() 150 | if module.config.public.fuzzy_finder == "Telescope" then 151 | local success, _ = pcall(require, "telescope") 152 | if not success then 153 | return false 154 | end 155 | 156 | module.private.telescope_modules = { 157 | pickers = require("telescope.pickers"), 158 | finders = require("telescope.finders"), 159 | conf = require("telescope.config").values, -- Allows us to use the values from the user's config 160 | make_entry = require("telescope.make_entry"), 161 | actions = require("telescope.actions"), 162 | actions_set = require("telescope.actions.set"), 163 | state = require("telescope.actions.state"), 164 | } 165 | return true 166 | elseif module.config.public.fuzzy_finder == "Fzf" then 167 | local success, fzf_lua = pcall(require, "fzf-lua") 168 | if not success then 169 | return false 170 | end 171 | 172 | module.private.fzf_modules = { 173 | fzf_lua = fzf_lua, 174 | previewer = require("fzf-lua.previewer"), 175 | builtin_previewer = require("fzf-lua.previewer.builtin"), 176 | actions = require("fzf-lua.actions"), 177 | } 178 | return true 179 | elseif module.config.public.fuzzy_finder == "Snacks" then 180 | local success, snacks = pcall(require, "snacks") 181 | if not success then 182 | return false 183 | end 184 | 185 | module.private.snacks_modules = { 186 | snacks = snacks, 187 | picker = require("snacks.picker"), 188 | } 189 | return true 190 | else 191 | return false 192 | end 193 | end, 194 | 195 | ---@param filename string 196 | ---@param lineno number? 197 | ---@return string|nil 198 | get_heading_text = function(filename, lineno) 199 | local file = io.open(filename, "r") 200 | if not file then 201 | print("Cannot open file:", filename) 202 | return nil 203 | end 204 | 205 | local file_content = file:read("*all") 206 | file:close() 207 | 208 | local tree = vim.treesitter.get_string_parser(file_content, "norg"):parse()[1] 209 | local heading_query_string = [[ 210 | (heading1 211 | title: (paragraph_segment) @paragraph_segment 212 | ) @heading1 213 | 214 | (heading2 215 | title: (paragraph_segment) @paragraph_segment 216 | ) @heading2 217 | 218 | (heading3 219 | title: (paragraph_segment) @paragraph_segment 220 | ) @heading3 221 | 222 | (heading4 223 | title: (paragraph_segment) @paragraph_segment 224 | ) @heading4 225 | 226 | (heading5 227 | title: (paragraph_segment) @paragraph_segment 228 | ) @heading5 229 | 230 | (heading6 231 | title: (paragraph_segment) @paragraph_segment 232 | ) @heading6 233 | ]] 234 | 235 | local heading_query = vim.treesitter.query.parse("norg", heading_query_string) 236 | local target_line = lineno - 1 237 | for _, node, _, _ in heading_query:iter_captures(tree:root(), file_content, 0, -1) do 238 | local row1, _, row2, _ = node:range() 239 | if row1 < lineno and row2 >= target_line then 240 | for child in node:iter_children() do 241 | local crow1, _, crow2, _ = child:range() 242 | if child:type() == "paragraph_segment" and (crow1 < lineno and crow2 >= target_line) then 243 | return (vim.treesitter.get_node_text(child, file_content)) 244 | end 245 | end 246 | end 247 | end 248 | return nil 249 | end, 250 | } 251 | 252 | module.public = { 253 | -- Function to find and insert nodes from Neorg files. 254 | -- This function scans Neorg files in the current workspace and allows the user to either insert 255 | -- a selected node into the current buffer or create a new node. 256 | node = function() 257 | ---Tokenise the name of a node 258 | ---@param node_name string 259 | ---@return string 260 | local function name_tokeniser(node_name) 261 | local title_token = node_name:gsub("%W", ""):lower() 262 | local n = #title_token 263 | if n > 5 then 264 | local step = math.max(1, math.floor(n / 5)) 265 | local condensed = "" 266 | for i = 1, n, step do 267 | condensed = condensed .. title_token:sub(i, i) 268 | end 269 | title_token = condensed 270 | end 271 | return title_token 272 | end 273 | 274 | local fuzzy = module.private.get_fuzzy_finder_modules() 275 | if not fuzzy then 276 | vim.notify("No fuzzy finder present.", vim.log.levels.ERROR) 277 | return nil 278 | end 279 | 280 | local current_workspace = module.required["core.dirman"].get_current_workspace() 281 | local base_directory = current_workspace[2] 282 | 283 | if module.config.public.fuzzy_finder == "Telescope" then 284 | -- Find all .norg files in the workspace 285 | local norg_files_output = 286 | vim.fn.systemlist("fd -e norg --type f --base-directory '" .. base_directory .. "'") 287 | 288 | -- Extract titles and paths from the Neorg files 289 | local title_path_pairs = {} 290 | for _, line in pairs(norg_files_output) do 291 | local full_path = base_directory .. "/" .. line 292 | local metadata = module.required["external.many-mans"]["meta-man"].extract_file_metadata(full_path) 293 | if metadata ~= nil then 294 | table.insert(title_path_pairs, { metadata["title"], full_path }) 295 | else 296 | table.insert(title_path_pairs, { "Untitled", full_path }) 297 | end 298 | end 299 | 300 | local opts = {} 301 | opts.entry_maker = opts.entry_maker or module.private.telescope_modules.make_entry.gen_from_file(opts) 302 | 303 | -- Set up Telescope picker to display and select Neorg files 304 | module.private.telescope_modules.pickers 305 | .new(opts, { 306 | prompt_title = "Find Neorg Node", 307 | finder = module.private.telescope_modules.finders.new_table({ 308 | results = title_path_pairs, 309 | entry_maker = function(entry) 310 | return { 311 | value = entry[2], 312 | display = entry[1], 313 | ordinal = entry[1], 314 | } 315 | end, 316 | }), 317 | previewer = module.private.telescope_modules.conf.file_previewer(opts), 318 | sorter = module.private.telescope_modules.conf.file_sorter(opts), 319 | attach_mappings = function(prompt_bufnr, map) 320 | -- Map to insert the selected node into the current buffer 321 | map("i", "", function() 322 | local entry = module.private.telescope_modules.state.get_selected_entry() 323 | local current_file_path = entry.value 324 | local escaped_base_path = base_directory:gsub("([^%w])", "%%%1") 325 | local relative_path = current_file_path:match("^" .. escaped_base_path .. "/(.+)%..+") 326 | -- Insert at the cursor location 327 | module.private.telescope_modules.actions.close(prompt_bufnr) 328 | vim.api.nvim_put( 329 | { "{:$/" .. relative_path .. ":}[" .. entry.display .. "]" }, 330 | "", 331 | false, 332 | true 333 | ) 334 | end) 335 | 336 | -- Map to create a new node with the given title in the default note vault 337 | map("i", "", function() 338 | local prompt = module.private.telescope_modules.state.get_current_line() 339 | local title_token = prompt 340 | if module.config.public.node_name_randomiser then 341 | title_token = name_tokeniser(prompt) 342 | elseif module.config.public.node_name_snake_case then 343 | title_token = title_token:lower() 344 | title_token = title_token:gsub(" ", "_") 345 | end 346 | module.private.telescope_modules.actions.close(prompt_bufnr) 347 | 348 | -- Ensure the vault directory exists 349 | local vault_dir = base_directory 350 | .. ( 351 | module.config.public.roam_base_directory ~= "" 352 | and "/" .. module.config.public.roam_base_directory 353 | or "" 354 | ) 355 | vim.fn.mkdir(vault_dir, "p") 356 | 357 | -- Create and open a new Neorg file with the generated title token 358 | vim.cmd("edit " .. vault_dir .. os.date("%Y%m%d%H%M%S-") .. title_token .. ".norg") 359 | vim.cmd([[Neorg inject-metadata]]) 360 | 361 | -- Update the title in the newly created buffer 362 | local buf = vim.api.nvim_get_current_buf() 363 | local lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false) 364 | for i, line in ipairs(lines) do 365 | if line:match("^title:") then 366 | lines[i] = "title: " .. prompt 367 | break 368 | end 369 | end 370 | vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines) 371 | end) 372 | return true 373 | end, 374 | }) 375 | :find() 376 | elseif module.config.public.fuzzy_finder == "Fzf" then 377 | local titles = {} 378 | local title_path_dict = {} 379 | 380 | local norg_files_output = 381 | vim.fn.systemlist("fd -e norg --type f --base-directory '" .. base_directory .. "'") 382 | 383 | -- Extract titles and paths from the Neorg files 384 | for _, line in pairs(norg_files_output) do 385 | local full_path = base_directory .. "/" .. line 386 | local metadata = module.required["external.many-mans"]["meta-man"].extract_file_metadata(full_path) 387 | if metadata ~= nil then 388 | table.insert(titles, metadata["title"]) 389 | title_path_dict[metadata["title"]] = full_path 390 | else 391 | table.insert(titles, full_path) 392 | title_path_dict[full_path] = full_path 393 | end 394 | end 395 | 396 | local NodePreview = module.private.fzf_modules.builtin_previewer.buffer_or_file:extend() 397 | 398 | function NodePreview:new(o, opts, fzf_win) 399 | NodePreview.super.new(self, o, opts, fzf_win) 400 | setmetatable(self, NodePreview) 401 | return self 402 | end 403 | 404 | function NodePreview:parse_entry(entry_str) 405 | return { 406 | path = title_path_dict[entry_str] == nil and entry_str or title_path_dict[entry_str], 407 | line = 1, 408 | col = 1, 409 | } 410 | end 411 | 412 | module.private.fzf_modules.fzf_lua.fzf_exec(titles, { 413 | previewer = NodePreview, 414 | prompt = "Find Neorg Node> ", 415 | actions = { 416 | ["default"] = { 417 | function(selected, _) 418 | vim.cmd("q") 419 | vim.cmd("edit " .. title_path_dict[selected[1]]) 420 | end, 421 | }, 422 | ["ctrl-i"] = { 423 | function(selected, _) 424 | local current_file_path = title_path_dict[selected[1]] 425 | local escaped_base_path = base_directory:gsub("([^%w])", "%%%1") 426 | local relative_path = current_file_path:match("^" .. escaped_base_path .. "/(.+)%..+") 427 | -- Insert after the cursor location 428 | vim.cmd("q") 429 | vim.api.nvim_put({ "{:$/" .. relative_path .. ":}[" .. selected[1] .. "]" }, "", true, true) 430 | end, 431 | }, 432 | ["ctrl-n"] = { 433 | function(_, opt) 434 | -- Input query is in opt.__call_opts.query 435 | local prompt = opt.__call_opts.query 436 | local title_token = prompt 437 | if module.config.public.node_name_randomiser then 438 | title_token = name_tokeniser(prompt) 439 | elseif module.config.public.node_name_snake_case then 440 | title_token = title_token:lower() 441 | title_token = title_token:gsub(" ", "_") 442 | end 443 | 444 | -- Ensure the vault directory exists 445 | local vault_dir = base_directory 446 | .. ( 447 | module.config.public.roam_base_directory ~= "" 448 | and "/" .. module.config.public.roam_base_directory 449 | or "" 450 | ) 451 | vim.fn.mkdir(vault_dir, "p") 452 | 453 | -- Create and open a new Neorg file with the generated title token 454 | vim.cmd("q") 455 | vim.cmd("edit " .. vault_dir .. "/" .. os.date("%Y%m%d%H%M%S-") .. title_token .. ".norg") 456 | vim.cmd([[Neorg inject-metadata]]) 457 | 458 | -- Update the title in the newly created buffer 459 | local buf = vim.api.nvim_get_current_buf() 460 | local lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false) 461 | for i, line in ipairs(lines) do 462 | if line:match("^title:") then 463 | lines[i] = "title: " .. prompt 464 | break 465 | end 466 | end 467 | vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines) 468 | end, 469 | }, 470 | }, 471 | }) 472 | elseif module.config.public.fuzzy_finder == "Snacks" then 473 | local get_nodes = function() 474 | local norg_files_output = 475 | vim.fn.systemlist("fd -e norg --type f --base-directory '" .. base_directory .. "'") 476 | local items = {} 477 | for _, line in pairs(norg_files_output) do 478 | local full_path = base_directory .. "/" .. line 479 | local metadata = module.required["external.many-mans"]["meta-man"].extract_file_metadata(full_path) 480 | if metadata ~= nil then 481 | table.insert( 482 | items, 483 | { text = metadata["title"], file = full_path, preview = { text = full_path } } 484 | ) 485 | else 486 | table.insert(items, { text = full_path, file = full_path, preview = { text = full_path } }) 487 | end 488 | end 489 | return items 490 | end 491 | 492 | module.private.snacks_modules.picker.pick({ 493 | source = "neorg_nodes", 494 | items = get_nodes(), 495 | format = "text", 496 | confirm = function(picker, item) 497 | picker:close() 498 | vim.cmd("edit " .. item.file) 499 | end, 500 | actions = { 501 | insert_node_at_cursor = function(picker, item) 502 | picker:close() 503 | local current_file_path = item.file 504 | local escaped_base_path = base_directory:gsub("([^%w])", "%%%1") 505 | local relative_path = current_file_path:match("^" .. escaped_base_path .. "/(.+)%..+") 506 | vim.api.nvim_put({ "{:$/" .. relative_path .. ":}[" .. item.text .. "]" }, "", true, true) 507 | end, 508 | new_node = function(picker, item) 509 | local prompt = picker.finder.filter.pattern 510 | picker:close() 511 | local title_token = prompt 512 | if module.config.public.node_name_randomiser then 513 | title_token = name_tokeniser(prompt) 514 | elseif module.config.public.node_name_snake_case then 515 | title_token = title_token:lower() 516 | title_token = title_token:gsub(" ", "_") 517 | end 518 | 519 | -- Ensure the vault directory exists 520 | local vault_dir = base_directory 521 | .. ( 522 | module.config.public.roam_base_directory ~= "" 523 | and "/" .. module.config.public.roam_base_directory 524 | or "" 525 | ) 526 | vim.fn.mkdir(vault_dir, "p") 527 | 528 | -- Create and open a new Neorg file with the generated title token 529 | vim.cmd("edit " .. vault_dir .. "/" .. os.date("%Y%m%d%H%M%S-") .. title_token .. ".norg") 530 | vim.cmd([[Neorg inject-metadata]]) 531 | 532 | -- Update the title in the newly created buffer 533 | local buf = vim.api.nvim_get_current_buf() 534 | local lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false) 535 | for i, line in ipairs(lines) do 536 | if line:match("^title:") then 537 | lines[i] = "title: " .. prompt 538 | break 539 | end 540 | end 541 | vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines) 542 | end, 543 | }, 544 | win = { 545 | input = { 546 | keys = { 547 | [""] = { 548 | "insert_node_at_cursor", 549 | mode = { "n", "i" }, 550 | desc = "Insert Node Reference at Cursor", 551 | }, 552 | [""] = { "new_node", mode = { "n", "i" }, desc = "Create New Node" }, 553 | }, 554 | }, 555 | }, 556 | }) 557 | end 558 | end, 559 | 560 | -- Function to find and insert blocks from Neorg files. 561 | -- This function searches for task blocks within Neorg files and allows the user to insert 562 | -- the selected block into the current buffer. 563 | block = function() 564 | local fuzzy = module.private.get_fuzzy_finder_modules() 565 | if not fuzzy then 566 | vim.notify("No fuzzy finder present.", vim.log.levels.ERROR) 567 | return nil 568 | end 569 | 570 | local current_workspace = module.required["core.dirman"].get_current_workspace() 571 | local base_directory = current_workspace[2] 572 | 573 | -- Define search pattern for different levels of task blocks 574 | local search_path = [["^\* |^\*\* |^\*\*\* |^\*\*\*\* |^\*\*\*\*\* |^\*\*\*\*\*\* "]] 575 | 576 | -- Run ripgrep to find matching lines in .norg files 577 | local rg_command = "rg " 578 | .. search_path 579 | .. " " 580 | .. "-g '*.norg' --with-filename --line-number '" 581 | .. base_directory 582 | .. "'" 583 | local rg_results = vim.fn.system(rg_command) 584 | 585 | if module.config.public.fuzzy_finder == "Telescope" then 586 | -- Process the ripgrep results 587 | local matches = {} 588 | local pattern = "([^:]+):(%d+):(.*)" 589 | for line in rg_results:gmatch("([^\n]+)") do 590 | local file, lineno, text = line:match(pattern) 591 | local metadata = module.required["external.many-mans"]["meta-man"].extract_file_metadata(file) 592 | if metadata ~= nil then 593 | table.insert(matches, { file, lineno, text, metadata["title"] }) 594 | else 595 | table.insert(matches, { file, lineno, text, "Untitled" }) 596 | end 597 | end 598 | 599 | local opts = {} 600 | opts.entry_maker = opts.entry_maker or module.private.telescope_modules.make_entry.gen_from_file(opts) 601 | 602 | -- Set up Telescope picker to display and select Neorg blocks 603 | module.private.telescope_modules.pickers 604 | .new(opts, { 605 | prompt_title = "Find Block", 606 | finder = module.private.telescope_modules.finders.new_table({ 607 | results = matches, 608 | entry_maker = function(entry) 609 | local filename = entry[1] 610 | local line_number = tonumber(entry[2]) 611 | local text = tostring(entry[3]) 612 | local title = tostring(entry[4]) 613 | 614 | return { 615 | value = filename, 616 | display = title .. " | " .. text, 617 | ordinal = title .. " | " .. text, 618 | filename = filename, 619 | lnum = line_number, 620 | line = text, 621 | } 622 | end, 623 | }), 624 | previewer = module.private.telescope_modules.conf.grep_previewer(opts), 625 | sorter = module.private.telescope_modules.conf.file_sorter(opts), 626 | attach_mappings = function(prompt_bufnr, map) 627 | -- Map to insert the selected block into the current buffer 628 | map("i", "", function() 629 | local entry = module.private.telescope_modules.state.get_selected_entry() 630 | local filename = entry.filename 631 | local base_path = base_directory:gsub("([^%w])", "%%%1") 632 | local rel_path = filename:match("^" .. base_path .. "/(.+)%..+") 633 | -- Insert at the cursor location 634 | local heading_prefix = string.match(entry.line, "^(%** )") 635 | local heading_text = module.private.get_heading_text(filename, entry.lnum) 636 | if not heading_text then 637 | return 638 | else 639 | heading_text = heading_text:gsub("^%s+", "") 640 | end 641 | local full_heading_text = heading_prefix .. heading_text 642 | 643 | module.private.telescope_modules.actions.close(prompt_bufnr) 644 | vim.api.nvim_put( 645 | { "{:$/" .. rel_path .. ":" .. full_heading_text .. "}[" .. heading_text .. "]" }, 646 | "", 647 | false, 648 | true 649 | ) 650 | end) 651 | return true 652 | end, 653 | }) 654 | :find() 655 | elseif module.config.public.fuzzy_finder == "Fzf" then 656 | local text_string = {} 657 | local text_string_matches_dict = {} 658 | local pattern = "([^:]+):(%d+):(.*)" 659 | 660 | for line in rg_results:gmatch("([^\n]+)") do 661 | local file, lineno, text = line:match(pattern) 662 | local metadata = module.required["external.many-mans"]["meta-man"].extract_file_metadata(file) 663 | if metadata ~= nil then 664 | table.insert(text_string, metadata["title"] .. " | " .. text) 665 | text_string_matches_dict[metadata["title"] .. " | " .. text] = { 666 | ["file"] = file, 667 | ["line"] = lineno, 668 | ["title"] = metadata["title"], 669 | ["heading_text"] = text, 670 | } 671 | else 672 | table.insert(text_string, file .. " | " .. text) 673 | text_string_matches_dict[file .. " | " .. text] = { 674 | ["file"] = file, 675 | ["line"] = lineno, 676 | ["title"] = file, 677 | ["heading_text"] = text, 678 | } 679 | end 680 | end 681 | 682 | local BlockPreview = module.private.fzf_modules.builtin_previewer.buffer_or_file:extend() 683 | 684 | function BlockPreview:new(o, opts, fzf_win) 685 | BlockPreview.super.new(self, o, opts, fzf_win) 686 | setmetatable(self, BlockPreview) 687 | return self 688 | end 689 | 690 | function BlockPreview:parse_entry(entry_str) 691 | return { 692 | path = text_string_matches_dict[entry_str] == nil and "/tmp/" 693 | or text_string_matches_dict[entry_str]["file"], 694 | line = text_string_matches_dict[entry_str] == nil and 1 695 | or text_string_matches_dict[entry_str]["line"], 696 | col = 1, 697 | } 698 | end 699 | 700 | module.private.fzf_modules.fzf_lua.fzf_exec(text_string, { 701 | previewer = BlockPreview, 702 | prompt = "Find Neorg Block> ", 703 | actions = { 704 | ["default"] = { 705 | function(selected, _) 706 | vim.cmd("q") 707 | vim.cmd("edit " .. text_string_matches_dict[selected[1]]["file"]) 708 | vim.cmd(":" .. text_string_matches_dict[selected[1]]["line"]) 709 | end, 710 | }, 711 | ["ctrl-i"] = { 712 | function(selected, _) 713 | local filename = text_string_matches_dict[selected[1]]["file"] 714 | local base_path = base_directory:gsub("([^%w])", "%%%1") 715 | local rel_path = filename:match("^" .. base_path .. "/(.+)%..+") 716 | 717 | local heading_prefix = 718 | string.match(text_string_matches_dict[selected[1]]["heading_text"], "^(%** )") 719 | local heading_text = module.private.get_heading_text( 720 | filename, 721 | tonumber(text_string_matches_dict[selected[1]]["line"]) 722 | ) 723 | if not heading_text then 724 | return 725 | else 726 | heading_text = heading_text:gsub("^%s+", "") 727 | end 728 | local full_heading_text = heading_prefix .. heading_text 729 | 730 | vim.cmd("q") 731 | vim.api.nvim_put( 732 | { "{:$/" .. rel_path .. ":" .. full_heading_text .. "}[" .. heading_text .. "]" }, 733 | "", 734 | true, 735 | true 736 | ) 737 | end, 738 | }, 739 | }, 740 | }) 741 | elseif module.config.public.fuzzy_finder == "Snacks" then 742 | local get_blocks = function() 743 | local items = {} 744 | local pattern = "([^:]+):(%d+):(.*)" 745 | 746 | for line in rg_results:gmatch("([^\n]+)") do 747 | local file, lineno, text = line:match(pattern) 748 | local metadata = module.required["external.many-mans"]["meta-man"].extract_file_metadata(file) 749 | if metadata ~= nil then 750 | table.insert(items, { 751 | text = metadata["title"] .. " | " .. text, 752 | heading = text, 753 | file = file, 754 | pos = { tonumber(lineno), 1 }, 755 | }) 756 | else 757 | table.insert( 758 | items, 759 | { text = file .. " | " .. text, heading = text, file = file, pos = { tonumber(lineno), 1 } } 760 | ) 761 | end 762 | end 763 | return items 764 | end 765 | 766 | module.private.snacks_modules.picker.pick({ 767 | source = "neorg_blocks", 768 | items = get_blocks(), 769 | format = "text", 770 | confirm = function(picker, item) 771 | picker:close() 772 | vim.cmd("edit " .. item.file) 773 | vim.cmd(":" .. item.pos[1]) 774 | end, 775 | actions = { 776 | insert_block_at_cursor = function(picker, item) 777 | picker:close() 778 | local filename = item.file 779 | local base_path = base_directory:gsub("([^%w])", "%%%1") 780 | local rel_path = filename:match("^" .. base_path .. "/(.+)%..+") 781 | 782 | local heading_prefix = string.match(item.heading, "^(%** )") 783 | local heading_text = module.private.get_heading_text(filename, tonumber(item.pos[1])) 784 | if not heading_text then 785 | return 786 | else 787 | heading_text = heading_text:gsub("^%s+", "") 788 | end 789 | local full_heading_text = heading_prefix .. heading_text 790 | 791 | vim.api.nvim_put( 792 | { "{:$/" .. rel_path .. ":" .. full_heading_text .. "}[" .. heading_text .. "]" }, 793 | "", 794 | true, 795 | true 796 | ) 797 | end, 798 | }, 799 | win = { 800 | input = { 801 | keys = { 802 | [""] = { 803 | "insert_block_at_cursor", 804 | mode = { "n", "i" }, 805 | desc = "Insert Block Reference at Cursor", 806 | }, 807 | }, 808 | }, 809 | }, 810 | }) 811 | end 812 | end, 813 | 814 | -- Function to select and switch between Neorg workspaces. 815 | -- This function lists available workspaces and allows the user to switch to a selected workspace. 816 | workspace_selector = function() 817 | local fuzzy = module.private.get_fuzzy_finder_modules() 818 | if not fuzzy then 819 | vim.notify("No fuzzy finder present.", vim.log.levels.ERROR) 820 | return nil 821 | end 822 | 823 | local workspaces = module.required["core.dirman"].get_workspaces() 824 | local workspace_names = {} 825 | -- Collect the names of all workspaces 826 | for name in pairs(workspaces) do 827 | table.insert(workspace_names, name) 828 | end 829 | 830 | if module.config.public.fuzzy_finder == "Telescope" then 831 | local opts = {} 832 | opts.entry_maker = opts.entry_maker or module.private.telescope_modules.make_entry.gen_from_file(opts) 833 | 834 | -- Set up Telescope picker to display and select Neorg workspaces 835 | module.private.telescope_modules.pickers 836 | .new(opts, { 837 | prompt_title = "Find Neorg Workspace", 838 | finder = module.private.telescope_modules.finders.new_table({ 839 | results = workspace_names, 840 | entry_maker = function(entry) 841 | local filename = workspaces[entry] .. "/index.norg" 842 | 843 | return { 844 | value = filename, 845 | display = entry, 846 | ordinal = entry, 847 | filename = filename, 848 | } 849 | end, 850 | }), 851 | previewer = module.private.telescope_modules.conf.file_previewer(opts), 852 | sorter = module.private.telescope_modules.conf.file_sorter(opts), 853 | attach_mappings = function(prompt_bufnr, map) 854 | -- Map to switch to the selected workspace 855 | map("i", "", function() 856 | local entry = module.private.telescope_modules.state.get_selected_entry() 857 | module.private.telescope_modules.actions.close(prompt_bufnr) 858 | module.required["core.dirman"].set_workspace(tostring(entry.display)) 859 | end) 860 | map("n", "", function() 861 | local entry = module.private.telescope_modules.state.get_selected_entry() 862 | module.private.telescope_modules.actions.close(prompt_bufnr) 863 | module.required["core.dirman"].set_workspace(tostring(entry.display)) 864 | end) 865 | 866 | return true 867 | end, 868 | }) 869 | :find() 870 | elseif module.config.public.fuzzy_finder == "Fzf" then 871 | local WorkspacePreview = module.private.fzf_modules.builtin_previewer.buffer_or_file:extend() 872 | 873 | function WorkspacePreview:new(o, opts, fzf_win) 874 | WorkspacePreview.super.new(self, o, opts, fzf_win) 875 | setmetatable(self, WorkspacePreview) 876 | return self 877 | end 878 | 879 | function WorkspacePreview:parse_entry(entry_str) 880 | return { 881 | path = workspaces[entry_str] == nil and "/tmp/" or workspaces[entry_str] .. "/index.norg", 882 | line = 1, 883 | col = 1, 884 | } 885 | end 886 | 887 | module.private.fzf_modules.fzf_lua.fzf_exec(workspace_names, { 888 | previewer = WorkspacePreview, 889 | prompt = "Find Neorg Workspace> ", 890 | actions = { 891 | ["default"] = { 892 | function(selected, _) 893 | module.required["core.dirman"].set_workspace(tostring(selected[1])) 894 | vim.cmd(":q") 895 | vim.cmd("edit " .. workspaces[selected[1]] .. "/index.norg") 896 | end, 897 | }, 898 | ["ctrl-i"] = { 899 | function(selected, _) 900 | module.required["core.dirman"].set_workspace(tostring(selected[1])) 901 | vim.cmd(":q") 902 | vim.cmd("edit " .. workspaces[selected[1]] .. "/index.norg") 903 | vim.cmd(":1") 904 | end, 905 | }, 906 | }, 907 | }) 908 | elseif module.config.public.fuzzy_finder == "Snacks" then 909 | local get_workspaces = function() 910 | local item = {} 911 | for i in pairs(workspace_names) do 912 | table.insert(item, { text = workspace_names[i], file = tostring(workspaces[workspace_names[i]]) }) 913 | end 914 | return item 915 | end 916 | module.private.snacks_modules.picker.pick({ 917 | source = "neorg_workspaces", 918 | items = get_workspaces(), 919 | format = "text", 920 | preview = "file", 921 | confirm = function(picker, item) 922 | picker:close() 923 | module.required["core.dirman"].set_workspace(item.text) 924 | end, 925 | actions = { 926 | open_index = function(picker, item) 927 | picker:close() 928 | vim.cmd("edit " .. workspaces[item.text] .. "/index.norg") 929 | vim.cmd(":1") 930 | end, 931 | }, 932 | win = { 933 | input = { 934 | keys = { 935 | [""] = { "open_index", mode = { "n", "i" }, desc = "Open Workspace Index" }, 936 | }, 937 | }, 938 | }, 939 | }) 940 | end 941 | end, 942 | 943 | -- Function to find and display backlinks to the current Neorg file. 944 | -- This function searches for references to the current file in other Neorg files and lists them. 945 | backlinks = function() 946 | local fuzzy = module.private.get_fuzzy_finder_modules() 947 | if not fuzzy then 948 | vim.notify("No fuzzy finder present.", vim.log.levels.ERROR) 949 | return nil 950 | end 951 | 952 | local current_workspace = module.required["core.dirman"].get_current_workspace() 953 | local base_directory = current_workspace[2] 954 | 955 | -- Get the path of the current file and convert it to a relative path within the workspace 956 | local current_file_path = vim.fn.expand("%:p") 957 | local escaped_base_path = base_directory:gsub("([^%w])", "%%%1") 958 | local relative_path = current_file_path:match("^" .. escaped_base_path .. "/(.+)%..+") 959 | if relative_path == nil then 960 | vim.notify("Current Node isn't a part of the Current Neorg Workspace", vim.log.levels.ERROR) 961 | return 962 | end 963 | local search_path = "{:$/" .. relative_path .. ":" 964 | 965 | -- Run ripgrep to find backlinks in other Neorg files 966 | local rg_command = "rg --fixed-strings " 967 | .. "'" 968 | .. search_path 969 | .. "'" 970 | .. " " 971 | .. "-g '*.norg' --with-filename --line-number '" 972 | .. base_directory 973 | .. "'" 974 | local rg_results = vim.fn.system(rg_command) 975 | 976 | -- Process the ripgrep results to identify backlinks 977 | local self_title = 978 | module.required["external.many-mans"]["meta-man"].extract_file_metadata(current_file_path)["title"] 979 | 980 | if not module.config.public.fuzzy_backlinks then 981 | local buffer_lines = {} 982 | table.insert(buffer_lines, "") 983 | table.insert(buffer_lines, "* Backlinks to -- [" .. self_title .. "]") 984 | table.insert(buffer_lines, "") 985 | table.insert(buffer_lines, "___") 986 | table.insert(buffer_lines, "") 987 | table.insert(buffer_lines, "") 988 | 989 | for line in rg_results:gmatch("([^\n]+)") do 990 | local file, lineno = line:match("^(.-):(%d+):") 991 | local metadata = module.required["external.many-mans"]["meta-man"].extract_file_metadata(file) 992 | 993 | if metadata == nil then 994 | table.insert(buffer_lines, "** {:" .. file .. ":" .. lineno .. "}[Untitled @" .. lineno .. "]") 995 | elseif metadata["title"] ~= self_title then 996 | table.insert( 997 | buffer_lines, 998 | "** {:" .. file .. ":" .. lineno .. "}[" .. metadata["title"] .. " @" .. lineno .. "]" 999 | ) 1000 | 1001 | local startrow = 0 1002 | if lineno - 3 < 1 then 1003 | startrow = 0 1004 | else 1005 | startrow = lineno - 3 1006 | end 1007 | 1008 | local endrow = 0 1009 | local wc_out = vim.fn.system("wc -l '" .. file .. "'") 1010 | local linecount = tonumber(wc_out:match("^(%d+)")) 1011 | if lineno + 3 > linecount then 1012 | endrow = linecount 1013 | else 1014 | endrow = lineno + 3 1015 | end 1016 | 1017 | table.insert(buffer_lines, "@code norg") 1018 | local curr_row = 0 1019 | for row in io.lines(file) do 1020 | curr_row = curr_row + 1 1021 | if curr_row >= startrow and curr_row <= endrow then 1022 | -- Escape out any lines that start with @ 1023 | -- because it can interfere with the @code ... @end block 1024 | row = row:gsub("^@", "\\@") 1025 | table.insert(buffer_lines, row) 1026 | end 1027 | end 1028 | table.insert(buffer_lines, "@end") 1029 | table.insert(buffer_lines, "___") 1030 | end 1031 | end 1032 | 1033 | module.required["external.many-mans"]["buff-man"].create_backlinks_buffer(buffer_lines) 1034 | else 1035 | if module.config.public.fuzzy_finder == "Telescope" then 1036 | local matches = {} 1037 | for line in rg_results:gmatch("([^\n]+)") do 1038 | local file, lineno = line:match("^(.-):(%d+):") 1039 | local metadata = module.required["external.many-mans"]["meta-man"].extract_file_metadata(file) 1040 | if metadata == nil then 1041 | table.insert(matches, { file, lineno, "Untitled" }) 1042 | elseif metadata["title"] ~= self_title then 1043 | table.insert(matches, { file, lineno, metadata["title"] }) 1044 | else 1045 | table.insert(matches, { file, lineno, "Untitled" }) 1046 | end 1047 | end 1048 | 1049 | local opts = {} 1050 | opts.entry_maker = opts.entry_maker or module.private.telescope_modules.make_entry.gen_from_file(opts) 1051 | 1052 | -- Set up Telescope picker to display and select backlinks 1053 | module.private.telescope_modules.pickers 1054 | .new(opts, { 1055 | prompt_title = "Backlinks", 1056 | finder = module.private.telescope_modules.finders.new_table({ 1057 | results = matches, 1058 | entry_maker = function(entry) 1059 | local filename = entry[1] 1060 | local line_number = tonumber(entry[2]) 1061 | local title = entry[3] 1062 | 1063 | return { 1064 | value = filename, 1065 | display = title .. " @" .. line_number, 1066 | ordinal = title, 1067 | filename = filename, 1068 | lnum = line_number, 1069 | } 1070 | end, 1071 | }), 1072 | previewer = module.private.telescope_modules.conf.grep_previewer(opts), 1073 | sorter = module.private.telescope_modules.conf.file_sorter(opts), 1074 | }) 1075 | :find() 1076 | elseif module.config.public.fuzzy_finder == "Fzf" then 1077 | local backlink_texts = {} 1078 | local backlink_text_matches_dict = {} 1079 | for line in rg_results:gmatch("([^\n]+)") do 1080 | local file, lineno = line:match("^(.-):(%d+):") 1081 | local metadata = module.required["external.many-mans"]["meta-man"].extract_file_metadata(file) 1082 | if metadata == nil then 1083 | table.insert(backlink_texts, "Untitled @" .. lineno) 1084 | backlink_text_matches_dict["Untitled @" .. lineno] = { ["file"] = file, ["line"] = lineno } 1085 | elseif metadata["title"] ~= self_title then 1086 | table.insert(backlink_texts, metadata["title"] .. " @" .. lineno) 1087 | backlink_text_matches_dict[metadata["title"] .. " @" .. lineno] = 1088 | { ["file"] = file, ["line"] = lineno } 1089 | else 1090 | table.insert(backlink_texts, "Untitled @" .. lineno) 1091 | backlink_text_matches_dict["Untitled @" .. lineno] = { ["file"] = file, ["line"] = lineno } 1092 | end 1093 | end 1094 | 1095 | local BacklinksPreview = module.private.fzf_modules.builtin_previewer.buffer_or_file:extend() 1096 | 1097 | function BacklinksPreview:new(o, opts, fzf_win) 1098 | BacklinksPreview.super.new(self, o, opts, fzf_win) 1099 | setmetatable(self, BacklinksPreview) 1100 | return self 1101 | end 1102 | 1103 | function BacklinksPreview:parse_entry(entry_str) 1104 | return { 1105 | path = backlink_text_matches_dict[entry_str] == nil and "/tmp/" 1106 | or backlink_text_matches_dict[entry_str]["file"], 1107 | line = backlink_text_matches_dict[entry_str] == nil and 1 1108 | or backlink_text_matches_dict[entry_str]["line"], 1109 | col = 1, 1110 | } 1111 | end 1112 | 1113 | module.private.fzf_modules.fzf_lua.fzf_exec(backlink_texts, { 1114 | previewer = BacklinksPreview, 1115 | prompt = "Backlinks> ", 1116 | actions = { 1117 | ["default"] = { 1118 | function(selected, _) 1119 | vim.cmd("q") 1120 | vim.cmd("edit " .. backlink_text_matches_dict[selected[1]]["file"]) 1121 | vim.cmd(":" .. backlink_text_matches_dict[selected[1]]["line"]) 1122 | end, 1123 | }, 1124 | }, 1125 | }) 1126 | elseif module.config.public.fuzzy_finder == "Snacks" then 1127 | local get_backlinks = function() 1128 | local items = {} 1129 | for line in rg_results:gmatch("([^\n]+)") do 1130 | local file, lineno = line:match("^(.-):(%d+):") 1131 | local metadata = module.required["external.many-mans"]["meta-man"].extract_file_metadata(file) 1132 | if metadata == nil then 1133 | table.insert( 1134 | items, 1135 | { text = "Untitled @" .. lineno, file = file, pos = { tonumber(lineno), 1 } } 1136 | ) 1137 | elseif metadata["title"] ~= self_title then 1138 | table.insert(items, { 1139 | text = metadata["title"] .. " @" .. lineno, 1140 | file = file, 1141 | pos = { tonumber(lineno), 1 }, 1142 | }) 1143 | else 1144 | table.insert( 1145 | items, 1146 | { text = "Untitled @" .. lineno, file = file, pos = { tonumber(lineno), 1 } } 1147 | ) 1148 | end 1149 | end 1150 | return items 1151 | end 1152 | 1153 | module.private.snacks_modules.picker.pick({ 1154 | source = "neorg_backlinks", 1155 | items = get_backlinks(), 1156 | format = "text", 1157 | preview = "file", 1158 | confirm = function(picker, item) 1159 | picker:close() 1160 | vim.cmd("edit " .. item.file) 1161 | vim.cmd(":" .. item.pos[1]) 1162 | end, 1163 | }) 1164 | end 1165 | end 1166 | end, 1167 | 1168 | -- Function to create a capture buffer and append text to today's journal entry 1169 | ---@param input_table table Template name and split kind 1170 | capture = function(input_table) 1171 | -- Search current workspace directory for a 1172 | -- Open a file in /tmp directory with name generated 1173 | -- '/tmp/' .. os.date("%Y%m%d%H%M%S") .. 'capture_type' .. '.norg' 1174 | -- Open capture buffer to that 1175 | local current_workspace = module.required["core.dirman"].get_current_workspace()[2] 1176 | 1177 | -- First check if default templates are populated 1178 | local templates_present = module.private.verify_default_capture_templates() 1179 | if not templates_present then 1180 | module.private.generate_default_capture_templates() 1181 | end 1182 | 1183 | -- If input is a custom template, check if that exists 1184 | local template_path = current_workspace .. "/.capture-templates/" .. input_table["template"] .. ".norg" 1185 | local template_exists = vim.fn.filereadable(template_path) 1186 | if template_exists ~= 1 then 1187 | vim.notify( 1188 | "Template " .. input_table["template"] .. ".norg does not exist in $workspace/.capture-templates folder", 1189 | vim.log.levels.WARN 1190 | ) 1191 | 1192 | local ok, _, code = 1193 | os.rename(current_workspace .. "/.capture-templates", current_workspace .. "/.capture-templates") 1194 | if not ok and code == 2 then 1195 | vim.fn.mkdir(current_workspace .. "/.capture-templates", "p") 1196 | end 1197 | 1198 | vim.cmd("edit " .. current_workspace .. "/.capture-templates/" .. input_table["template"] .. ".norg") 1199 | vim.api.nvim_buf_set_lines( 1200 | 0, 1201 | 0, 1202 | 0, 1203 | false, 1204 | vim.split("/insert template text, then save `:wq` to create new template./ \n", "\n") 1205 | ) 1206 | vim.api.nvim_buf_set_lines( 1207 | 0, 1208 | 1, 1209 | 1, 1210 | false, 1211 | vim.split("/Then recall `Neorg roam capture ` to create new capture./ \n", "\n") 1212 | ) 1213 | return 1214 | end 1215 | 1216 | if input_table["template"] == "selection" then 1217 | local start_row, start_col = vim.fn.line("'<"), vim.fn.col("'<") 1218 | local end_row, end_col = vim.fn.line("'>"), vim.fn.col("'>") 1219 | -- If the selection is reversed, swap the start and end positions 1220 | if start_row > end_row or (start_row == end_row and start_col > end_col) then 1221 | start_row, start_col, end_row, end_col = end_row, end_col, start_row, start_col 1222 | end 1223 | 1224 | local lines = vim.api.nvim_buf_get_lines(0, start_row - 1, end_row, false) 1225 | 1226 | lines[1] = string.sub(lines[1], start_col) 1227 | lines[#lines] = string.sub(lines[#lines], 1, end_col) 1228 | 1229 | -- Add code block 1230 | table.insert(lines, 1, "@code " .. vim.bo.filetype) 1231 | table.insert(lines, "@end") 1232 | table.insert(lines, 1, "") 1233 | 1234 | -- Add heading and hyperlink 1235 | local path_str = vim.fn.expand("%:p") 1236 | local filename_str = vim.fn.expand("%:t") 1237 | local hostname_str = vim.fn.hostname() 1238 | local heading_str = "* Clipped from {/ " 1239 | .. path_str 1240 | .. ":" 1241 | .. start_row 1242 | .. "}[" 1243 | .. filename_str 1244 | .. "] @hostname:" 1245 | .. hostname_str 1246 | table.insert(lines, 1, heading_str) 1247 | table.insert(lines, 1, "") 1248 | 1249 | -- local lines = vim.fn.readfile(template_path) 1250 | module.required["external.many-mans"]["buff-man"].create_capture_buffer( 1251 | lines, 1252 | input_table["kind"], 1253 | input_table["template"] 1254 | ) 1255 | else 1256 | local lines = vim.fn.readfile(template_path) 1257 | module.required["external.many-mans"]["buff-man"].create_capture_buffer( 1258 | lines, 1259 | input_table["kind"], 1260 | input_table["template"] 1261 | ) 1262 | end 1263 | end, 1264 | } 1265 | 1266 | module.on_event = function(event) 1267 | if event.split_type[2] == "external.roam.node" then 1268 | module.public.node() 1269 | elseif event.split_type[2] == "external.roam.block" then 1270 | module.public.block() 1271 | elseif event.split_type[2] == "external.roam.backlinks" then 1272 | module.public.backlinks() 1273 | elseif event.split_type[2] == "external.roam.select_workspace" then 1274 | module.public.workspace_selector() 1275 | elseif event.split_type[2] == "external.roam.capture" then 1276 | local input_table = { 1277 | template = event.content[1], -- Template name 1278 | kind = #event.content > 1 and event.content[2]:match("=(.+)") or "split", -- Split kind 1279 | } 1280 | module.public.capture(input_table) 1281 | end 1282 | end 1283 | 1284 | return module 1285 | -------------------------------------------------------------------------------- /test/capture_edge_cases.norg: -------------------------------------------------------------------------------- 1 | * (?) Capture this (and this) 2 | ** (?) And this (and this) 3 | *** (?) And this (and this) 4 | **** (?) And also this (and this) 5 | ***** (?) Maybe this? (and this) 6 | ****** (?) And also this (and this) 7 | * (_) Capture this (and this) 8 | ** (_) And this (and this) 9 | *** (_) And this (and this) 10 | **** (_) And also this (and this) 11 | ***** (_) Maybe this? (and this) 12 | ****** (_) And also this (and this) 13 | * (x) Capture this (and this) 14 | ** (x) And this (and this) 15 | *** (x) And this (and this) 16 | **** (x) And also this (and this) 17 | ***** (x) Maybe this? (and this) 18 | ****** (x) And also this (and this) 19 | * (!) Capture this (and this) 20 | ** (!) And this (and this) 21 | *** (!) And this (and this) 22 | **** (!) And also this (and this) 23 | ***** (!) Maybe this? (and this) 24 | ****** (!) And also this (and this) 25 | * (-) Capture this (and this) 26 | ** (-) And this (and this) 27 | *** (-) And this (and this) 28 | **** (-) And also this (and this) 29 | ***** (-) Maybe this? (and this) 30 | ****** (-) And also this (and this) 31 | * ( ) Capture this (and this) 32 | ** ( ) And this (and this) 33 | *** ( ) And this (and this) 34 | **** ( ) And also this (and this) 35 | ***** ( ) Maybe this? (and this) 36 | ****** ( ) And also this (and this) 37 | * (=) Capture this (and this) 38 | ** (=) And this (and this) 39 | *** (=) And this (and this) 40 | **** (=) And also this (and this) 41 | ***** (=) Maybe this? (and this) 42 | ****** (=) And also this (and this) 43 | * (+) Capture this (and this) 44 | ** (+) And this (and this) 45 | *** (+) And this (and this) 46 | **** (+) And also this (and this) 47 | ***** (+) Maybe this? (and this) 48 | ****** (+) And also this (and this) 49 | === 50 | None of these * (?) Capture this 51 | None of these ** (?) And this 52 | None of these *** (?) And this 53 | None of these *** (?) And also this 54 | None of these **** (?) Maybe this? 55 | None of these ***** (?) And also this 56 | None of these * (_) Capture this 57 | None of these ** (_) And this 58 | None of these *** (_) And this 59 | None of these **** (_) And also this 60 | None of these ***** (_) Maybe this? 61 | None of these ****** (_) And also this 62 | None of these * (x) Capture this 63 | None of these ** (x) And this 64 | None of these *** (x) And this 65 | None of these **** (x) And also this 66 | None of these ***** (x) Maybe this? 67 | None of these ****** (x) And also this 68 | None of these * (!) Capture this 69 | None of these ** (!) And this 70 | None of these *** (!) And this 71 | None of these **** (!) And also this 72 | None of these ***** (!) Maybe this? 73 | None of these ****** (!) And also this 74 | None of these * (-) Capture this 75 | None of these ** (-) And this 76 | None of these *** (-) And this 77 | None of these **** (-) And also this 78 | None of these ***** (-) Maybe this? 79 | None of these ****** (-) And also this 80 | None of these * ( ) Capture this 81 | None of these ** ( ) And this 82 | None of these *** ( ) And this 83 | None of these **** ( ) And also this 84 | None of these ***** ( ) Maybe this? 85 | None of these ****** ( ) And also this 86 | None of these * (=) Capture this 87 | None of these ** (=) And this 88 | None of these *** (=) And this 89 | None of these **** (=) And also this 90 | None of these ***** (=) Maybe this? 91 | None of these ****** (=) And also this 92 | None of these * (+) Capture this 93 | None of these ** (+) And this 94 | None of these *** (+) And this 95 | None of these **** (+) And also this 96 | None of these ***** (+) Maybe this? 97 | None of these ****** (+) And also this 98 | 99 | -------------------------------------------------------------------------------- /test/rg_for_all_tasks.txt: -------------------------------------------------------------------------------- 1 | rg '^\*{1,8} \(\s*(-?)\s*x*\?*!*_*\+*=*\)' --glob '*.norg' --line-number 2 | -------------------------------------------------------------------------------- /test/rg_for_block_text.txt: -------------------------------------------------------------------------------- 1 | ** Test Flights: 14 August 2024 2 | --------------------------------------------------------------------------------