├── .gitignore ├── CHANGES.TXT ├── LICENSE.TXT ├── README ├── addon-info.json ├── autoload ├── tcomment │ └── types │ │ └── ttodo.vim ├── ttodo.vim └── ttodo │ └── ftplugin.vim ├── doc ├── tags └── ttodo.txt ├── etc └── tpl_ttodo.txt ├── ftdetect └── ttodo.vim ├── ftplugin └── ttodo.vim ├── plugin └── ttodo.vim └── syntax └── ttodo.vim /.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | !doc/tags 3 | Makefile 4 | TODO.TXT 5 | TODO_archived.viki 6 | *.vba 7 | *.vmb 8 | *.zip 9 | .last_* 10 | test 11 | test_* 12 | tmp 13 | var 14 | -------------------------------------------------------------------------------- /CHANGES.TXT: -------------------------------------------------------------------------------- 1 | version: "0.02" 2 | - :Ttodo -A, -R, -i, -x command line options; require tlib >= 1.16 3 | - ttodo#CComplete(): use tlib#arg#Complete; misc 4 | - NEW --sort command-line option; vikitask integration for manipulating todo.txt files; misc enh 5 | - NEW own ftplugin; misc improvements 6 | - Require vikitasks >= 1.02 7 | - Use tlib#file#Globpath() 8 | - various improvements 9 | - s/TLibTrace/Tlibtrace/g 10 | - version 0.01-151109 11 | MD5 checksum: e6b8be03504c4a9d948ca4a38de683f3 12 | 13 | version: "0.03" 14 | - ttodo#Show: copy(s:list_env) 15 | - NEW :Ttodosort command 16 | - Support for indented subtasks similar to the outline add-on; misc enhancements 17 | - Support for tcomment 18 | - Fix handling of subtasks; map for inserting subtasks; g:ttodo#viewer is a list 19 | - NEW --encoding command-line option 20 | - NEW --bufnr, --bufname command-line options 21 | - Remove dependency on vikitasks plugin 22 | - Use autocmd BufNewFile,BufRead done.txt 23 | - Use , t1 for setting the priority 24 | - ttodo#GetFileTasks: Use tlib#eval#Extend(copy(parent.task), task) 25 | - g:ttodo#viewer is a string; removed last traces of vikitasks 26 | - Configure "hidden" tasks via g:ttodo#task_hide_rx 27 | - NEW :Ttodotask; use y for SetPriority; misc enhancements 28 | - Properly support file-specific args; improved support for subtasks; misc enh.s 29 | - NEW g:ttodo#filesargs: A dictionary of {filename regexp: {additional args}} 30 | - NEW --has_lists=, --has_tags= command-line options 31 | - g:ttodo#sort: s/idx/lnum/ 32 | - s/Ttodotask/Ttodonew/ 33 | - Misc improvements to ftplugin 34 | - s:GetFiles(): FIX type error 35 | - s:FilterTasks(): Don't use g:ttodo#default_pri 36 | - FIX Ttodosort 37 | - Stop when sorting task outlines 38 | - Warn if subtask has a due date after the parent's task due date 39 | - ttodo#ftplugin#New(): FIX indentation 40 | MD5 checksum: f3cbe1572df17ba026f84166d3857a4b 41 | 42 | - g:ttodo#ftplugin#add_at_eof defaults to 1 43 | - NEW map t* 44 | - g:ttodo_enable_ftdetect defaults to 1 45 | - Completion for lists and tags 46 | - Require tlib 1.18 47 | - Command-line completion for Ttodonew 48 | - :Ttodonew respects --pref argument 49 | - ftplugin: lb fo=cql 50 | - Cache each parsed tasks not tasks per file 51 | - Highlight overdue due dates 52 | - Task dependencies, --pending command-line option 53 | - dep:IDs is a comma-separated list 54 | - Sort moves overdue items to the top 55 | - NEW ttodo#ftplugin#AddDep(), map: tD 56 | - Fix has_lists/tags command-line flag 57 | - s/tlib#type#DefSchema/tlib#type#Define/; require tlib >= 1.19 58 | - ttodo#ftplugin#Archive(): Don't archive tasks with pending sub/tasks 59 | - ttodo#ftplugin#Agent: Allow for "once" expressions as arguments 60 | - g:ttodo#rewrite_gsub: FIX regexp 61 | - NEW g:ttodo#ftplugin#rec_copy: copy recurring tasks when marking them as "done" 62 | - ttodo#ftplugin#MarkDone(): Make sure to inc due date once 63 | - NEW :Ttodogrep 64 | - ttodo#NewTask: FIX handling of inboxfile arg 65 | - Simplify g:ttodo#prefs 66 | - g:ttodo#new_task: pri = C 67 | - NEW ignore_lists, ignore_tags, ignore_pri arguments 68 | - g:ttodo#prefs: important.due = 1w 69 | - g:ttodo#sort_defaults.pri = I 70 | - s:FilterTasks: FIX handling of undated 71 | - NEW ttodo#InputNumber() 72 | - ttodo#ftplugin#MarkDue: Accept count == -1 73 | - NEW Ttodoinbox 74 | - TtodoHidden syntax 75 | - ttodo#ftplugin#MarkDone(): temporarily disallow for outlines with rec: tags; g:ttodo#ftplugin#rec_copy appends new task at the eof 76 | MD5 checksum: a7a364b97ca3e05540974d05a42a797e 77 | version: "1.00" 78 | 79 | version: '1.01' 80 | - s/@inbox/@Inbox/ 81 | - Allow for `due:today` shortcut 82 | - list view: FIX invocation of some commands on multiple items 83 | - g:ttodo#ftplugin#edit_note defaults to '' 84 | - syntax: don't accidentally highlight tags, keywords etc. within words 85 | - FIX #1: If g:ttodo#force_filetype evaluates to true, use `set ft=ttodo` instead of `setf ttodo` 86 | - FIX #2: Remove leading whitespace when archiving a sub-task 87 | - FIX #3: Use ttodo#IsValidDue(due) to validate the value of the `due` command-line flag 88 | - FIX handling of --[no-]undated 89 | - Support for rec:Nb business days 90 | - g:ttodo#ftplugin#note_prefix defaults to 'root://' 91 | - syntax/ttodo.vim: TtodoTag: Highlight only known tags 92 | - ttodo#SetCreateDate(): Marking a recurring task as done updates the created date 93 | - require tlib >= 1.22 94 | - also copies notes 95 | - FIX #4: docs for maps 96 | - Misc improvments 97 | - g:ttodo#file_pattern can be a list 98 | - --files command-line option actually works; more checks if a file exists 99 | - Support for @next lists 100 | - Command & map to open todo files in the current working directory 101 | - ttodo#ftplugin#MarkDone(): Don't inherit the @next list for recurrent items 102 | - s:GetFiles(): use map(); etc. 103 | - ftdetect: Also check for upper case TODO.TXT pattern 104 | - FIX parsing of tags & lists; FIX linter warnings 105 | - g:ttodo#ftplugin#new_subtask_copy_pri defaults to 0 106 | - misc improvements 107 | - Use tcomment#type#Define() instead of tcomment#DefineType() for tcomment >= 4.00 108 | - Make the done filename configurable 109 | - Misc improvements to "mark done" & "archive" 110 | - Support for file-local options 111 | SHA256 checksum: 6fcd0ebac1f0a01222ef9b836fd39843921f03a5eab4d93e3c30ec4ad1c4edf1 112 | 113 | version: '1.01' 114 | - s/@inbox/@Inbox/ 115 | - Allow for `due:today` shortcut 116 | - list view: FIX invocation of some commands on multiple items 117 | - g:ttodo#ftplugin#edit_note defaults to '' 118 | - syntax: don't accidentally highlight tags, keywords etc. within words 119 | - FIX #1: If g:ttodo#force_filetype evaluates to true, use `set ft=ttodo` instead of `setf ttodo` 120 | - FIX #2: Remove leading whitespace when archiving a sub-task 121 | - FIX #3: Use ttodo#IsValidDue(due) to validate the value of the `due` command-line flag 122 | - FIX handling of --[no-]undated 123 | - Support for rec:Nb business days 124 | - g:ttodo#ftplugin#note_prefix defaults to 'root://' 125 | - syntax/ttodo.vim: TtodoTag: Highlight only known tags 126 | - ttodo#SetCreateDate(): Marking a recurring task as done updates the created date 127 | - require tlib >= 1.22 128 | - also copies notes 129 | - FIX #4: docs for maps 130 | - Misc improvments 131 | - g:ttodo#file_pattern can be a list 132 | - --files command-line option actually works; more checks if a file exists 133 | - Support for @next lists 134 | - Command & map to open todo files in the current working directory 135 | - ttodo#ftplugin#MarkDone(): Don't inherit the @next list for recurrent items 136 | - s:GetFiles(): use map(); etc. 137 | - ftdetect: Also check for upper case TODO.TXT pattern 138 | - FIX parsing of tags & lists; FIX linter warnings 139 | - g:ttodo#ftplugin#new_subtask_copy_pri defaults to 0 140 | - misc improvements 141 | - Use tcomment#type#Define() instead of tcomment#DefineType() for tcomment >= 4.00 142 | - Make the done filename configurable 143 | - Misc improvements to "mark done" & "archive" 144 | - Support for file-local options 145 | SHA256 checksum: 6fcd0ebac1f0a01222ef9b836fd39843921f03a5eab4d93e3c30ec4ad1c4edf1 146 | 147 | -------------------------------------------------------------------------------- /LICENSE.TXT: -------------------------------------------------------------------------------- 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: -------------------------------------------------------------------------------- 1 | This plugin provides the |:Ttodo| command that allow easy editing, 2 | viewing, and filtering of todo.txt files (see http://todotxt.com) via 3 | |tlib#input#List()|. The plugin supports: 4 | 5 | - syntax highlighting for todo.txt files 6 | - search across multiple todo.txt files (see |:Ttodo|) 7 | - filter tasks with specific tags, lists etc. (see |:Ttodo|) 8 | - subtasks (outlines of complex tasks) 9 | - hide tasks until a threshold date 10 | - recurring tasks. 11 | 12 | Examples: > 13 | 14 | " Show all tasks; default map (|g:ttodo_nmap|): 1 15 | :Ttodo 16 | 17 | " Show important tasks; default map (|g:ttodo_nmap_important|): ! 18 | :Ttodo! 19 | 20 | " Show tasks that are due in the next two weeks 21 | :Ttodo --due=2w 22 | 23 | " Show tasks with priorities A to C 24 | :Ttodo --pri=A-C 25 | 26 | " Show tasks matching @Test 27 | :Ttodo @Test 28 | 29 | " By default, |:Ttodo| scans the todo.txt files in |g:ttodo#dirs|. Users 30 | " can also scan loaded buffers. 31 | " Show tasks in the current buffer 32 | :Ttodo --bufname=% 33 | 34 | " Command-line options can be collected in preference sets (see 35 | " |g:ttodo#prefs|) 36 | :Ttodo --pref=work 37 | 38 | Global maps: 39 | 40 | 1 ............ Show tasks (:Ttodo) 41 | ! ............ Show important tasks (:Ttodo --pref=important) 42 | 43 | If filetype is ttodo, the following buffer-local keymaps are enabled: 44 | 45 | ................. Add a new task; 46 | if |g:ttodo#ftplugin#add_at_eof| is true, add the 47 | task at the end of file 48 | ............... Add a new task; copy any list, tags, and notes from 49 | the current task; 50 | if |g:ttodo#ftplugin#add_at_eof| is true, add the 51 | task at the end of file 52 | ............... Add a new subtask 53 | tx ...... Mark the current task as "done" 54 | td ...... Mark the current task as due in N days 55 | tw ...... Mark the current task as due in N weeks 56 | tm ...... Mark the current task as due in N months 57 | ty ...... Set the current task's priority 58 | ta ...... Archive completed tasks 59 | tb ...... View, filter tasks in the current buffer 60 | t* ...... View tasks in the current buffer that match the word 61 | under the cursor 62 | tn ...... Add a note (the filename uses the first @list tag) 63 | ti ...... Add a hopefully unique ID (an Adler32 hash) 64 | tD ...... Add a dependency 65 | 66 | If filetype is ttodo, the following buffer-local commands are enabled: 67 | 68 | |:Ttodoarchive| ...... Archive completed tasks in the current buffer 69 | |:Ttodobuffer| ....... Show tasks in the current buffer only 70 | |:Ttodonote| ......... Add a new note to the task at the cursor 71 | |:Ttodosort| ......... Sort the tasks in the current buffer 72 | 73 | As a ftplugin, ttodo supports the following syntax/extensions to todo.txt (see 74 | also https://github.com/ginatrapani/todo.txt-cli/wiki/The-Todo.txt-Format): 75 | 76 | (A) DATE TASK ........ A priority as upper case letter (at the beginning of the 77 | line) 78 | DATE TASK ............ An open task 79 | x DATE DATE TASK ..... A completed task (with completion date) 80 | indented tasks ..... A indented task is a subtask of the parent task; unless 81 | `has_subtasks` is true, |:Ttodo| will only show tasks 82 | with no open subtasks; this is similar to how the 83 | outline addon handles subtasks (see also 84 | https://github.com/samuelsnyder/outline-todo.txt) 85 | 86 | *ttodo-tags* 87 | A TASK may contain the following tags: 88 | *ttodo-@next* 89 | @list ............ a "list" tag 90 | NOTE: The is a special list `@next` that marks important 91 | task that should really be tackled next. 92 | +keyword ......... a "keyword" tag 93 | h:1 .............. hidden task 94 | due:YYYY-MM-DD ... due dates 95 | NOTE: If a task is member of the `@next` list, filters 96 | by due dates will be ignored 97 | rec:+Nx .......... When marking a task a "done", add a new task with a due 98 | date in N d(ays), w(eeks), m(onths), y(ears); with the 99 | leading '+' use the original due date; else use the 100 | completion date; this is similar to how the Simpletask 101 | Android app handles `rec` tags 102 | t:YYYY-MM-DD ..... Hide the tasks until the given date 103 | t:-Nd ............ Hide the tasks until N days before the due date 104 | id:ID ............ Define a tasks ID string (an ID should consist 105 | of alphanumeric characters only) 106 | dep:IDs .......... Depends on task with ID (if the other task is not 107 | completed yet, mark the current task as pending); 108 | IDs is a comma-separated list of IDs 109 | parent:ID ........ In outlines: the current task is the child of 110 | task with ID 111 | *ttodo-file-options* 112 | $TTODO$ OPTION:VALUE .. If a line matches `$TTODO$` it is assumed to 113 | contain a file-local option. Search the help file for 114 | `OPTION:` to see which options are available. Users will 115 | typically want to hide such lines using `h:1` 116 | 117 | If you set |g:ttodo_enable_ftdetect| to 0, you can use the |:Ttodo| command in 118 | conjunction with other syntax files/ftplugins such as: 119 | 120 | - https://github.com/freitass/todo.txt-vim 121 | - todo-txt.vim : Vim plugin for Todo.txt 122 | https://github.com/dbeniamine/todo.txt-vim or 123 | http://www.vim.org/scripts/script.php?script_id=5134 124 | - https://github.com/mivok/vimtodo or 125 | http://www.vim.org/scripts/script.php?script_id=3264 126 | - https://github.com/davidoc/todo.txt-vim 127 | - My fork: https://github.com/tomtom/todo.txt-vim-1 128 | - https://github.com/dsiroky/vim-todotxt 129 | - ... 130 | 131 | Related work: 132 | - https://github.com/elentok/todo.vim 133 | 134 | 135 | ----------------------------------------------------------------------- 136 | Install~ 137 | 138 | To install the vimball, edit the vba file and type: > 139 | 140 | :so % 141 | 142 | See :help vimball for details. 143 | 144 | To install from github, please use 145 | 1. git + a plugin loader like enable_vim, pathogen, vim-unbundle etc. 146 | 2. a plugin manager like VAM, Vundle, NeoBundle, vim-plug etc. 147 | 148 | The tlib_vim plugin is required: 149 | https://github.com/tomtom/tlib_vim 150 | 151 | Optional enhancement: 152 | - https://github.com/tomtom/autolinker_vim for hyperlinking 153 | 154 | Also available via git: http://github.com/tomtom/ttodo_vim 155 | 156 | 157 | Setup~ 158 | 159 | Please set |g:ttodo#dirs| in |vimrc| before using |:Ttodo|. 160 | 161 | 162 | 163 | 164 | Dependencies: 165 | tlib (>= 1.26) :: http://github.com/tomtom/tlib_vim 166 | 167 | License: GPLv3 or later 168 | 169 | 170 | -------------------------------------------------------------------------------- /addon-info.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "ttodo", 3 | "version" : "dev", 4 | "author" : "Tom Link ", 5 | "maintainer" : "Tom Link ", 6 | "repository" : {"type": "git", "url": "git://github.com/tomtom/ttodo_vim.git"}, 7 | "dependencies" : { 8 | "tlib": {"type": "git", "url": "git://github.com/tomtom/tlib_vim.git"} 9 | }, 10 | "description" : "Edit, view, sort, and filter todo.txt files" 11 | } 12 | -------------------------------------------------------------------------------- /autoload/tcomment/types/ttodo.vim: -------------------------------------------------------------------------------- 1 | " @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) 2 | " @Website: https://github.com/tomtom 3 | " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) 4 | " @Last Change: 2018-12-31 5 | " @Revision: 4 6 | 7 | if g:loaded_tcomment < 400 8 | call tcomment#DefineType('ttodo', 'x '. strftime(g:tlib#date#date_format) .' %s') 9 | else 10 | call tcomment#type#Define('ttodo', 'h:1 %s') 11 | endif 12 | 13 | -------------------------------------------------------------------------------- /autoload/ttodo.vim: -------------------------------------------------------------------------------- 1 | " @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) 2 | " @Website: https://github.com/tomtom 3 | " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) 4 | " @Last Change: 2019-04-23 5 | " @Revision: 1438 6 | 7 | 8 | if !exists('g:loaded_tlib') || g:loaded_tlib < 126 9 | runtime plugin/tlib.vim 10 | if !exists('g:loaded_tlib') || g:loaded_tlib < 126 11 | echoerr 'tlib >= 1.26 is required -- http://bit.ly/tlib_vim' 12 | finish 13 | endif 14 | endif 15 | 16 | 17 | if !exists('g:ttodo#dirs') 18 | " A list of directories containing todo.txt files. An item in this 19 | " list can be either: 20 | " - a directory as string 21 | " - a list of [directory, options] 22 | " - a dictionary of {'dir': directory, 'opts': options} 23 | " 24 | " Options is a dictionary that may contain the following keys: 25 | " 26 | " lists: LIST OF STRINGS .... Additional lists 27 | " tags: LIST OF STRINGS ..... Additional tags 28 | " inbox: BASENAME ........... Basename for new tasks (see 29 | " |g:ttodo#inbox|) 30 | " inboxfile: FILENAME ....... Full filename for new tasks 31 | " file_pattern: GLOB ........ See |g:ttodo#file_pattern| 32 | " file_include_rx: REGEXP ... See |g:ttodo#file_include_rx| 33 | " file_exclude_rx: REGEXP ... See |g:ttodo#file_exclude_rx| 34 | " encoding: ENC ............. If ENC != 'enc', then the file 35 | " contents will be transcoded with 36 | " |iconv()| 37 | " 38 | " |g:ttodo#fileargs| provides an alternative way to define 39 | " file-specific options. 40 | " 41 | " If the todotxt plugin is used, |g:todotxt#dir| is added to the 42 | " list. 43 | " 44 | " Changes to this variable will have an effect only after restart. 45 | let g:ttodo#dirs = [] 46 | endif 47 | 48 | 49 | if !exists('g:ttodo#fileargs') 50 | " A dictionary of {filename |regexp|: {additional args}} -- see 51 | " |g:ttodo#dirs| for details on supported arguments. 52 | let g:ttodo#fileargs = {} "{{{2 53 | endif 54 | 55 | 56 | if !exists('g:ttodo#file_pattern') 57 | " A glob pattern matching todo.txt files. 58 | let g:ttodo#file_pattern = ['*todo.txt', '*TODO.TXT'] "{{{2 59 | endif 60 | 61 | 62 | if !exists('g:ttodo#force_filetype') 63 | " By default, |ttodo#FiletypeDetect()| uses |:setf| to set the 64 | " filetype. This only works, if there isn't already a filetype 65 | " assigned to the buffer. 66 | " 67 | " If true, ttodo will make sure the filetype is `ttodo` by using 68 | " |:set| to set 'filetype'. 69 | let g:ttodo#force_filetype = 1 "{{{2 70 | endif 71 | 72 | 73 | if !exists('g:ttodo#file_include_rx') 74 | " Consider only files matching this |regexp|. 75 | let g:ttodo#file_include_rx = '' "{{{2 76 | endif 77 | 78 | 79 | if !exists('g:ttodo#file_exclude_rx') 80 | " Ignore files matching this |regexp|. 81 | let g:ttodo#file_exclude_rx = '[\/]done\.txt$' "{{{2 82 | endif 83 | 84 | 85 | if !exists('g:ttodo#task_include_rx') 86 | " Include only tasks matching this |regexp| in the list. 87 | let g:ttodo#task_include_rx = '' "{{{2 88 | endif 89 | 90 | 91 | if !exists('g:ttodo#task_exclude_rx') 92 | " Exclude tasks matching this |regexp| from the list. 93 | let g:ttodo#task_exclude_rx = '' "{{{2 94 | endif 95 | 96 | 97 | if !exists('g:ttodo#task_hide_rx') 98 | let g:ttodo#task_hide_rx = '' "{{{2 99 | endif 100 | 101 | 102 | if !exists('g:ttodo#viewer') 103 | " Supported values: 104 | " tlib ...... Use the tlib_vim plugin; the syntax of |:Ttodo|'s 105 | " initial filter depends on the value of 106 | " |g:tlib#input#filter_mode| 107 | " :COMMAND .. E.g. `:cwindow` or `:CtrlPQuickfix`. In this case 108 | " initial filter is a standard |regexp|. 109 | let g:ttodo#viewer = 'tlib' "{{{2 110 | endif 111 | 112 | 113 | if !exists('g:ttodo#sort') 114 | " A comma-separated list of fields that determine the sort order for 115 | " |:Ttodo| and |:Ttodosort|. 116 | " 117 | " A "-" as prefix reverses the sort order. 118 | let g:ttodo#sort = '-next,-overdue,pri,due,done,lists,tags,idx' "{{{2 119 | endif 120 | 121 | 122 | if !exists('g:ttodo#sort_defaults') 123 | " :nodoc: 124 | let g:ttodo#sort_defaults = { 125 | \ 'pri': 'I', 126 | \ 'overdue': 0, 127 | \ 'next': 0, 128 | \ 'due': strftime(g:tlib#date#date_format, localtime() + g:tlib#date#dayshift * 28), 129 | \ } 130 | endif 131 | 132 | 133 | if !exists('g:ttodo#prefs') 134 | " A dictionary of configurations that can be invoked with the 135 | " `--pref=NAME` command line option from |:Ttodo|. 136 | " 137 | " If no preference is given, "default" is used. 138 | let g:ttodo#prefs = {'default': {'ignore_pri': 'X-Z'}, 'important': {'undated': 1, 'due': '1w', 'pri': 'A-C', 'ignore_lists': ['someday', 'maybe']}} "{{{2 139 | if exists('g:ttodo#prefs_user') 140 | let g:ttodo#prefs = tlib#eval#Extend(g:ttodo#prefs, g:ttodo#prefs_user) 141 | endif 142 | endif 143 | 144 | 145 | if !exists('g:ttodo#default_t') 146 | " If a task has no threshold date defined, assign this default threshold date. 147 | let g:ttodo#default_t = '-31d' "{{{2 148 | endif 149 | 150 | 151 | if !exists('g:ttodo#parse_rx') 152 | ":nodoc: 153 | let g:ttodo#parse_rx = { 154 | \ 'id': '\', 160 | \ 't': '\', 161 | \ 'pri': '^\s*(\zs\u\ze)', 162 | \ 'hidden?': '\%(\\|'. g:ttodo#task_hide_rx .'\)', 163 | \ 'done?': '^\C\s*x\ze\s', 164 | \ 'donedate': '^\Cx\s\+\zs'. g:tlib#date#date_rx, 165 | \ 'notes+': '\', 167 | \ } 168 | endif 169 | if exists('g:ttodo#parse_rx_user') 170 | call extend(g:ttodo#parse_rx, g:ttodo#parse_rx_user) 171 | endif 172 | 173 | 174 | if !exists('g:ttodo#rewrite_gsub') 175 | ":nodoc: 176 | let g:ttodo#rewrite_gsub = [ 177 | \ ['^\C\%((\u)\s\+\)\?\zs'. g:tlib#date#date_rx .'\s*', ''], 178 | \ ['\%(^\|\s\+\)\%(id\|parent\|t\):\S\+', ''], 179 | \ ] 180 | endif 181 | if exists('g:ttodo#rewrite_gsub_user') 182 | call extend(g:ttodo#rewrite_gsub, g:ttodo#rewrite_gsub_user) 183 | endif 184 | 185 | 186 | if !exists('g:ttodo#mapleader') 187 | let g:ttodo#mapleader = 't' "{{{2 188 | endif 189 | 190 | 191 | if !exists('g:ttodo#new_task') 192 | " Defintion for tasks added via |:Ttodonew|. 193 | let g:ttodo#new_task = {'lists': ['Inbox'], 'pri': 'C'} "{{{2 194 | endif 195 | 196 | 197 | if !exists('g:ttodo#inbox') 198 | " A file basename (no directory). 199 | " 200 | " Tasks added by |:Ttodonew| will be added to this file in the 201 | " default (i.e. the first) directory in |g:ttodo#dirs|. 202 | let g:ttodo#inbox = 'todo.txt' "{{{2 203 | endif 204 | 205 | 206 | if !exists('g:ttodo#qfl_short_filename') 207 | " Possible values: "basename", "shorten", "" 208 | let g:ttodo#qfl_short_filename = 'basename' "{{{2 209 | endif 210 | 211 | 212 | call tlib#type#Define('ttodo_type_itemdef_opts', {'__name__': 's', '__rx__': 's'}) 213 | 214 | 215 | let s:list_env = { 216 | \ 'qfl_short_filename': g:ttodo#qfl_short_filename, 217 | \ 'qfl_list_syntax': 'ttodo', 218 | \ 'qfl_list_syntax_nextgroup': '@TtodoTask', 219 | \ 'set_syntax': 'ttodo#InitListBuffer', 220 | \ 'pick_last_item': 0, 221 | \ 'scratch': '__Ttodo__', 222 | \ } 223 | 224 | let s:list_env['key_map'] = { 225 | \ 'default': { 226 | \ 24 : {'key': 24, 'agent': 'ttodo#ftplugin#Agent', 'args': ['ttodo#ftplugin#MarkDone', 0], 'key_name': '', 'help': 'Mark done'}, 227 | \ 4 : {'key': 4, 'agent': 'ttodo#ftplugin#Agent', 'args': ['ttodo#ftplugin#MarkDue', 'd', '\=ttodo#InputNumber("Number of days: ")'], 'key_name': '', 'help': 'Mark as due in N days'}, 228 | \ 23 : {'key': 23, 'agent': 'ttodo#ftplugin#Agent', 'args': ['ttodo#ftplugin#MarkDue', 'w', '\=ttodo#InputNumber("Number of weeks: ")'], 'key_name': '', 'help': 'Mark as due in N weeks'}, 229 | \ 25 : {'key': 25, 'agent': 'ttodo#ftplugin#Agent', 'args': ['ttodo#ftplugin#SetPriority', 0, '\=tlib#string#Input("New task category [A-Z]: ")'], 'key_name': '', 'help': 'Change task category'}, 230 | \ } 231 | \ } 232 | 233 | if exists('g:ttodo#world_user') 234 | let s:list_env = tlib#eval#Extend(s:list_env, g:ttodo#world_user) 235 | endif 236 | 237 | 238 | let s:ttodo_dirs = {} 239 | 240 | 241 | function! ttodo#GetDirs() abort "{{{3 242 | return s:ttodo_dirs 243 | endf 244 | 245 | 246 | function! s:GetOpt(opts, name) abort "{{{3 247 | return get(a:opts, a:name, g:ttodo#{a:name}) 248 | endf 249 | 250 | 251 | " :display: s:ItemDef(var, item, ?opts={}) 252 | " Register a new directory with todo.txt files. The first directory is 253 | " the default directory for |g:ttodo#inbox|. 254 | function! s:ItemDef(item, first) abort "{{{3 255 | Tlibtrace 'ttodo', a:item, a:first 256 | if type(a:item) == 1 257 | let item = a:item 258 | let opts = {} 259 | elseif type(a:item) == 3 260 | let [item, opts] = a:item 261 | elseif type(a:item) == 4 262 | let item = get(a:item, 'file', get(a:item, 'dir', '')) 263 | if empty(item) 264 | throw 'Ttodo: No item: '. string(a:item) 265 | endif 266 | let opts = get(a:item, 'opts', {}) 267 | else 268 | throw 'Ttodo: Unsupported value for g:ttodo#dirs: '. string(g:ttodo#dirs) 269 | endif 270 | Tlibtrace 'ttodo', item, keys(opts) 271 | if a:first 272 | let opts.default = 1 273 | endif 274 | let opts.__name__ = item 275 | let opts.__rx__ = '\V\^'. join(map(split(item, '[\/]', 1), 'tlib#rx#Escape(v:val, "V")'), '[\\/]') 276 | Tlibassert tlib#type#Has(opts, 'ttodo_type_itemdef_opts') 277 | return {item : opts} 278 | endf 279 | 280 | 281 | function! s:ItemsDefs(items, first) abort "{{{3 282 | let itemsdefs = {} 283 | let i = 0 284 | for item in a:items 285 | call extend(itemsdefs, s:ItemDef(item, a:first && i == 0)) 286 | let i += 1 287 | endfor 288 | return itemsdefs 289 | endf 290 | 291 | 292 | if !empty(g:ttodo#dirs) 293 | call extend(s:ttodo_dirs, s:ItemsDefs(g:ttodo#dirs, empty(s:ttodo_dirs))) 294 | endif 295 | 296 | 297 | if exists('g:todotxt#dir') 298 | call extend(s:ttodo_dirs, s:ItemDef(g:todotxt#dir, empty(s:ttodo_dirs))) 299 | endif 300 | 301 | 302 | function! s:GetDefaultDirDef(args, default) abort "{{{3 303 | Tlibtrace 'ttodo', a:args, a:default 304 | let dirsdefs = s:GetDirsDefs(a:args) 305 | Tlibtrace 'ttodo', dirsdefs 306 | let default_dirs = filter(copy(dirsdefs), 'get(v:val, "default", 0)') 307 | Tlibtrace 'ttodo', keys(default_dirs) 308 | if empty(default_dirs) 309 | return {'__name__': a:default} 310 | else 311 | return default_dirs[keys(default_dirs)[0]] 312 | endif 313 | endf 314 | 315 | 316 | let s:ttodo_args = { 317 | \ 'help': ':Ttodo', 318 | \ 'handle_exit_code': 1, 319 | \ 'values': { 320 | \ 'bufname': {'type': 1}, 321 | \ 'bufnr': {'type': 1}, 322 | \ 'done': {'type': -1}, 323 | \ 'due': {'type': 1, 'validate': 'ttodo#IsValidDue'}, 324 | \ 'encoding': {'type': 1}, 325 | \ 'file_exclude_rx': {'type': 1}, 326 | \ 'file_include_rx': {'type': 1}, 327 | \ 'hidden': {'type': -1}, 328 | \ 'inbox': {'type': 1}, 329 | \ 'pending': {'type': -1}, 330 | \ 'has_subtasks': {'type': -1}, 331 | \ 'has_lists': {'type': 3, 'complete_customlist': 'ttodo#CollectTags("lists")'}, 332 | \ 'ignore_lists': {'type': 3, 'complete_customlist': 'ttodo#CollectTags("lists")'}, 333 | \ 'has_tags': {'type': 3, 'complete_customlist': 'ttodo#CollectTags("tags")'}, 334 | \ 'ignore_tags': {'type': 3, 'complete_customlist': 'ttodo#CollectTags("tags")'}, 335 | \ 'lists': {'type': 3, 'complete_customlist': 'ttodo#CollectTags("lists")'}, 336 | \ 'tags': {'type': 3, 'complete_customlist': 'ttodo#CollectTags("tags")'}, 337 | \ 'sortseps': {'type': 3, 'complete_customlist': '["lists", "tags"]'}, 338 | \ 'files': {'type': 3, 'complete': 'files'}, 339 | \ 'dirs': {'type': 3, 'complete': 'dirs'}, 340 | \ 'path': {'type': 1, 'complete': 'dirs'}, 341 | \ 'pref': {'type': 1, 'complete_customlist': 'keys(g:ttodo#prefs)'}, 342 | \ 'pri': {'type': 1, 'complete_customlist': '["", "A-", "A-C", "A-Z", "X-Z"]'}, 343 | \ 'ignore_pri': {'type': 1, 'complete_customlist': '["", "X-Z"]'}, 344 | \ 'sort': {'type': 1, 'complete_customlist': 'map(keys(g:ttodo#parse_rx), "substitute(v:val, ''\\W$'', '''', ''g'')")'}, 345 | \ 'task_exclude_rx': {'type': 1}, 346 | \ 'task_include_rx': {'type': 1}, 347 | \ 'undated': {'type': -1}, 348 | \ 'threshold': {'type': -1}, 349 | \ }, 350 | \ 'flags': { 351 | \ 'A': '--file_include_rx', 'R': '--file_exclude_rx', 352 | \ 'i': '--task_include_rx', 'x': '--task_exclude_rx', 353 | \ }, 354 | \ } 355 | 356 | 357 | function! s:GetFiles(args) abort "{{{3 358 | let bufname = get(a:args, 'bufname', '') 359 | let filedefs = [] 360 | Tlibtrace 'ttodo', 1, filedefs 361 | if !empty(bufname) 362 | call add(filedefs, {'fileargs': {}, 'file': bufname(bufname)}) 363 | Tlibtrace 'ttodo', 2, filedefs 364 | else 365 | let bufnr = get(a:args, 'bufnr', '') 366 | if !empty(bufnr) 367 | let bufnrs = tlib#string#SplitCommaList(bufnr) 368 | let files = map(bufnrs, 'bufname(str2nr(v:val))') 369 | for file in files 370 | call add(filedefs, {'fileargs': {}, 'file': file}) 371 | endfor 372 | Tlibtrace 'ttodo', 3, filedefs 373 | else 374 | if has_key(a:args, 'files') 375 | let files0 = filter(copy(a:args.files), 'filereadable(v:val)') 376 | let files = s:ItemsDefs(files0, 1) 377 | call extend(filedefs, map(items(files), '{"fileargs": v:val[1], "file": v:val[0]}')) 378 | Tlibtrace 'ttodo', 4, filedefs 379 | else 380 | let dirsdefs = s:GetDirsDefs(a:args) 381 | for [dir, dirargs] in items(dirsdefs) 382 | Tlibtrace 'ttodo', dir, keys(dirargs) 383 | let pattern0 = get(a:args, 'pattern', s:GetOpt(dirargs, 'file_pattern')) 384 | Tlibtrace 'ttodo', pattern0 385 | let patterns = type(pattern0) == v:t_string ? [pattern0] : pattern0 386 | let ffiles = map(copy(patterns), 'tlib#file#Glob(tlib#file#Join([dir, v:val]))') 387 | let files = tlib#list#Uniq(tlib#list#Flatten(ffiles)) 388 | let file_include_rx = get(a:args, 'file_include_rx', s:GetOpt(a:args, 'file_include_rx')) 389 | if !empty(file_include_rx) 390 | let files = filter(files, 'v:val =~# file_include_rx') 391 | endif 392 | let file_exclude_rx = get(a:args, 'file_exclude_rx', s:GetOpt(a:args, 'file_exclude_rx')) 393 | if !empty(file_exclude_rx) 394 | let files = filter(files, 'v:val !~# file_exclude_rx') 395 | for file in files 396 | call add(filedefs, {'fileargs': dirargs, 'file': file}) 397 | endfor 398 | endif 399 | endfor 400 | Tlibtrace 'ttodo', 5, filedefs 401 | endif 402 | endif 403 | endif 404 | Tlibtrace 'ttodo', filedefs 405 | let filedefs = map(filedefs, 's:EnrichWithFileargs(v:val)') 406 | Tlibtrace 'ttodo', len(filedefs) 407 | Tlibassert tlib#type#Are(copy(filedefs), 'dict') 408 | Tlibassert tlib#type#Have(copy(filedefs), ['fileargs', 'file']) 409 | return filedefs 410 | endf 411 | 412 | 413 | function! s:GetDirsDefs(args) abort "{{{3 414 | let dirs = s:GetDirs(a:args) 415 | if empty(dirs) 416 | throw 'TTodo: Please set dirs via g:ttodo#dirs' 417 | endif 418 | let dirsdefs = s:ItemsDefs(dirs, 1) 419 | return dirsdefs 420 | endf 421 | 422 | 423 | function! s:GetDirs(args) abort "{{{3 424 | if has_key(a:args, 'path') 425 | let dirs = tlib#string#SplitCommaList(a:args.path) 426 | elseif has_key(a:args, 'dirs') 427 | let dirs = a:args.dirs 428 | else 429 | let dirs = keys(s:ttodo_dirs) 430 | endif 431 | return dirs 432 | endf 433 | 434 | 435 | function! s:EnrichWithFileargs(filedef) abort "{{{3 436 | Tlibtrace 'ttodo', a:filedef 437 | let filename = a:filedef.file 438 | for [rx, fileargs] in items(g:ttodo#fileargs) 439 | Tlibtrace 'ttodo', rx 440 | if filename =~# rx 441 | Tlibtrace 'ttodo', fileargs 442 | let a:filedef.fileargs = tlib#eval#Extend(copy(a:filedef.fileargs), fileargs) 443 | Tlibtrace 'ttodo', a:filedef.fileargs 444 | endif 445 | endfor 446 | return a:filedef 447 | endf 448 | 449 | 450 | let s:filetasks = {} 451 | 452 | function! s:filetasks.GetQfeByLnum(lnum) abort dict "{{{3 453 | return get(self.qfe_by_lnum, ''. a:lnum, {}) 454 | " for qfe in self.qfl 455 | " if qfe.lnum == a:lnum 456 | " return qfe 457 | " endif 458 | " endfor 459 | " return {} 460 | endf 461 | 462 | 463 | ":nodoc: 464 | function! ttodo#GetFileTasks(args, file, fileargs) abort "{{{3 465 | Tlibtrace 'ttodo', a:file, keys(a:fileargs) 466 | let qfl = [] 467 | let task_by_id = {} 468 | let qfe_by_lnum = {} 469 | let children = {} 470 | let lnum = 0 471 | let pred_idx = -1 472 | let filelines = s:GetLines(a:file, a:fileargs) 473 | let s:file_options[a:file] = {} 474 | let source = filelines.source 475 | for line in filelines.lines 476 | let lnum += 1 477 | if line =~ '\S' 478 | let task = ttodo#ParseTask(line, a:file, a:args) 479 | if !empty(task) 480 | let id = get(task, 'id', '') 481 | let task.__source__ = source 482 | Tlibtrace 'ttodo', task 483 | if get(task, 'subtask', 0) && pred_idx >= 0 484 | let indentstr = matchstr(line, '^\%(\s\{1,'. &shiftwidth .'}\)\+') 485 | Tlibtrace 'ttodo', indentstr 486 | let indentstr = substitute(indentstr, '\%(\s\{1,'. &shiftwidth .'}\)', '+', 'g') 487 | let indent = len(indentstr) 488 | Tlibtrace 'ttodo', indentstr, indent 489 | let line = substitute(line, '^\s\+', '', '') 490 | let parent_idx = pred_idx 491 | let parent = qfl[parent_idx] 492 | Tlibtrace 'ttodo', parent 493 | while get(parent.task, '__indent__', 0) >= indent 494 | let parent_idx = parent.task.__parent_idx__ 495 | let parent = qfl[parent_idx] 496 | endwh 497 | let parent_indent = get(parent.task, '__indent__', 0) 498 | Tlibtrace 'ttodo', indent, parent_indent, parent_idx, parent 499 | if !task.done 500 | " let parent.task.has_subtasks = get(parent.task, 'has_subtasks', 0) + 1 501 | let parent.task.has_subtasks = 1 502 | Tlibtrace 'ttodo', parent, parent_idx, pred_idx 503 | let qfl[parent_idx] = parent 504 | endif 505 | if has_key(task, 'due') && task.due > get(parent.task, 'due', task.due) 506 | echohl WarningMsg 507 | echom 'WARN ttodo#GetFileTasks: subtask has due date after the parent''s task due date: '. line 508 | echohl NONE 509 | endif 510 | let task0 = task 511 | let task = tlib#eval#Extend(copy(parent.task), task) 512 | let task.has_subtasks = 0 513 | let task.__level__ = get(parent.task, '__level__', 0) + 1 514 | let task.__indent__ = indent 515 | let task.__parent_idx__ = parent_idx 516 | if !has_key(children, parent_idx) 517 | let children[parent_idx] = {} 518 | endif 519 | let children[parent_idx][pred_idx + 1] = 1 520 | Tlibtrace 'ttodo', task, qfl[parent_idx] 521 | let line .= ' | '. substitute(s:FormatTask(a:args, copy(parent), 0).text, '^\C\s*\%(x\s\+\)\?\%((\u)\s\+\)\?', '', '') 522 | if has_key(parent.task, 'pri') && !has_key(task0, 'pri') 523 | Tlibtrace 'ttodo', task0 524 | let line = '('. parent.task.pri .') '. line 525 | endif 526 | Tlibtrace 'ttodo', line 527 | else 528 | Tlibtrace 'ttodo', line 529 | for [prefix, key] in [['@', 'lists'], ['+', 'tags']] 530 | if has_key(a:fileargs, key) 531 | let vals = a:fileargs[key] 532 | let task[key] += vals 533 | let line = ttodo#MaybeAppend(line, ttodo#FormatTags(prefix, vals)) 534 | endif 535 | endfor 536 | Tlibtrace 'ttodo', line 537 | endif 538 | let pred_idx += 1 539 | let task.idx = pred_idx 540 | let qfe = {'filename': a:file, 'lnum': lnum, 'text': line, 'task': task} 541 | call add(qfl, qfe) 542 | if !empty(id) 543 | let task_by_id[id] = task 544 | endif 545 | let qfe_by_lnum[lnum] = qfe 546 | endif 547 | endif 548 | endfor 549 | let qfl = map(qfl, 's:SetPending(v:key, v:val, task_by_id)') 550 | let filetasks = extend({'qfl': qfl, 'task_by_id': task_by_id, 'qfe_by_lnum': qfe_by_lnum}, s:filetasks) 551 | return filetasks 552 | endf 553 | 554 | 555 | function! s:SetPending(idx, qfe, task_by_id) abort "{{{3 556 | let deps = get(a:qfe.task, 'dep', '') 557 | if !empty(deps) 558 | for dep in tlib#string#SplitCommaList(deps) 559 | if has_key(a:task_by_id, dep) 560 | let done = get(a:task_by_id[dep], 'done', 1) 561 | if !done 562 | let a:qfe.task.pending = 1 563 | Tlibtrace 'ttodo', a:idx, done 564 | break 565 | endif 566 | endif 567 | endfor 568 | endif 569 | return a:qfe 570 | endf 571 | 572 | 573 | function! s:GetLines(filename, fileargs) abort "{{{3 574 | let bufnr = bufnr(a:filename) 575 | if bufnr == -1 || !bufloaded(bufnr) 576 | if !filereadable(a:filename) 577 | echoerr 'TTODO: File not readable:' a:filename 578 | let lines = [] 579 | else 580 | let lines = readfile(a:filename) 581 | if has('iconv') 582 | Tlibtrace 'ttodo', keys(a:fileargs) 583 | let tenc = get(a:fileargs, 'encoding', &encoding) 584 | Tlibtrace 'ttodo', tenc, &enc 585 | if tenc != &encoding 586 | let lines = map(lines, 'iconv(v:val, tenc, &encoding)') 587 | endif 588 | endif 589 | endif 590 | return {'source': 'file', 'lines': lines} 591 | else 592 | return {'source': 'buffer', 'lines': getbufline(bufnr, 1, '$')} 593 | endif 594 | endf 595 | 596 | 597 | function! s:GetTasks(args) abort "{{{3 598 | let qfl = [] 599 | for filedef in s:GetFiles(a:args) 600 | Tlibtrace 'ttodo', filedef 601 | let filetasks = ttodo#GetFileTasks(a:args, filedef.file, filedef.fileargs) 602 | if !empty(filetasks) 603 | let qfl = extend(qfl, filetasks.qfl) 604 | endif 605 | endfor 606 | return qfl 607 | endf 608 | 609 | 610 | let s:parsed_tasks = {} 611 | let s:file_options = {} 612 | 613 | 614 | function! ttodo#GetOption(name, default, ...) abort "{{{3 615 | let filename = tlib#file#Canonic(a:0 >= 1 ? a:1 : expand('%:p')) 616 | let options = get(s:file_options, filename, {}) 617 | return get(options, a:name, a:default) 618 | endf 619 | 620 | 621 | function! ttodo#ParseTask(line, file, ...) abort "{{{3 622 | TVarArg ['args', {}] 623 | if a:line !~# '\S' 624 | return {} 625 | elseif a:line =~ '\(^\|\s\)\$TTODO\$\s' 626 | let oname = matchstr(a:line, '\(^\|\s\)\$TTODO\$\s\+\zs\w\+') 627 | let oval = matchstr(a:line, '\(^\|\s\)\$TTODO\$\s\+\w\+:\zs.*$') 628 | let s:file_options[tlib#file#Canonic(a:file)][oname] = oval 629 | else 630 | let cid = join([a:line, a:file, get(args, 'lists', []), get(args, 'tags', [])], "\n") 631 | if has_key(s:parsed_tasks, cid) 632 | Tlibtrace 'ttodo', cid 633 | let task = deepcopy(s:parsed_tasks[cid]) 634 | else 635 | let task = {'text': a:line} 636 | for [key, rx] in items(g:ttodo#parse_rx) 637 | if key =~# '+$' 638 | let key = substitute(key, '+$', '', '') 639 | if tlib#type#IsList(rx) 640 | let val = call('tlib#string#MatchAll', [a:line] + rx) 641 | else 642 | let val = tlib#string#MatchAll(a:line, rx) 643 | endif 644 | let task[key] = val 645 | else 646 | let val = matchstr(a:line, rx) 647 | if key =~# '?$' 648 | let key = substitute(key, '?$', '', '') 649 | let task[key] = !empty(val) 650 | elseif !empty(val) 651 | let task[key] = val 652 | endif 653 | endif 654 | unlet val 655 | endfor 656 | if has_key(task, 'due') 657 | Tlibtrace 'ttodo', task 658 | if task.due ==# 'today' 659 | let task.due = strftime(g:tlib#date#date_format) 660 | Tlibtrace 'ttodo', task.due 661 | endif 662 | if task.due < strftime(g:tlib#date#date_format) 663 | let task.overdue = 1 664 | endif 665 | endif 666 | let task.lists = filter(map(split(a:line, '\(^ \|\s\)\ze@'), 'matchstr(v:val, ''^@\zs\S\+'')'), '!empty(v:val)') + get(args, 'lists', []) 667 | let task.tags = filter(map(split(a:line, '\(^ \|\s\)\ze+'), 'matchstr(v:val, ''^+\zs\S\+'')'), '!empty(v:val)') + get(args, 'tags', []) 668 | if index(task.lists, 'next') != -1 669 | let task.next = 1 670 | endif 671 | let task.file = a:file 672 | let s:parsed_tasks[cid] = deepcopy(task) 673 | endif 674 | return task 675 | endif 676 | endf 677 | 678 | 679 | function! s:FilterTasks(args) abort "{{{3 680 | let qfl = s:GetTasks(a:args) 681 | let task_include_rx = get(a:args, 'task_include_rx', g:ttodo#task_include_rx) 682 | let task_exclude_rx = get(a:args, 'task_exclude_rx', g:ttodo#task_exclude_rx) 683 | let qfl = filter(qfl, '(empty(task_include_rx) || v:val.text =~ task_include_rx) && (empty(task_exclude_rx) || v:val.text !~ task_exclude_rx)') 684 | if has_key(a:args, 'due') 685 | let due = a:args.due 686 | let today = strftime(g:tlib#date#date_format) 687 | if due =~# '^t%\[oday]$' 688 | call filter(qfl, 'get(v:val.task, "next", 0) || empty(get(v:val.task, "due", "")) || get(v:val.task, "due", "") <= '. string(today)) 689 | elseif due =~# '^\d\+-\d\+-\d\+$' 690 | call filter(qfl, 'get(v:val.task, "next", 0) || empty(get(v:val.task, "due", "")) || get(v:val.task, "due", "") <= '. string(due)) 691 | else 692 | if due =~# '^\d\+w$' 693 | let due = matchstr(due, '^\d\+') * 7 694 | endif 695 | call filter(qfl, 'get(v:val.task, "next", 0) || empty(get(v:val.task, "due", "")) || tlib#date#DiffInDays(v:val.task.due) <= '. due) 696 | endif 697 | if !get(a:args, 'undated', 0) 698 | call filter(qfl, 'get(v:val.task, "next", 0) || !empty(get(v:val.task, "due", ""))') 699 | endif 700 | endif 701 | for lst in ['lists', 'tags'] 702 | let key = 'has_'. lst 703 | if has_key(a:args, key) 704 | let vals = a:args[key] 705 | call filter(qfl, 's:HasAnyList(v:val.task[lst], vals)') 706 | endif 707 | let ikey = 'ignore_'. lst 708 | if has_key(a:args, ikey) 709 | let vals = a:args[ikey] 710 | call filter(qfl, '!s:HasAnyList(v:val.task[lst], vals)') 711 | endif 712 | endfor 713 | if !get(a:args, 'has_subtasks', 0) 714 | call filter(qfl, 'get(v:val.task, "has_subtasks", 0) == 0') 715 | endif 716 | if !get(a:args, 'done', 0) 717 | call filter(qfl, '!get(v:val.task, "done", 0)') 718 | endif 719 | if !get(a:args, 'hidden', 0) 720 | call filter(qfl, 'empty(get(v:val.task, "hidden", ""))') 721 | endif 722 | if !get(a:args, 'pending', 0) 723 | call filter(qfl, '!get(v:val.task, "pending", 0)') 724 | endif 725 | if has_key(a:args, 'pri') 726 | call filter(qfl, 'get(v:val.task, "pri", "") =~# ''^['. a:args.pri .']$''') 727 | endif 728 | if has_key(a:args, 'ignore_pri') 729 | call filter(qfl, 'empty(get(v:val.task, "pri", "")) || get(v:val.task, "pri", "") !~# ''^['. a:args.ignore_pri .']$''') 730 | endif 731 | if get(a:args, 'threshold', 1) 732 | let today = strftime(g:tlib#date#date_format) 733 | call filter(qfl, 'get(v:val.task, "next", 0) || s:CheckThreshold(get(v:val.task, "t", ""), get(v:val.task, "due", ""), today)') 734 | endif 735 | return qfl 736 | endf 737 | 738 | 739 | function! s:HasAnyList(tags, vals) abort "{{{3 740 | Tlibtrace 'ttodo', a:tags, a:vals 741 | let rv = !empty(filter(copy(a:tags), 'index(a:vals, v:val) != -1')) 742 | Tlibtrace 'ttodo', rv 743 | return rv 744 | endf 745 | 746 | 747 | function! s:CheckThreshold(t, due, today) abort "{{{3 748 | Tlibtrace 'ttodo', a:t, a:due, a:today 749 | let t = 0 750 | let tn = '' 751 | if !empty(a:t) 752 | if a:t =~# '^'. g:tlib#date#date_rx .'$' 753 | let t = a:t 754 | elseif !empty(a:due) 755 | let tn = a:t 756 | endif 757 | else 758 | let tn = g:ttodo#default_t 759 | endif 760 | if t == 0 && !empty(tn) && !empty(a:due) 761 | let n = str2nr(matchstr(tn, '^-\?\d\+\ze[d]$')) 762 | if n != 0 763 | if tn =~# 'd$' 764 | let t = strftime(g:tlib#date#date_format, tlib#date#SecondsSince1970(a:due) + n * g:tlib#date#dayshift) 765 | endif 766 | endif 767 | endif 768 | Tlibtrace 'ttodo', tn, t 769 | if !empty(t) 770 | return a:today >= t 771 | else 772 | return 1 773 | endif 774 | endf 775 | 776 | 777 | let s:sort_params = {} 778 | 779 | 780 | function! s:sort_params.GetSortItem(qfe, task, item, default) abort dict "{{{3 781 | let val = get(a:task, a:item, get(a:qfe, a:item, a:default)) 782 | if type(val) > 1 783 | let tmp = val 784 | unlet val 785 | let val = string(tmp) 786 | unlet tmp 787 | endif 788 | return val 789 | endf 790 | 791 | 792 | " function! s:sort_params.GetSortTasks(a, b) abort dict "{{{3 793 | " let api = get(a:a, '__parent_idx__', -1) 794 | " let bpi = get(a:b, '__parent_idx__', -1) 795 | " while api != bpi 796 | " " let al = get(a:a, '__level__', 0) 797 | " " let bl = get(a:b, '__level__', 0) 798 | " endwh 799 | " return 800 | " endf 801 | 802 | 803 | function! s:SortTasks(args, qfl) abort "{{{3 804 | Tlibtrace 'ttodo', a:qfl 805 | let params = {'qfl': a:qfl, 'fields': tlib#string#SplitCommaList(get(a:args, 'sort', g:ttodo#sort))} 806 | let params = extend(params, s:sort_params, 'keep') 807 | let qfl = sort(a:qfl, 's:SortTask', params) 808 | return qfl 809 | endf 810 | 811 | 812 | function! s:SortTask(a, b) dict abort "{{{3 813 | let a = a:a.task 814 | let b = a:b.task 815 | for item in self.fields 816 | if item =~# '^-\S\+$' 817 | let mul = -1 818 | let item = substitute(item, '^-', '', '') 819 | else 820 | let mul = 1 821 | endif 822 | let default = get(g:ttodo#sort_defaults, item, '') 823 | let aa = self.GetSortItem(a:a, a, item, default) 824 | let bb = self.GetSortItem(a:b, b, item, default) 825 | if item ==# 'overdue' 826 | Tlibtrace 'ttodo', 'overdue', aa, bb, default, a, b 827 | endif 828 | if aa != bb 829 | return mul * (aa > bb ? 1 : -1) 830 | endif 831 | unlet aa bb default 832 | endfor 833 | return 0 834 | endf 835 | 836 | 837 | function! s:FormatTask(args, qfe, maybe_iconv) abort "{{{3 838 | Tlibtrace 'ttodo', a:qfe 839 | let text = a:qfe.text 840 | let text0 = text 841 | Tlibtrace 'ttodo', text0 842 | for [rx, subst] in g:ttodo#rewrite_gsub 843 | let text = substitute(text, rx, subst, 'g') 844 | Tlibtrace 'ttodo', rx, subst, text 845 | endfor 846 | if text !=# text0 847 | let qfe = copy(a:qfe) 848 | let qfe.text = text 849 | return qfe 850 | else 851 | return a:qfe 852 | endif 853 | endf 854 | 855 | 856 | function! ttodo#GetOpts(bang, cmdargs) abort "{{{3 857 | let args = tlib#arg#GetOpts(a:cmdargs, s:ttodo_args) 858 | let pref = get(args, 'pref', a:bang ? 'important' : 'default') 859 | Tlibtrace 'ttodo', pref 860 | let args = tlib#eval#Extend(copy(g:ttodo#prefs[pref]), args) 861 | Tlibtrace 'ttodo', keys(args) 862 | return args 863 | endf 864 | 865 | 866 | ":nodoc: 867 | function! ttodo#Show(bang, cmdargs) abort "{{{3 868 | let args = ttodo#GetOpts(a:bang, a:cmdargs) 869 | Tlibtrace 'ttodo', args 870 | if args.__exit__ 871 | return 872 | else 873 | let qfl = copy(s:FilterTasks(args)) 874 | let qfl = s:SortTasks(args, qfl) 875 | let qfl = map(qfl, 's:FormatTask(args, v:val, 1)') 876 | let flt = get(args, '__rest__', []) 877 | if !empty(qfl) 878 | if g:ttodo#viewer ==# 'tlib' 879 | let w = copy(s:list_env) 880 | if !empty(flt) 881 | Tlibtrace 'ttodo', flt 882 | let w.initial_filter = [[""], flt] 883 | endif 884 | let overdue_rx = s:QflOverdueRx(qfl) 885 | if !empty(overdue_rx) 886 | let w.overdue_rx = overdue_rx 887 | endif 888 | call tlib#qfl#QflList(qfl, w) 889 | elseif g:ttodo#viewer =~# '^:' 890 | if exists(g:ttodo#viewer) == 2 891 | if !empty(flt) 892 | let qfl = filter(qfl, 's:FilterQFL(v:val, flt)') 893 | endif 894 | call setqflist(qfl) 895 | exec g:ttodo#viewer 896 | endif 897 | else 898 | throw 'TTodo: Unsupported value for g:ttodo#viewer: '. string(g:ttodo#viewer) 899 | endif 900 | endif 901 | endif 902 | endf 903 | 904 | 905 | function! ttodo#GetOverdueRx(args) abort "{{{3 906 | let qfl = s:GetTasks(a:args) 907 | return s:QflOverdueRx(qfl) 908 | endf 909 | 910 | 911 | function! s:QflOverdueRx(qfl) abort "{{{3 912 | let overdue = filter(copy(a:qfl), 'get(v:val.task, "overdue", 0)') 913 | if !empty(overdue) 914 | return '\V\' 915 | else 916 | return '' 917 | endif 918 | endf 919 | 920 | 921 | function! ttodo#InitListBuffer() dict abort "{{{3 922 | call call('tlib#qfl#SetSyntax', [], self) 923 | if has_key(self, 'overdue_rx') 924 | Tlibtrace 'ttodo', self.overdue_rx 925 | exec 'syntax match TtodoOverdue /'. escape(self.overdue_rx, '/') .'/ contained containedin=TtodoTag' 926 | hi def link TtodoOverdue ErrorMsg 927 | syntax cluster TtodoTask add=TtodoOverdue 928 | endif 929 | endf 930 | 931 | 932 | function! s:FilterQFL(item, flts) abort "{{{3 933 | let text = a:item.text 934 | for flt in a:flts 935 | if text !~ flt 936 | return 0 937 | endif 938 | endfor 939 | return 1 940 | endf 941 | 942 | 943 | ":nodoc: 944 | function! ttodo#CComplete(ArgLead, CmdLine, CursorPos) abort "{{{3 945 | let words = tlib#arg#CComplete(s:ttodo_args, a:ArgLead) 946 | if !empty(a:ArgLead) 947 | let fn = exists('*strcharpart') ? 'strcharpart' : 'strpart' 948 | if a:ArgLead =~# '^--pref=' 949 | let words = keys(g:ttodo#prefs) 950 | let apref = substitute(a:ArgLead, '^--pref=', '', '') 951 | if !empty(apref) 952 | let nchar = len(apref) 953 | call filter(words, fn .'(v:val, 0, nchar) ==# apref') 954 | endif 955 | let words = map(words, '"--pref=". v:val') 956 | elseif a:ArgLead =~# '^@' 957 | let words = map(ttodo#CollectTags("lists"), '"@". v:val') 958 | let nchar = len(a:ArgLead) 959 | call filter(words, fn .'(v:val, 0, nchar) ==# a:ArgLead') 960 | elseif a:ArgLead =~# '^+' 961 | let words = map(ttodo#CollectTags("tags"), '"+". v:val') 962 | let nchar = len(a:ArgLead) 963 | call filter(words, fn .'(v:val, 0, nchar) ==# a:ArgLead') 964 | else 965 | let nchar = len(a:ArgLead) 966 | let texts = {} 967 | for task in s:GetTasks({}) 968 | for word in split(task.text, '\s\+') 969 | if call(fn, [word, 0, nchar]) ==# a:ArgLead 970 | let texts[word] = 1 971 | endif 972 | endfor 973 | endfor 974 | let words += sort(keys(texts)) 975 | endif 976 | endif 977 | return words 978 | endf 979 | 980 | 981 | function! ttodo#CollectTags(type) abort "{{{3 982 | let args = {} 983 | if &filetype ==# 'ttodo' 984 | let args.bufname = '%' 985 | endif 986 | let tasks = s:GetTasks(args) 987 | let tags = map(copy(tasks), 'v:val.task[a:type]') 988 | let tags = tlib#list#Flatten(tags) 989 | let tags = filter(tags, '!empty(v:val)') 990 | let tags = tlib#list#Uniq(tags) 991 | let tags = sort(tags) 992 | return tags 993 | endf 994 | 995 | 996 | function! ttodo#FiletypeDetect(...) abort "{{{3 997 | let filename = a:0 >= 1 ? a:1 : expand('%:p') 998 | Tlibtrace 'ttodo', filename 999 | let bdir = substitute(filename, '\\', '/', 'g') 1000 | let bdir = substitute(bdir, '/[^/]\+$', '', '') 1001 | let dirs = map(keys(s:ttodo_dirs), 'substitute(resolve(fnamemodify(v:val, ":p:h")), ''\\'', ''/'', ''g'')') 1002 | Tlibtrace 'ttodo', dirs, bdir 1003 | if index(dirs, bdir, 0, !has('fname_case')) != -1 1004 | Tlibtrace 'ttodo', g:ttodo#force_filetype, &filetype 1005 | if g:ttodo#force_filetype 1006 | setl filetype=ttodo 1007 | else 1008 | setf ttodo 1009 | endif 1010 | Tlibtrace 'ttodo', &filetype 1011 | endif 1012 | endf 1013 | 1014 | 1015 | " If called with --sortseps=tags,lists, an empty line is inserted after 1016 | " each main (i.e. first) list or tag. 1017 | " 1018 | " Sorting doesn't work for outlines, i.e. tasks with subtasks. 1019 | function! ttodo#SortBuffer(cmdargs) abort "{{{3 1020 | let args = ttodo#GetOpts(0, a:cmdargs) 1021 | let filename = expand('%:p') 1022 | let filetasks = ttodo#GetFileTasks(args, filename, {}) 1023 | let qfl = filetasks.qfl 1024 | if !empty(filter(copy(qfl), 'get(v:val.task, "subtask", 0)')) 1025 | throw 'ttodo#SortBuffer: Cannot sort task outlines!' 1026 | endif 1027 | let qfl = s:SortTasks(args, qfl) 1028 | let seps = get(args, 'sortseps', []) 1029 | Tlibtrace 'ttodo', seps 1030 | if empty(seps) 1031 | let tasks = map(qfl, 'v:val.task.text') 1032 | else 1033 | let tasks = [] 1034 | let last = {} 1035 | for qfe in qfl 1036 | for sep in seps 1037 | if !empty(last) && get(get(last.task, sep, []), 0, '') != get(get(qfe.task, sep, []), 0, '') 1038 | Tlibtrace 'ttodo', last, qfe 1039 | call add(tasks, '') 1040 | break 1041 | endif 1042 | endfor 1043 | call add(tasks, qfe.task.text) 1044 | let last = qfe 1045 | endfor 1046 | endif 1047 | let pos = getpos('.') 1048 | try 1049 | 1,$delete 1050 | call append(1, tasks) 1051 | 1delete 1052 | finally 1053 | call setpos('.', pos) 1054 | endtry 1055 | endf 1056 | 1057 | 1058 | function! ttodo#NewTask(cmdargs) abort "{{{3 1059 | let args = extend(copy(g:ttodo#new_task), ttodo#GetOpts(0, a:cmdargs)) 1060 | let filename = get(args, 'inboxfile', '') 1061 | if empty(filename) 1062 | let dirdef = s:GetDefaultDirDef(args, '.') 1063 | Tlibtrace 'ttodo', keys(dirdef), dirdef.__name__ 1064 | let filename = tlib#file#Join([dirdef.__name__, get(args, 'inbox', get(dirdef, 'inbox', g:ttodo#inbox))]) 1065 | endif 1066 | let text = join(args.__rest__) 1067 | let text = ttodo#MaybeAppend(text, get(args, 'suffix', '')) 1068 | let text = ttodo#MaybeAppend(text, ttodo#FormatTags('@', get(args, 'lists', []))) 1069 | let text = ttodo#MaybeAppend(text, ttodo#FormatTags('+', get(args, 'tags', []))) 1070 | let ttask = ttodo#ParseTask(text, filename) 1071 | if !empty(ttask) 1072 | let args = extend(args, ttask) 1073 | endif 1074 | exec 'tab drop' fnameescape(filename) 1075 | let text = substitute(text, '\C^\s*(\u)\s*', '', '') 1076 | exec 'norm!' ttodo#ftplugin#New('G', 0, 'n', args) . text 1077 | endf 1078 | 1079 | 1080 | function! ttodo#FormatTags(prefix, lists) abort "{{{3 1081 | Tlibtrace 'ttodo', a:prefix, a:lists 1082 | return join(map(copy(a:lists), 'a:prefix . v:val')) 1083 | endf 1084 | 1085 | 1086 | function! ttodo#MaybeAppend(text, suffix) abort "{{{3 1087 | if empty(a:suffix) 1088 | return a:text 1089 | elseif empty(a:text) 1090 | return a:suffix 1091 | else 1092 | return a:text .' '. a:suffix 1093 | endif 1094 | endf 1095 | 1096 | 1097 | function! ttodo#MaybePadRight(text) abort "{{{3 1098 | if empty(a:text) 1099 | return a:text 1100 | else 1101 | return a:text .' ' 1102 | endif 1103 | endf 1104 | 1105 | 1106 | function! ttodo#MaybeSetPriority(text, priority) abort "{{{3 1107 | if empty(a:priority) 1108 | return a:text 1109 | else 1110 | return substitute(a:text, '^\s*\zs\((\u)\s\+\)\?', '('. a:priority .') ', '') 1111 | endif 1112 | endf 1113 | 1114 | 1115 | function! ttodo#FileSources(args) abort "{{{3 1116 | Tlibtrace 'ttodo', a:args 1117 | let args = a:args 1118 | let pref = get(args, 'pref', 'default') 1119 | Tlibtrace 'ttodo', pref 1120 | let args = tlib#eval#Extend(copy(g:ttodo#prefs[pref]), args) 1121 | let pattern = get(args, 'glob', get(args, 'deep', 1) ? '**' : '*') 1122 | let globs = {} 1123 | let dirsdefs = s:GetDirsDefs(args) 1124 | for [dir, dirargs] in items(dirsdefs) 1125 | let glob = tlib#file#Join([dir, pattern]) 1126 | Tlibtrace 'ttodo', glob 1127 | let globs[glob] = 1 1128 | endfor 1129 | return keys(globs) 1130 | endf 1131 | 1132 | 1133 | function! ttodo#InputNumber(prompt, ...) abort "{{{3 1134 | let default = a:0 >= 1 ? a:1 : -1 1135 | let s = tlib#string#Input(a:prompt) 1136 | return empty(s) ? default : str2nr(s) 1137 | endf 1138 | 1139 | 1140 | " :nodoc: 1141 | function! ttodo#IsValidDue(due) abort "{{{3 1142 | return a:due =~# '^\%(today\|[0-9]\+[dwmy]\)$' || tlib#date#IsDate(a:due) 1143 | endf 1144 | 1145 | 1146 | function! ttodo#SetCreateDate(line, ...) abort "{{{3 1147 | let cdate = a:0 >= 1 ? a:1 : tlib#date#Format() 1148 | let line = substitute(a:line, '^\s*\%((\u)\s\+\)\zs'. g:tlib#date#date_rx, cdate, '') 1149 | Tlibtrace 'ttodo', cdate, a:line, line 1150 | return line 1151 | endf 1152 | 1153 | -------------------------------------------------------------------------------- /autoload/ttodo/ftplugin.vim: -------------------------------------------------------------------------------- 1 | " @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) 2 | " @Website: https://github.com/tomtom 3 | " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) 4 | " @Last Change: 2024-01-30 5 | " @Revision: 527 6 | 7 | 8 | if !exists('g:ttodo#ftplugin#id_version') 9 | " If 1, use IDs based on Adler32 (see |tlib#hash#Adler32()|) of the 10 | " string representation of the internal structure representing a 11 | " task. 12 | " If 2, use IDs based on |reltime()|. 13 | " If 3, use IDs based on |rand()|. 14 | let g:ttodo#ftplugin#id_version = v:version < 800 || !has('reltime') ? 1 : 2 "{{{2 15 | endif 16 | 17 | 18 | if !exists('g:ttodo#ftplugin#id_suffix') 19 | " Add this suffix to the value used for generating the ID. 20 | " If |g:ttodo#ftplugin#id_version| is 2, this must evaluate to a numeric value. 21 | " This could be used to insert user IDs etc. 22 | let g:ttodo#ftplugin#id_suffix = '' "{{{2 23 | endif 24 | 25 | 26 | if !exists('g:ttodo#ftplugin#notefmt') 27 | if exists('g:ttodo#ftplugin#notef') " && g:ttodo#ftplugin#notef !=# 'notes/%s/%s-%s.md' 28 | let g:ttodo#ftplugin#notefmt = [printf(g:ttodo#ftplugin#notef, '${name}', '${date}', '${index}')] 29 | else 30 | let g:ttodo#ftplugin#notefmt = ['notes/${year}/${name}/${date}-${index}.md', 'notes/${name}/<++>.md'] "{{{2 31 | endif 32 | elseif type(g:ttodo#ftplugin#notefmt) == 1 33 | let s:notefmt = g:ttodo#ftplugin#notefmt 34 | unlet! g:ttodo#ftplugin#notefmt 35 | let g:ttodo#ftplugin#notefmt = [s:notefmt] "{{{2 36 | endif 37 | 38 | 39 | if !exists('g:ttodo#ftplugin#note_prefix') 40 | " OPTION: note_prefix:PREFIX 41 | " 42 | " Prefix for references to notes. 43 | " 44 | " Possible (potentially useful) values: 45 | " - todo:// (opens the file in SimpleTask) 46 | " - root:// (SimpleTask: path relative to todo.txt file) 47 | " - file:// (less useful since it would require an absolute path) 48 | let g:ttodo#ftplugin#note_prefix = 'root://' "{{{2 49 | endif 50 | 51 | 52 | if !exists('g:ttodo#ftplugin#edit_note') 53 | " If non-empty, edit a newly added reference to a note right away. 54 | " 55 | " Possible (potentially useful) values: 56 | " - split 57 | " - hide edit 58 | " - tabedit 59 | let g:ttodo#ftplugin#edit_note = '' "{{{2 60 | endif 61 | 62 | 63 | if !exists('g:ttodo#ftplugin#add_at_eof') 64 | " OPTION: add_at_eof:VALUE 65 | " 66 | " If true, the or map will make ttodo add a new task at 67 | " the end of the file. Otherwise the task will be added below the 68 | " current line. 69 | " Subtasks will always be added below the current line. 70 | let g:ttodo#ftplugin#add_at_eof = 1 "{{{2 71 | endif 72 | 73 | 74 | if !exists('g:ttodo#ftplugin#rec_copy') 75 | " OPTION: rec_copy:VALUE 76 | " 77 | " If true, marking a recurring task as "done" will mark the old task 78 | " as completed and will then create a new updated task. 79 | let g:ttodo#ftplugin#rec_copy = 1 "{{{2 80 | endif 81 | 82 | 83 | if !exists('g:ttodo#ftplugin#new_subtask_copy_pri') 84 | " OPTION: new_subtask_copy_pri:VALUE 85 | " 86 | " If true, copy the parent task's priority when creating subtasks. 87 | let g:ttodo#ftplugin#new_subtask_copy_pri = 0 "{{{2 88 | endif 89 | 90 | 91 | if !exists('g:ttodo#ftplugin#new_subtask_place_cursor_before_copied_attribs') 92 | " OPTION: new_subtask_place_cursor_before_copied_attribs:VALUE 93 | let g:ttodo#ftplugin#new_subtask_place_cursor_before_copied_attribs = 1 "{{{2 94 | endif 95 | 96 | 97 | if !exists('g:ttodo#ftplugin#new_with_creation_date') 98 | " OPTION: new_with_creation_date:VALUE 99 | let g:ttodo#ftplugin#new_with_creation_date = 1 "{{{2 100 | endif 101 | 102 | 103 | if !exists('g:ttodo#ftplugin#new_default_priority') 104 | " OPTION: new_default_priority:VALUE 105 | let g:ttodo#ftplugin#new_default_priority = 'C' "{{{2 106 | endif 107 | 108 | 109 | if !exists('g:ttodo#ftplugin#mark_done_style') 110 | " See https://github.com/todotxt/todo.txt#rule-2-the-date-of-completion-appears-directly-after-the-x-separated-by-a-space 111 | " 1 ... x (PRI) COMPLETION_DATE CREATION_DATE ... 112 | " 2 ... x COMPLETION_DATE CREATION_DATE ... pri:PRI 113 | let g:ttodo#ftplugin#mark_done_style = 1 "{{{2 114 | endif 115 | 116 | 117 | if !exists('g:ttodo#ftplugin#done_filename_rewrite_expr') 118 | let g:ttodo#ftplugin#done_filename_rewrite_expr = 'substitute(%s, ''\". o 228 | endif 229 | endif 230 | let new = ttodo#MaybeAppend(new, 'dep:'. id) 231 | endif 232 | let i0 = indent('.') 233 | let add_at_eof = ttodo#GetOption('add_at_eof', g:ttodo#ftplugin#add_at_eof) 234 | Tlibtrace 'ttodo', o, new, i0 235 | " new item after indented line 236 | if i0 > 0 && empty(a:move) 237 | let move_down = '' 238 | for pos1 in range(line('.') + 1, line('$')) 239 | let i1 = indent(pos1) 240 | Tlibtrace 'ttodo', i1 241 | if i1 > i0 242 | let move_down .= 'j' 243 | else 244 | break 245 | endif 246 | endfor 247 | let keys = o . ttodo#MaybePadRight(new) 248 | if !empty(move_down) 249 | let keys .= "\ddk" . move_down . 'pA' 250 | endif 251 | Tlibtrace 'ttodo', keys 252 | return keys 253 | else 254 | let task = a:0 >= 1 ? a:1 : ttodo#ParseTask(getline('.'), expand('%:p')) 255 | if a:move == '>' 256 | let new = ttodo#MaybePadRight(new) 257 | let new_subtask_copy_pri = ttodo#GetOption('new_subtask_copy_pri', g:ttodo#ftplugin#new_subtask_copy_pri) 258 | if new_subtask_copy_pri 259 | Tlibtrace 'ttodo', new_subtask_copy_pri, new 260 | let new = s:MaybeCopyPriority(task, new) 261 | endif 262 | let prefix = matchstr(getline('.'), '^\s\+') 263 | Tlibtrace 'ttodo', prefix 264 | if add_at_eof 265 | for lnum in range(line('.'), line('$') - 1) 266 | let i1 = indent(lnum + 1) 267 | Tlibtrace 'ttodo', lnum, i0, i1 268 | if i1 == 0 || i1 <= i0 269 | let expr = lnum .'gg'. o ."\I". prefix ."\". new 270 | Tlibtrace 'ttodo', expr 271 | return expr 272 | endif 273 | endfor 274 | endif 275 | Tlibtrace 'ttodo', o, new 276 | return o ."\" . new 277 | else 278 | let post = '' 279 | let o .= "\" 280 | let new_subtask_place_cursor_before_copied_attribs = ttodo#GetOption('new_subtask_place_cursor_before_copied_attribs', g:ttodo#ftplugin#new_subtask_place_cursor_before_copied_attribs) 281 | let new_default_priority = ttodo#GetOption('new_default_priority', g:ttodo#ftplugin#new_default_priority) 282 | if !empty(new_default_priority) 283 | let new = '('. new_default_priority .') '. new 284 | endif 285 | if a:copytags > 0 286 | if new_subtask_place_cursor_before_copied_attribs 287 | let new = new . ' ' 288 | endif 289 | let nnew = strwidth(new) 290 | let new = ttodo#MaybeAppend(new, ttodo#FormatTags('@', get(task, 'lists', []))) 291 | let new = ttodo#MaybeAppend(new, ttodo#FormatTags('+', get(task, 'tags', []))) 292 | let new = ttodo#MaybeAppend(new, join(get(task, 'notes', []))) 293 | let new = s:MaybeCopyPriority(task, new) 294 | if new_subtask_place_cursor_before_copied_attribs 295 | let post .= repeat("\", strwidth(new) - nnew) 296 | endif 297 | endif 298 | let move = a:move 299 | if empty(move) && i0 == 0 300 | let move = add_at_eof ? 'G' : '' 301 | " else " TODO: find last line with same indent 302 | endif 303 | if a:mode == 'i' && !empty(move) 304 | let move = "\\" 305 | endif 306 | if !new_subtask_place_cursor_before_copied_attribs 307 | let new = ttodo#MaybePadRight(new) 308 | endif 309 | Tlibtrace 'ttodo', move, o, new, post 310 | return move . o . new . post 311 | endif 312 | endif 313 | endf 314 | 315 | 316 | function! s:MaybeCopyPriority(task, text) abort "{{{3 317 | if has_key(a:task, 'pri') 318 | return ttodo#MaybeSetPriority(a:text, a:task.pri) 319 | else 320 | return a:text 321 | endif 322 | endf 323 | 324 | 325 | function! s:IsDone(line) abort "{{{3 326 | return a:line =~# '^\s*x\s' 327 | endf 328 | 329 | 330 | function! ttodo#ftplugin#MarkDone(count, ...) abort "{{{3 331 | TVarArg ['ignore_rec', 0] 332 | Tlibtrace 'ttodo', a:count, ignore_rec 333 | let donedate = strftime(g:tlib#date#date_format) 334 | let lnum0 = line('.') 335 | for lnum in range(lnum0, lnum0 + a:count) 336 | let line = getline(lnum) 337 | Tlibtrace 'ttodo', lnum, line 338 | let task = ttodo#ParseTask(line, expand('%:p')) 339 | Tlibtrace 'ttodo', task 340 | if !get(task, 'done', 0) 341 | if !ignore_rec 342 | let rec = get(task, 'rec', '') 343 | if !empty(rec) 344 | if get(task, 'subtask', 0) 345 | echohl Error 346 | echom "TTodo: Cannot complete subtasks with a 'rec:' tag:" line 347 | continue 348 | elseif get(task, 'has_subtask', 0) 349 | " TODO: Must copy the whole tree 350 | echohl Error 351 | echom "TTodo: Cannot complete top tasks with a 'rec:' tag:" line 352 | continue 353 | else 354 | if ttodo#GetOption('rec_copy', g:ttodo#ftplugin#rec_copy) 355 | call ttodo#ftplugin#MarkDone(0, 1) 356 | let line = ttodo#SetCreateDate(line) 357 | call append('$', line) 358 | let lnum = line('$') 359 | endif 360 | let shift = matchstr(rec, '\d\+\a$') 361 | let due = get(task, 'due', '') 362 | if !empty(due) 363 | let refdate = rec =~ '^+' ? due : donedate 364 | Tlibtrace 'ttodo', rec, due, shift, refdate 365 | while 1 366 | let due = tlib#date#Shift(due, shift) 367 | Tlibtrace 'ttodo', due 368 | if due > refdate 369 | break 370 | endif 371 | endwh 372 | exec lnum 373 | call s:MarkDueDate(due) 374 | endif 375 | if has_key(task, 't') && task.t =~# g:tlib#date#date_rx 376 | let t0 = task.t 377 | let t1 = tlib#date#Shift(t0, shift) 378 | Tlibtrace 'ttodo', t1 379 | exec lnum 380 | call s:SetTag('t', g:tlib#date#date_rx, t1) 381 | endif 382 | continue 383 | endif 384 | endif 385 | endif 386 | if get(task, 'next', 0) 387 | if line =~ '@next\s\+' 388 | let line = substitute(line, '@next\s\+', '', '') 389 | else 390 | let line = substitute(line, '\s\+@next\>', '', '') 391 | endif 392 | " call setline(lnum, line) 393 | endif 394 | endif 395 | if get(task, 'subtask', 0) && !has_key(task, 'parent') 396 | let parent = s:GetParentID(lnum) 397 | if !empty(parent) 398 | let line = s:Append(line, 'parent:'. parent) 399 | " call setline(lnum, line .' parent:'. parent) 400 | endif 401 | endif 402 | " let line = substitute(line, '^\s*\zs\C\%(x\s\+\%('. g:tlib#date#date_rx .'\s\+\)\?\)\?', 'x '. donedate .' ', '') 403 | if g:ttodo#ftplugin#mark_done_style == 1 404 | let line = substitute(line, '^\s*\zs\C\((\u)\s\)', 'x \1'. donedate .' ', '') 405 | elseif g:ttodo#ftplugin#mark_done_style == 2 406 | let line = substitute(line, '^\s*\zs\C\((\(\u\))\s\)\(.*\)$', 'x '. donedate .' \3 pri:\2', '') 407 | else 408 | throw 'ttodo: Unsupported value for g:ttodo#ftplugin#mark_done_style = '. g:ttodo#ftplugin#mark_done_style 409 | endif 410 | call setline(lnum, line) 411 | " exec lnum .'s/^\s*\zs\C\%(x\s\+\%('. g:tlib#date#date_rx .'\s\+\)\?\)\?/x '. donedate .' /' 412 | endfor 413 | exec lnum0 + a:count 414 | endf 415 | 416 | 417 | function! s:GetIdAtLine(lnum) abort "{{{3 418 | let line = getline(a:lnum) 419 | let filename = expand('%:p') 420 | let task = ttodo#ParseTask(line, filename) 421 | if !has_key(task, 'id') 422 | exec a:lnum 423 | call ttodo#ftplugin#AddId(0) 424 | let task = ttodo#ParseTask(getline(a:lnum), filename) 425 | endif 426 | return task.id 427 | endf 428 | 429 | 430 | function! s:GetParentID(lnum0) abort "{{{3 431 | let indent0 = indent(a:lnum0) 432 | " let filename = expand('%:p') 433 | for lnum in range(a:lnum0 - 1, 1, -1) 434 | let indent = indent(lnum) 435 | if indent < indent0 436 | return s:GetIdAtLine(lnum) 437 | " let line = getline(lnum) 438 | " let task = ttodo#ParseTask(line, filename) 439 | " if !has_key(task, 'id') 440 | " exec lnum 441 | " call ttodo#ftplugin#AddId(0) 442 | " let task = ttodo#ParseTask(getline(lnum), filename) 443 | " endif 444 | " return task.id 445 | endif 446 | endfor 447 | return '' 448 | endf 449 | 450 | 451 | function! ttodo#ftplugin#MarkDue(unit, count) abort "{{{3 452 | if a:count == -1 453 | elseif s:IsDone(getline('.')) 454 | echohl WarningMsg 455 | throw 'Ttodo: Cannot change finshed task' 456 | echohl NONE 457 | else 458 | if type(a:count) == 0 459 | let n = a:count 460 | elseif type(a:count) == 1 461 | let n = ttodo#InputNumber(a:count) 462 | if n < 0 463 | return 464 | endif 465 | else 466 | throw 'ttodo#ftplugin#MarkDue: count must be a number or a string' 467 | endif 468 | let task = ttodo#ParseTask(getline('.'), expand('%:p')) 469 | " let due = strftime(g:tlib#date#date_format) 470 | let due = get(task, 'due', strftime(g:tlib#date#date_format)) 471 | let shift = n . a:unit 472 | let due = tlib#date#Shift(due, shift) 473 | call s:MarkDueDate(due) 474 | if has_key(task, 't') && task.t =~# g:tlib#date#date_rx 475 | let t0 = task.t 476 | let t1 = tlib#date#Shift(t0, shift) 477 | Tlibtrace 'ttodo', t1 478 | call s:SetTag('t', g:tlib#date#date_rx, t1) 479 | endif 480 | endif 481 | endf 482 | 483 | 484 | function! s:MarkDueDate(date) abort "{{{3 485 | call s:SetTag('due', '\%(\\|'. g:tlib#date#date_rx .'\)', a:date) 486 | " exec 's/\C\%(\s\+due:'. g:tlib#date#date_rx .'\|$\)/ due:'. a:date .'/' 487 | endf 488 | 489 | 490 | function! s:SetTag(name, rx, value) abort "{{{3 491 | exec 's/\C\%(\s\+'. a:name .':'. escape(a:rx, '/') .'\|$\)/ '. a:name .':'. escape(a:value, '/') .'/' 492 | endf 493 | 494 | 495 | function! ttodo#ftplugin#SetPriority(count, ...) abort "{{{3 496 | " TLogVAR a:count 497 | if s:IsDone(getline('.')) 498 | echohl WarningMsg 499 | throw 'Ttodo: Cannot change finshed task' 500 | echohl NONE 501 | else 502 | let category = a:0 >= 1 ? a:1 : tlib#string#Input('New task category [A-Z]: ') 503 | let category = toupper(category) 504 | if category =~ '\C^[A-Z]$' 505 | exec 's/^\s*\zs\C\%((\u)\s\+\)\?/('. category .') /' 506 | else 507 | echohl WarningMsg 508 | echom 'Invalid category (must be A-Z):' category 509 | echohl NONE 510 | endif 511 | endif 512 | endf 513 | 514 | 515 | function! ttodo#ftplugin#Agent(world, selected, fn, ...) abort "{{{3 516 | " TLogVAR a:fn, a:000 517 | let cmd = printf('call call(%s, %s)', string(a:fn), string(map(copy(a:000), 's:AgentEvalArg(v:val)'))) 518 | Tlibtrace 'ttodo', cmd 519 | let world = tlib#qfl#RunCmdOnSelected(a:world, a:selected, cmd) 520 | return world 521 | endf 522 | 523 | 524 | function! s:AgentEvalArg(arg) abort "{{{3 525 | if type(a:arg) == 1 && a:arg =~ '^\\=' 526 | return eval(substitute(a:arg, '^\\=', '', '')) 527 | elseif type(a:arg) == 1 && a:arg =~ '^".\{-}"$' 528 | return matchstr(a:arg, '^"\zs.\{-}\ze"$') 529 | else 530 | return a:arg 531 | endif 532 | endf 533 | 534 | 535 | function! s:EnsureIdAtLine(lnum, ...) abort "{{{3 536 | let filename = a:0 >= 1 ? a:1 : expand('%:p') 537 | let filetasks = a:0 >= 2 ? a:2 : ttodo#GetFileTasks({}, filename, {}) 538 | let fqfl = filetasks.qfl 539 | let line = getline(a:lnum) 540 | let task = ttodo#ParseTask(line, filename) 541 | if !has_key(task, 'id') 542 | let qfe = filetasks.GetQfeByLnum(a:lnum) 543 | if g:ttodo#ftplugin#id_version == 1 544 | let ttask = string(empty(qfe) ? task : qfe) . g:ttodo#ftplugin#id_suffix 545 | let id = tlib#hash#Adler32(ttask) 546 | elseif g:ttodo#ftplugin#id_version == 2 547 | if !has('reltime') 548 | throw 'TTodo: g:ttodo#ftplugin#id_version == 2 requires +reltime' 549 | endif 550 | let suffix = ''. a:lnum . g:ttodo#ftplugin#id_suffix 551 | let ids = str2nr(substitute(reltimestr(reltime()), '\.', '', '')) . suffix 552 | let id = tlib#number#ConvertBase(ids, 62) 553 | elseif g:ttodo#ftplugin#id_version == 3 554 | if !exists('*rand') 555 | throw 'TTodo: g:ttodo#ftplugin#id_version == 3 requires +rand' 556 | endif 557 | let ids = ''. a:lnum . g:ttodo#ftplugin#id_suffix . rand() 558 | let id = tlib#number#ConvertBase(ids, 62) 559 | else 560 | throw 'TTodo: Unsupported value for g:ttodo#ftplugin#id_version: '. g:ttodo#ftplugin#id_version 561 | endif 562 | Tlibtrace 'ttodo', id 563 | return [1, id] 564 | else 565 | return [0, task.id] 566 | endif 567 | endf 568 | 569 | 570 | function! s:Append(a, b) abort "{{{3 571 | return substitute(a:a, '\s\+$', '', '') .' '. a:b 572 | endf 573 | 574 | 575 | function! ttodo#ftplugin#AddId(count) abort "{{{3 576 | let filename = expand('%:p') 577 | let filetasks = ttodo#GetFileTasks({}, filename, {}) 578 | let fqfl = filetasks.qfl 579 | for lnum in range(line('.'), line('.') + a:count) 580 | let [isnew, id] = s:EnsureIdAtLine(lnum, filename, filetasks) 581 | if isnew 582 | let line = s:Append(getline(lnum), 'id:'. id) 583 | Tlibtrace 'ttodo', lnum, line 584 | call setline(lnum, line) 585 | endif 586 | endfor 587 | endf 588 | 589 | 590 | function! ttodo#ftplugin#SyntaxDue() abort "{{{3 591 | let overdue_rx = ttodo#GetOverdueRx({'bufname': '%'}) 592 | if !empty(overdue_rx) 593 | exec 'syntax match TtodoOverdue /'. escape(overdue_rx, '/') .'/' 594 | endif 595 | exec 'syntax match TtodoDue /\/' 596 | endf 597 | 598 | 599 | function! ttodo#ftplugin#AddDep() abort "{{{3 600 | let filename = expand('%:p') 601 | let filetasks = ttodo#GetFileTasks({}, filename, {}) 602 | " TLogVAR len(filetasks.qfl), len(filetasks.task_by_id) 603 | let with_id = values(map(copy(filetasks.task_by_id), 'v:key ."\t". v:val.text')) 604 | if empty(with_id) 605 | echom 'ttodo#ftplugin#AddDep: No IDs' 606 | else 607 | let dep = tlib#input#List('s', 'Select dependency:', with_id) 608 | if !empty(dep) 609 | let id = matchstr(dep, '^[^\t]\+\ze\t') 610 | call setline('.', s:Append(getline('.'), 'dep:'. id)) 611 | endif 612 | endif 613 | endf 614 | 615 | 616 | function! ttodo#ftplugin#Duplicate(count, markdone) abort "{{{3 617 | " let pos = getpos('.') 618 | Tlibtrace 'ttodo', a:count, a:markdone 619 | for lnum in range(line('.'), line('.') + a:count - 1) 620 | Tlibtrace 'ttodo', lnum 621 | exec lnum 622 | if indent('.') > 0 623 | norm! yy 624 | if a:count > 0 625 | exec lnum + a:count - 1 626 | endif 627 | norm! p 628 | else 629 | norm! yyGp 630 | endif 631 | if a:markdone 632 | let p1 = getpos('.') 633 | exec lnum 634 | " call setpos('.', pos) 635 | call ttodo#ftplugin#MarkDone(0) 636 | call setpos('.', p1) 637 | endif 638 | endfor 639 | endf 640 | 641 | -------------------------------------------------------------------------------- /doc/tags: -------------------------------------------------------------------------------- 1 | :Ttodo ttodo.txt /*:Ttodo* 2 | :Ttodoarchive ttodo.txt /*:Ttodoarchive* 3 | :Ttodobuffer ttodo.txt /*:Ttodobuffer* 4 | :Ttodogrep ttodo.txt /*:Ttodogrep* 5 | :Ttodoinbox ttodo.txt /*:Ttodoinbox* 6 | :Ttodonew ttodo.txt /*:Ttodonew* 7 | :Ttodonext ttodo.txt /*:Ttodonext* 8 | :Ttodonote ttodo.txt /*:Ttodonote* 9 | :Ttodosort ttodo.txt /*:Ttodosort* 10 | autoload/ttodo.vim ttodo.txt /*autoload\/ttodo.vim* 11 | autoload/ttodo/ftplugin.vim ttodo.txt /*autoload\/ttodo\/ftplugin.vim* 12 | ftplugin/ttodo.vim ttodo.txt /*ftplugin\/ttodo.vim* 13 | g:ttodo#default_t ttodo.txt /*g:ttodo#default_t* 14 | g:ttodo#file_exclude_rx ttodo.txt /*g:ttodo#file_exclude_rx* 15 | g:ttodo#file_include_rx ttodo.txt /*g:ttodo#file_include_rx* 16 | g:ttodo#file_pattern ttodo.txt /*g:ttodo#file_pattern* 17 | g:ttodo#fileargs ttodo.txt /*g:ttodo#fileargs* 18 | g:ttodo#force_filetype ttodo.txt /*g:ttodo#force_filetype* 19 | g:ttodo#ftplugin#add_at_eof ttodo.txt /*g:ttodo#ftplugin#add_at_eof* 20 | g:ttodo#ftplugin#edit_note ttodo.txt /*g:ttodo#ftplugin#edit_note* 21 | g:ttodo#ftplugin#id_suffix ttodo.txt /*g:ttodo#ftplugin#id_suffix* 22 | g:ttodo#ftplugin#id_version ttodo.txt /*g:ttodo#ftplugin#id_version* 23 | g:ttodo#ftplugin#new_default_priority ttodo.txt /*g:ttodo#ftplugin#new_default_priority* 24 | g:ttodo#ftplugin#new_subtask_copy_pri ttodo.txt /*g:ttodo#ftplugin#new_subtask_copy_pri* 25 | g:ttodo#ftplugin#new_subtask_place_cursor_before_copied_attribs ttodo.txt /*g:ttodo#ftplugin#new_subtask_place_cursor_before_copied_attribs* 26 | g:ttodo#ftplugin#new_with_creation_date ttodo.txt /*g:ttodo#ftplugin#new_with_creation_date* 27 | g:ttodo#ftplugin#note_prefix ttodo.txt /*g:ttodo#ftplugin#note_prefix* 28 | g:ttodo#ftplugin#rec_copy ttodo.txt /*g:ttodo#ftplugin#rec_copy* 29 | g:ttodo#inbox ttodo.txt /*g:ttodo#inbox* 30 | g:ttodo#new_task ttodo.txt /*g:ttodo#new_task* 31 | g:ttodo#qfl_short_filename ttodo.txt /*g:ttodo#qfl_short_filename* 32 | g:ttodo#sort ttodo.txt /*g:ttodo#sort* 33 | g:ttodo#task_exclude_rx ttodo.txt /*g:ttodo#task_exclude_rx* 34 | g:ttodo#task_include_rx ttodo.txt /*g:ttodo#task_include_rx* 35 | g:ttodo#viewer ttodo.txt /*g:ttodo#viewer* 36 | g:ttodo_enable_ftdetect ttodo.txt /*g:ttodo_enable_ftdetect* 37 | g:ttodo_localmap ttodo.txt /*g:ttodo_localmap* 38 | g:ttodo_nmap ttodo.txt /*g:ttodo_nmap* 39 | g:ttodo_nmap_important ttodo.txt /*g:ttodo_nmap_important* 40 | plugin/ttodo.vim ttodo.txt /*plugin\/ttodo.vim* 41 | ttodo#SortBuffer() ttodo.txt /*ttodo#SortBuffer()* 42 | ttodo#ftplugin#New() ttodo.txt /*ttodo#ftplugin#New()* 43 | ttodo-@next ttodo.txt /*ttodo-@next* 44 | ttodo-file-options ttodo.txt /*ttodo-file-options* 45 | ttodo-tags ttodo.txt /*ttodo-tags* 46 | ttodo.txt ttodo.txt /*ttodo.txt* 47 | -------------------------------------------------------------------------------- /doc/ttodo.txt: -------------------------------------------------------------------------------- 1 | *ttodo.txt* Edit, view, sort, and filter todo.txt files 2 | Author: Tom Link, micathom at gmail com 3 | 4 | This plugin provides the |:Ttodo| command that allow easy editing, 5 | viewing, and filtering of todo.txt files (see http://todotxt.com) via 6 | |tlib#input#List()|. The plugin supports: 7 | 8 | - syntax highlighting for todo.txt files 9 | - search across multiple todo.txt files (see |:Ttodo|) 10 | - filter tasks with specific tags, lists etc. (see |:Ttodo|) 11 | - subtasks (outlines of complex tasks) 12 | - hide tasks until a threshold date 13 | - recurring tasks. 14 | 15 | Examples: > 16 | 17 | " Show all tasks; default map (|g:ttodo_nmap|): 1 18 | :Ttodo 19 | 20 | " Show important tasks; default map (|g:ttodo_nmap_important|): ! 21 | :Ttodo! 22 | 23 | " Show tasks that are due in the next two weeks 24 | :Ttodo --due=2w 25 | 26 | " Show tasks with priorities A to C 27 | :Ttodo --pri=A-C 28 | 29 | " Show tasks matching @Test 30 | :Ttodo @Test 31 | 32 | " By default, |:Ttodo| scans the todo.txt files in |g:ttodo#dirs|. Users 33 | " can also scan loaded buffers. 34 | " Show tasks in the current buffer 35 | :Ttodo --bufname=% 36 | 37 | " Command-line options can be collected in preference sets (see 38 | " |g:ttodo#prefs|) 39 | :Ttodo --pref=work 40 | 41 | Global maps: 42 | 43 | 1 ............ Show tasks (:Ttodo) 44 | ! ............ Show important tasks (:Ttodo --pref=important) 45 | 46 | If filetype is ttodo, the following buffer-local keymaps are enabled: 47 | 48 | ................. Add a new task; 49 | if |g:ttodo#ftplugin#add_at_eof| is true, add the 50 | task at the end of file 51 | ............... Add a new task; copy any list, tags, and notes from 52 | the current task; 53 | if |g:ttodo#ftplugin#add_at_eof| is true, add the 54 | task at the end of file 55 | ............... Add a new subtask 56 | tx ...... Mark the current task as "done" 57 | td ...... Mark the current task as due in N days 58 | tw ...... Mark the current task as due in N weeks 59 | tm ...... Mark the current task as due in N months 60 | ty ...... Set the current task's priority 61 | ta ...... Archive completed tasks 62 | tb ...... View, filter tasks in the current buffer 63 | t* ...... View tasks in the current buffer that match the word 64 | under the cursor 65 | tn ...... Add a note (the filename uses the first @list tag) 66 | ti ...... Add a hopefully unique ID (an Adler32 hash) 67 | tD ...... Add a dependency 68 | 69 | If filetype is ttodo, the following buffer-local commands are enabled: 70 | 71 | |:Ttodoarchive| ...... Archive completed tasks in the current buffer 72 | |:Ttodobuffer| ....... Show tasks in the current buffer only 73 | |:Ttodonote| ......... Add a new note to the task at the cursor 74 | |:Ttodosort| ......... Sort the tasks in the current buffer 75 | 76 | As a ftplugin, ttodo supports the following syntax/extensions to todo.txt (see 77 | also https://github.com/ginatrapani/todo.txt-cli/wiki/The-Todo.txt-Format): 78 | 79 | (A) DATE TASK ........ A priority as upper case letter (at the beginning of the 80 | line) 81 | DATE TASK ............ An open task 82 | x DATE DATE TASK ..... A completed task (with completion date) 83 | indented tasks ..... A indented task is a subtask of the parent task; unless 84 | `has_subtasks` is true, |:Ttodo| will only show tasks 85 | with no open subtasks; this is similar to how the 86 | outline addon handles subtasks (see also 87 | https://github.com/samuelsnyder/outline-todo.txt) 88 | 89 | *ttodo-tags* 90 | A TASK may contain the following tags: 91 | *ttodo-@next* 92 | @list ............ a "list" tag 93 | NOTE: The is a special list `@next` that marks important 94 | task that should really be tackled next. 95 | +keyword ......... a "keyword" tag 96 | h:1 .............. hidden task 97 | due:YYYY-MM-DD ... due dates 98 | NOTE: If a task is member of the `@next` list, filters 99 | by due dates will be ignored 100 | rec:+Nx .......... When marking a task a "done", add a new task with a due 101 | date in N d(ays), w(eeks), m(onths), y(ears); with the 102 | leading '+' use the original due date; else use the 103 | completion date; this is similar to how the Simpletask 104 | Android app handles `rec` tags 105 | t:YYYY-MM-DD ..... Hide the tasks until the given date 106 | t:-Nd ............ Hide the tasks until N days before the due date 107 | id:ID ............ Define a tasks ID string (an ID should consist 108 | of alphanumeric characters only) 109 | dep:IDs .......... Depends on task with ID (if the other task is not 110 | completed yet, mark the current task as pending); 111 | IDs is a comma-separated list of IDs 112 | parent:ID ........ In outlines: the current task is the child of 113 | task with ID 114 | *ttodo-file-options* 115 | $TTODO$ OPTION:VALUE .. If a line matches `$TTODO$` it is assumed to 116 | contain a file-local option. Search the help file for 117 | `OPTION:` to see which options are available. Users will 118 | typically want to hide such lines using `h:1` 119 | 120 | If you set |g:ttodo_enable_ftdetect| to 0, you can use the |:Ttodo| command in 121 | conjunction with other syntax files/ftplugins such as: 122 | 123 | - https://github.com/freitass/todo.txt-vim 124 | - todo-txt.vim : Vim plugin for Todo.txt 125 | https://github.com/dbeniamine/todo.txt-vim or 126 | http://www.vim.org/scripts/script.php?script_id=5134 127 | - https://github.com/mivok/vimtodo or 128 | http://www.vim.org/scripts/script.php?script_id=3264 129 | - https://github.com/davidoc/todo.txt-vim 130 | - My fork: https://github.com/tomtom/todo.txt-vim-1 131 | - https://github.com/dsiroky/vim-todotxt 132 | - ... 133 | 134 | Related work: 135 | - https://github.com/elentok/todo.vim 136 | 137 | 138 | ----------------------------------------------------------------------- 139 | Install~ 140 | 141 | To install the vimball, edit the vba file and type: > 142 | 143 | :so % 144 | 145 | See :help vimball for details. 146 | 147 | To install from github, please use 148 | 1. git + a plugin loader like enable_vim, pathogen, vim-unbundle etc. 149 | 2. a plugin manager like VAM, Vundle, NeoBundle, vim-plug etc. 150 | 151 | The tlib_vim plugin is required: 152 | https://github.com/tomtom/tlib_vim 153 | 154 | Optional enhancement: 155 | - https://github.com/tomtom/autolinker_vim for hyperlinking 156 | 157 | Also available via git: http://github.com/tomtom/ttodo_vim 158 | 159 | 160 | Setup~ 161 | 162 | Please set |g:ttodo#dirs| in |vimrc| before using |:Ttodo|. 163 | 164 | 165 | ======================================================================== 166 | Contents~ 167 | 168 | g:ttodo_nmap ...................................................... |g:ttodo_nmap| 169 | g:ttodo_nmap_important ............................................ |g:ttodo_nmap_important| 170 | g:ttodo_localmap .................................................. |g:ttodo_localmap| 171 | g:ttodo_enable_ftdetect ........................................... |g:ttodo_enable_ftdetect| 172 | :Ttodo ............................................................ |:Ttodo| 173 | :Ttodonew ......................................................... |:Ttodonew| 174 | :Ttodoinbox ....................................................... |:Ttodoinbox| 175 | :Ttodonext ........................................................ |:Ttodonext| 176 | :Ttodogrep ........................................................ |:Ttodogrep| 177 | g:ttodo#fileargs .................................................. |g:ttodo#fileargs| 178 | g:ttodo#file_pattern .............................................. |g:ttodo#file_pattern| 179 | g:ttodo#force_filetype ............................................ |g:ttodo#force_filetype| 180 | g:ttodo#file_include_rx ........................................... |g:ttodo#file_include_rx| 181 | g:ttodo#file_exclude_rx ........................................... |g:ttodo#file_exclude_rx| 182 | g:ttodo#task_include_rx ........................................... |g:ttodo#task_include_rx| 183 | g:ttodo#task_exclude_rx ........................................... |g:ttodo#task_exclude_rx| 184 | g:ttodo#viewer .................................................... |g:ttodo#viewer| 185 | g:ttodo#sort ...................................................... |g:ttodo#sort| 186 | g:ttodo#default_t ................................................. |g:ttodo#default_t| 187 | g:ttodo#new_task .................................................. |g:ttodo#new_task| 188 | g:ttodo#inbox ..................................................... |g:ttodo#inbox| 189 | g:ttodo#qfl_short_filename ........................................ |g:ttodo#qfl_short_filename| 190 | ttodo#SortBuffer .................................................. |ttodo#SortBuffer()| 191 | g:ttodo#ftplugin#id_version ....................................... |g:ttodo#ftplugin#id_version| 192 | g:ttodo#ftplugin#id_suffix ........................................ |g:ttodo#ftplugin#id_suffix| 193 | g:ttodo#ftplugin#note_prefix ...................................... |g:ttodo#ftplugin#note_prefix| 194 | g:ttodo#ftplugin#edit_note ........................................ |g:ttodo#ftplugin#edit_note| 195 | g:ttodo#ftplugin#add_at_eof ....................................... |g:ttodo#ftplugin#add_at_eof| 196 | g:ttodo#ftplugin#rec_copy ......................................... |g:ttodo#ftplugin#rec_copy| 197 | g:ttodo#ftplugin#new_subtask_copy_pri ............................. |g:ttodo#ftplugin#new_subtask_copy_pri| 198 | g:ttodo#ftplugin#new_subtask_place_cursor_before_copied_attribs ... |g:ttodo#ftplugin#new_subtask_place_cursor_before_copied_attribs| 199 | g:ttodo#ftplugin#new_with_creation_date ........................... |g:ttodo#ftplugin#new_with_creation_date| 200 | g:ttodo#ftplugin#new_default_priority ............................. |g:ttodo#ftplugin#new_default_priority| 201 | ttodo#ftplugin#New ................................................ |ttodo#ftplugin#New()| 202 | :Ttodosort ........................................................ |:Ttodosort| 203 | :Ttodoarchive ..................................................... |:Ttodoarchive| 204 | :Ttodobuffer ...................................................... |:Ttodobuffer| 205 | :Ttodonote ........................................................ |:Ttodonote| 206 | 207 | 208 | ------------------------------------------------------------------------ 209 | *plugin/ttodo.vim* 210 | *g:ttodo_nmap* 211 | g:ttodo_nmap (default: '1') 212 | Call |:Ttodo|. 213 | 214 | *g:ttodo_nmap_important* 215 | g:ttodo_nmap_important (default: '!') 216 | Call |:Ttodonext|. 217 | 218 | *g:ttodo_localmap* 219 | g:ttodo_localmap (default: '1') 220 | Call |:Ttodo| with `%:p:h/TODO.TXT`. 221 | 222 | *g:ttodo_enable_ftdetect* 223 | g:ttodo_enable_ftdetect (default: 1) 224 | Set this variable to 1 in |vimrc| in order to enable the ttodo 225 | filetype for todo.txt files. 226 | 227 | *:Ttodo* 228 | :Ttodo[!] [ARGS] [INITIAL FILTER] 229 | 230 | ARGS is an argument list. The following arguments are supported: 231 | --pref=PREF .... PREF is the name of a preferences set in 232 | |g:ttodo#prefs| (default: "default") 233 | --due=DATE ..... show only tasks with due dates >= DATE. DATE can be 234 | - a DATE in the form YYYY-MM-DD or 235 | - a number of days or 236 | - a number of weeks as in "4w" 237 | (default: |g:ttodo#default_due|) 238 | --undated ...... Show tasks with no due dates when using the due 239 | argument 240 | --done ......... Show completed tasks 241 | --pending ...... Show tasks with open dependencies 242 | --hidden ....... Show hidden tasks, i.e. tasks with a "h:1" tag or 243 | tasks matching |g:ttodo#task_hide_rx| 244 | --bufnr=BUFNR .. A comma-separated list of buffer numbers (must be 245 | numbers) 246 | --bufname=EXPR . A buffer name expression (see |bufname()|) 247 | --files=FILE1,FILE2... .. A comma-separated list of todo.txt files 248 | --path=PATH .... Search files in this path (default: use 249 | |g:ttodo#dirs|) 250 | --pattern=PAT .. Search files matching this pattern (default: 251 | |g:ttodo#file_pattern|) 252 | --encoding=ENC . Encoding of the task files (default: &enc) 253 | --sort=FIELDS .. default: |g:ttodo#sort| 254 | --has_subtasks . Show tasks with open subtasks (i.e. indented tasks 255 | below the parent task) 256 | --pri=PRI ..................... Show tasks with a priority matching 257 | [PRI] (see |/[]|) 258 | --ignore_pri=PRI .............. Ignore tasks with a priority 259 | matching [PRI] (see |/[]|) 260 | --has_lists=LIST1,.. .......... Show tasks with matching lists 261 | --ignore_lists=LIST1,.. ....... Ignore tasks with matching lista 262 | --has_tags=TAG1,.. ............ Show tasks with matching taga 263 | --ignore_tags=TAG1,.. ......... Ignore tasks with matching tags 264 | -A=RX, --file_include_rx=RX ... Default: |g:ttodo#file_include_rx| 265 | -R=RX, --file_exclude_rx=RX ... Default: |g:ttodo#file_exclude_rx| 266 | -i=RX, --task_include_rx=RX ... Default: |g:ttodo#task_include_rx| 267 | -x=RX, --task_exclude_rx=RX ... Default: |g:ttodo#task_exclude_rx| 268 | 269 | When the [!] is included show only important tasks. 270 | 271 | INITIAL FILTER is a |regexp| for filtering the task list. The 272 | interpretation of INITIAL FILTER depends on the value of 273 | |g:tlib#input#filter_mode|. The format of INITIAL FILTER depends on 274 | the value of |g:ttodo#viewer|. 275 | 276 | *:Ttodonew* 277 | :Ttodonew 278 | Add a new task. 279 | 280 | *:Ttodoinbox* 281 | :Ttodoinbox 282 | Show newly (maybe semi-automatically) added tasks, i.e. tasks that are in the @Inbox list. 283 | 284 | *:Ttodonext* 285 | :Ttodonext 286 | Show tasks that should be done next, i.e. tasks that are in the @next 287 | list. 288 | 289 | *:Ttodogrep* 290 | :Ttodogrep 291 | Scan todo files and notes for some text -- see |:Trag| for details. 292 | 293 | NOTE: This command requires the trag VIM plugin to be installed. 294 | 295 | 296 | ------------------------------------------------------------------------ 297 | *autoload/ttodo.vim* 298 | *g:ttodo#fileargs* 299 | g:ttodo#fileargs (default: {}) 300 | A dictionary of {filename |regexp|: {additional args}} -- see 301 | |g:ttodo#dirs| for details on supported arguments. 302 | 303 | *g:ttodo#file_pattern* 304 | g:ttodo#file_pattern (default: ['*todo.txt', '*TODO.TXT']) 305 | A glob pattern matching todo.txt files. 306 | 307 | *g:ttodo#force_filetype* 308 | g:ttodo#force_filetype (default: 1) 309 | By default, |ttodo#FiletypeDetect()| uses |:setf| to set the 310 | filetype. This only works, if there isn't already a filetype 311 | assigned to the buffer. 312 | 313 | If true, ttodo will make sure the filetype is `ttodo` by using 314 | |:set| to set 'filetype'. 315 | 316 | *g:ttodo#file_include_rx* 317 | g:ttodo#file_include_rx (default: '') 318 | Consider only files matching this |regexp|. 319 | 320 | *g:ttodo#file_exclude_rx* 321 | g:ttodo#file_exclude_rx (default: '[\/]done\.txt$') 322 | Ignore files matching this |regexp|. 323 | 324 | *g:ttodo#task_include_rx* 325 | g:ttodo#task_include_rx (default: '') 326 | Include only tasks matching this |regexp| in the list. 327 | 328 | *g:ttodo#task_exclude_rx* 329 | g:ttodo#task_exclude_rx (default: '') 330 | Exclude tasks matching this |regexp| from the list. 331 | 332 | *g:ttodo#viewer* 333 | g:ttodo#viewer (default: 'tlib') 334 | Supported values: 335 | tlib ...... Use the tlib_vim plugin; the syntax of |:Ttodo|'s 336 | initial filter depends on the value of 337 | |g:tlib#input#filter_mode| 338 | :COMMAND .. E.g. `:cwindow` or `:CtrlPQuickfix`. In this case 339 | initial filter is a standard |regexp|. 340 | 341 | *g:ttodo#sort* 342 | g:ttodo#sort (default: '-next,-overdue,pri,due,done,lists,tags,idx') 343 | A comma-separated list of fields that determine the sort order for 344 | |:Ttodo| and |:Ttodosort|. 345 | 346 | A "-" as prefix reverses the sort order. 347 | 348 | *g:ttodo#default_t* 349 | g:ttodo#default_t (default: '-31d') 350 | If a task has no threshold date defined, assign this default threshold date. 351 | 352 | *g:ttodo#new_task* 353 | g:ttodo#new_task (default: {'lists': ['Inbox'], 'pri': 'C'}) 354 | Defintion for tasks added via |:Ttodonew|. 355 | 356 | *g:ttodo#inbox* 357 | g:ttodo#inbox (default: 'todo.txt') 358 | A file basename (no directory). 359 | 360 | Tasks added by |:Ttodonew| will be added to this file in the 361 | default (i.e. the first) directory in |g:ttodo#dirs|. 362 | 363 | *g:ttodo#qfl_short_filename* 364 | g:ttodo#qfl_short_filename (default: 'basename') 365 | Possible values: "basename", "shorten", "" 366 | 367 | *ttodo#SortBuffer()* 368 | ttodo#SortBuffer(cmdargs) 369 | If called with --sortseps=tags,lists, an empty line is inserted after 370 | each main (i.e. first) list or tag. 371 | 372 | Sorting doesn't work for outlines, i.e. tasks with subtasks. 373 | 374 | 375 | ------------------------------------------------------------------------ 376 | *autoload/ttodo/ftplugin.vim* 377 | *g:ttodo#ftplugin#id_version* 378 | g:ttodo#ftplugin#id_version (default: v:version < 800 || !has('reltime') ? 1 : 2) 379 | If 1, use IDs based on Adler32 (see |tlib#hash#Adler32()|) of the 380 | string representation of the internal structure representing a 381 | task. 382 | If 2, use IDs based on |reltime()| and |rand()|. 383 | 384 | *g:ttodo#ftplugin#id_suffix* 385 | g:ttodo#ftplugin#id_suffix (default: '') 386 | Add this suffix to the value used for generating the ID. 387 | If |g:ttodo#ftplugin#id_version| is 2, this must evaluate to a numeric value. 388 | This could be used to insert user IDs etc. 389 | 390 | *g:ttodo#ftplugin#note_prefix* 391 | g:ttodo#ftplugin#note_prefix (default: 'root://') 392 | OPTION: note_prefix:PREFIX 393 | 394 | Prefix for references to notes. 395 | 396 | Possible (potentially useful) values: 397 | - todo:// (opens the file in SimpleTask) 398 | - root:// (SimpleTask: path relative to todo.txt file) 399 | - file:// (less useful since it would require an absolute path) 400 | 401 | *g:ttodo#ftplugin#edit_note* 402 | g:ttodo#ftplugin#edit_note (default: '') 403 | If non-empty, edit a newly added reference to a note right away. 404 | 405 | Possible (potentially useful) values: 406 | - split 407 | - hide edit 408 | - tabedit 409 | 410 | *g:ttodo#ftplugin#add_at_eof* 411 | g:ttodo#ftplugin#add_at_eof (default: 1) 412 | OPTION: add_at_eof:VALUE 413 | 414 | If true, the or map will make ttodo add a new task at 415 | the end of the file. Otherwise the task will be added below the 416 | current line. 417 | Subtasks will always be added below the current line. 418 | 419 | *g:ttodo#ftplugin#rec_copy* 420 | g:ttodo#ftplugin#rec_copy (default: 1) 421 | OPTION: rec_copy:VALUE 422 | 423 | If true, marking a recurring task as "done" will mark the old task 424 | as completed and will then create a new updated task. 425 | 426 | *g:ttodo#ftplugin#new_subtask_copy_pri* 427 | g:ttodo#ftplugin#new_subtask_copy_pri (default: 0) 428 | OPTION: new_subtask_copy_pri:VALUE 429 | 430 | If true, copy the parent task's priority when creating subtasks. 431 | 432 | *g:ttodo#ftplugin#new_subtask_place_cursor_before_copied_attribs* 433 | g:ttodo#ftplugin#new_subtask_place_cursor_before_copied_attribs (default: 1) 434 | OPTION: new_subtask_place_cursor_before_copied_attribs:VALUE 435 | 436 | *g:ttodo#ftplugin#new_with_creation_date* 437 | g:ttodo#ftplugin#new_with_creation_date (default: 1) 438 | OPTION: new_with_creation_date:VALUE 439 | 440 | *g:ttodo#ftplugin#new_default_priority* 441 | g:ttodo#ftplugin#new_default_priority (default: 'C') 442 | OPTION: new_default_priority:VALUE 443 | 444 | *ttodo#ftplugin#New()* 445 | ttodo#ftplugin#New(move, copytags, mode, ...) 446 | Values for copytags: 447 | 1 ... Copy tags 448 | 2 ... Copy tags & mark as dependency 449 | 450 | 451 | ------------------------------------------------------------------------ 452 | *ftplugin/ttodo.vim* 453 | *:Ttodosort* 454 | :Ttodosort 455 | Sort the tasks in the current buffer. 456 | 457 | Sorting task outlines (i.e. subtasks) is not supported. 458 | 459 | *:Ttodoarchive* 460 | :Ttodoarchive 461 | Archive completed tasks in the current buffer. 462 | 463 | *:Ttodobuffer* 464 | :Ttodobuffer 465 | View the tasks in the current buffer. 466 | 467 | *:Ttodonote* 468 | :Ttodonote 469 | Add a new task to the task at the cursor. 470 | 471 | 472 | 473 | vim:tw=78:fo=w2croql:isk=!-~,^*,^|,^":ts=8:ft=help:norl: 474 | -------------------------------------------------------------------------------- /etc/tpl_ttodo.txt: -------------------------------------------------------------------------------- 1 | *ttodo.txt* Edit, view, sort, and filter todo.txt files 2 | Author: Tom Link, micathom at gmail com 3 | 4 | This plugin provides the |:Ttodo| command that allow easy editing, 5 | viewing, and filtering of todo.txt files (see http://todotxt.com) via 6 | |tlib#input#List()|. The plugin supports: 7 | 8 | - syntax highlighting for todo.txt files 9 | - search across multiple todo.txt files (see |:Ttodo|) 10 | - filter tasks with specific tags, lists etc. (see |:Ttodo|) 11 | - subtasks (outlines of complex tasks) 12 | - hide tasks until a threshold date 13 | - recurring tasks. 14 | 15 | Examples: > 16 | 17 | " Show all tasks; default map (|g:ttodo_nmap|): 1 18 | :Ttodo 19 | 20 | " Show important tasks; default map (|g:ttodo_nmap_important|): ! 21 | :Ttodo! 22 | 23 | " Show tasks that are due in the next two weeks 24 | :Ttodo --due=2w 25 | 26 | " Show tasks with priorities A to C 27 | :Ttodo --pri=A-C 28 | 29 | " Show tasks matching @Test 30 | :Ttodo @Test 31 | 32 | " By default, |:Ttodo| scans the todo.txt files in |g:ttodo#dirs|. Users 33 | " can also scan loaded buffers. 34 | " Show tasks in the current buffer 35 | :Ttodo --bufname=%% 36 | 37 | " Command-line options can be collected in preference sets (see 38 | " |g:ttodo#prefs|) 39 | :Ttodo --pref=work 40 | 41 | Global maps: 42 | 43 | 1 ............ Show tasks (:Ttodo) 44 | ! ............ Show important tasks (:Ttodo --pref=important) 45 | 46 | If filetype is ttodo, the following buffer-local keymaps are enabled: 47 | 48 | ................. Add a new task; 49 | if |g:ttodo#ftplugin#add_at_eof| is true, add the 50 | task at the end of file 51 | ............... Add a new task; copy any list, tags, and notes from 52 | the current task; 53 | if |g:ttodo#ftplugin#add_at_eof| is true, add the 54 | task at the end of file 55 | ............... Add a new subtask 56 | tx ...... Mark the current task as "done" 57 | td ...... Mark the current task as due in N days 58 | tw ...... Mark the current task as due in N weeks 59 | tm ...... Mark the current task as due in N months 60 | ty ...... Set the current task's priority 61 | ta ...... Archive completed tasks 62 | tb ...... View, filter tasks in the current buffer 63 | t* ...... View tasks in the current buffer that match the word 64 | under the cursor 65 | tn ...... Add a note (the filename uses the first @list tag) 66 | ti ...... Add a hopefully unique ID (an Adler32 hash) 67 | tD ...... Add a dependency 68 | 69 | If filetype is ttodo, the following buffer-local commands are enabled: 70 | 71 | |:Ttodoarchive| ...... Archive completed tasks in the current buffer 72 | |:Ttodobuffer| ....... Show tasks in the current buffer only 73 | |:Ttodonote| ......... Add a new note to the task at the cursor 74 | |:Ttodosort| ......... Sort the tasks in the current buffer 75 | 76 | As a ftplugin, ttodo supports the following syntax/extensions to todo.txt (see 77 | also https://github.com/ginatrapani/todo.txt-cli/wiki/The-Todo.txt-Format): 78 | 79 | (A) DATE TASK ........ A priority as upper case letter (at the beginning of the 80 | line) 81 | DATE TASK ............ An open task 82 | x DATE DATE TASK ..... A completed task (with completion date) 83 | indented tasks ..... A indented task is a subtask of the parent task; unless 84 | `has_subtasks` is true, |:Ttodo| will only show tasks 85 | with no open subtasks; this is similar to how the 86 | outline addon handles subtasks (see also 87 | https://github.com/samuelsnyder/outline-todo.txt) 88 | 89 | *ttodo-tags* 90 | A TASK may contain the following tags: 91 | *ttodo-@next* 92 | @list ............ a "list" tag 93 | NOTE: The is a special list `@next` that marks important 94 | task that should really be tackled next. 95 | +keyword ......... a "keyword" tag 96 | h:1 .............. hidden task 97 | due:YYYY-MM-DD ... due dates 98 | NOTE: If a task is member of the `@next` list, filters 99 | by due dates will be ignored 100 | rec:+Nx .......... When marking a task a "done", add a new task with a due 101 | date in N d(ays), w(eeks), m(onths), y(ears); with the 102 | leading '+' use the original due date; else use the 103 | completion date; this is similar to how the Simpletask 104 | Android app handles `rec` tags 105 | t:YYYY-MM-DD ..... Hide the tasks until the given date 106 | t:-Nd ............ Hide the tasks until N days before the due date 107 | id:ID ............ Define a tasks ID string (an ID should consist 108 | of alphanumeric characters only) 109 | dep:IDs .......... Depends on task with ID (if the other task is not 110 | completed yet, mark the current task as pending); 111 | IDs is a comma-separated list of IDs 112 | parent:ID ........ In outlines: the current task is the child of 113 | task with ID 114 | *ttodo-file-options* 115 | $TTODO$ OPTION:VALUE .. If a line matches `$TTODO$` it is assumed to 116 | contain a file-local option. Search the help file for 117 | `OPTION:` to see which options are available. Users will 118 | typically want to hide such lines using `h:1` 119 | 120 | If you set |g:ttodo_enable_ftdetect| to 0, you can use the |:Ttodo| command in 121 | conjunction with other syntax files/ftplugins such as: 122 | 123 | - https://github.com/freitass/todo.txt-vim 124 | - todo-txt.vim : Vim plugin for Todo.txt 125 | https://github.com/dbeniamine/todo.txt-vim or 126 | http://www.vim.org/scripts/script.php?script_id=5134 127 | - https://github.com/mivok/vimtodo or 128 | http://www.vim.org/scripts/script.php?script_id=3264 129 | - https://github.com/davidoc/todo.txt-vim 130 | - My fork: https://github.com/tomtom/todo.txt-vim-1 131 | - https://github.com/dsiroky/vim-todotxt 132 | - ... 133 | 134 | Related work: 135 | - https://github.com/elentok/todo.vim 136 | 137 | 138 | ----------------------------------------------------------------------- 139 | Install~ 140 | 141 | To install the vimball, edit the vba file and type: > 142 | 143 | :so %% 144 | 145 | See :help vimball for details. 146 | 147 | To install from github, please use 148 | 1. git + a plugin loader like enable_vim, pathogen, vim-unbundle etc. 149 | 2. a plugin manager like VAM, Vundle, NeoBundle, vim-plug etc. 150 | 151 | The tlib_vim plugin is required: 152 | https://github.com/tomtom/tlib_vim 153 | 154 | Optional enhancement: 155 | - https://github.com/tomtom/autolinker_vim for hyperlinking 156 | 157 | Also available via git: http://github.com/tomtom/ttodo_vim 158 | 159 | 160 | Setup~ 161 | 162 | Please set |g:ttodo#dirs| in |vimrc| before using |:Ttodo|. 163 | 164 | 165 | %s 166 | -------------------------------------------------------------------------------- /ftdetect/ttodo.vim: -------------------------------------------------------------------------------- 1 | autocmd BufNewFile,BufRead *todo.txt if &ft != 'ttodo' && exists('g:ttodo_enable_ftdetect') && g:ttodo_enable_ftdetect | call ttodo#FiletypeDetect(expand(":p")) | endif 2 | autocmd BufNewFile,BufRead *TODO.TXT if &ft != 'ttodo' && exists('g:ttodo_enable_ftdetect') && g:ttodo_enable_ftdetect | call ttodo#FiletypeDetect(expand(":p")) | endif 3 | autocmd BufNewFile,BufRead done.txt if &ft != 'ttodo' && exists('g:ttodo_enable_ftdetect') && g:ttodo_enable_ftdetect | call ttodo#FiletypeDetect(expand(":p")) | endif 4 | -------------------------------------------------------------------------------- /ftplugin/ttodo.vim: -------------------------------------------------------------------------------- 1 | " @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) 2 | " @Website: https://github.com/tomtom 3 | " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) 4 | " @Last Change: 2023-02-26. 5 | " @Revision: 118 6 | 7 | if exists("b:did_ftplugin") 8 | finish 9 | endif 10 | let b:did_ftplugin = 1 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | " setlocal wrap 15 | setlocal textwidth=0 16 | setlocal linebreak 17 | setlocal commentstring=x\ %s 18 | setlocal formatoptions=cql 19 | 20 | exec 'nnoremap ' g:ttodo#mapleader .'a :call ttodo#ftplugin#ArchiveCurrentBuffer()' 21 | exec 'nnoremap ' g:ttodo#mapleader .'D :call ttodo#ftplugin#AddDep()' 22 | exec 'nnoremap ' g:ttodo#mapleader .'d :call ttodo#ftplugin#MarkDue("d", v:count)' 23 | exec 'nnoremap ' g:ttodo#mapleader .'i :call ttodo#ftplugin#AddId(v:count)' 24 | exec 'nnoremap ' g:ttodo#mapleader .'m :call ttodo#ftplugin#MarkDue("m", v:count1)' 25 | exec 'nnoremap ' g:ttodo#mapleader .'n :call ttodo#ftplugin#Note(0)' 26 | exec 'nnoremap ' g:ttodo#mapleader .'N :call ttodo#ftplugin#Note(1)' 27 | exec 'nnoremap ' g:ttodo#mapleader .'p :call ttodo#ftplugin#Duplicate(v:count1, 0)' 28 | exec 'nnoremap ' g:ttodo#mapleader .'P :call ttodo#ftplugin#Duplicate(v:count1, 1)' 29 | exec 'nnoremap ' g:ttodo#mapleader .'w :call ttodo#ftplugin#MarkDue("w", v:count1)' 30 | exec 'nnoremap ' g:ttodo#mapleader .'x :call ttodo#ftplugin#MarkDone(v:count)' 31 | exec 'nnoremap ' g:ttodo#mapleader .'y :call ttodo#ftplugin#SetPriority(v:count)' 32 | 33 | exec 'nnoremap ' g:ttodo#mapleader .'/ :Ttodogrep ' 34 | exec 'xnoremap ' g:ttodo#mapleader .'/ y:Ttodogrep 0' 35 | 36 | exec 'nnoremap ' g:ttodo#mapleader .'b :Ttodo --bufname=%' 37 | exec 'nnoremap ' g:ttodo#mapleader .'* :Ttodo --bufname=% ' 38 | 39 | nnoremap ttodo#ftplugin#New('', 0, 'n') 40 | nnoremap ttodo#ftplugin#New('', 1, 'n') 41 | nnoremap ttodo#ftplugin#New('>', 1, 'n') 42 | nnoremap ttodo#ftplugin#New('', 2, 'n') 43 | 44 | inoremap ttodo#ftplugin#New('', 0, 'i') 45 | inoremap ttodo#ftplugin#New('', 1, 'i') 46 | inoremap ttodo#ftplugin#New('>', 1, 'i') 47 | inoremap ttodo#ftplugin#New('', 2, 'i') 48 | 49 | 50 | " Sort the tasks in the current buffer. 51 | " 52 | " Sorting task outlines (i.e. subtasks) is not supported. 53 | command! -buffer -bar -nargs=* -complete=customlist,ttodo#CComplete Ttodosort call ttodo#SortBuffer([]) 54 | 55 | " Archive completed tasks in the current buffer. 56 | command! -buffer -bar Ttodoarchive call ttodo#ftplugin#ArchiveCurrentBuffer() 57 | 58 | " View the tasks in the current buffer. 59 | command! -buffer -bar -nargs=* Ttodobuffer Ttodo --bufname=% 60 | 61 | " Add a new task to the task at the cursor. 62 | command! -buffer -bar Ttodonote call ttodo#ftplugin#Note() 63 | 64 | 65 | let &cpo = s:save_cpo 66 | unlet s:save_cpo 67 | -------------------------------------------------------------------------------- /plugin/ttodo.vim: -------------------------------------------------------------------------------- 1 | " @Author: Tom Link (micathom AT gmail com?subject=[vim]) 2 | " @Website: https://github.com/tomtom 3 | " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) 4 | " @Last Change: 2022-07-22 5 | " @Revision: 118 6 | " GetLatestVimScripts: 5262 0 :AutoInstall: ttodo.vim 7 | 8 | if &cp || exists("loaded_ttodo") 9 | finish 10 | endif 11 | let loaded_ttodo = 101 12 | 13 | let s:save_cpo = &cpo 14 | set cpo&vim 15 | 16 | 17 | if !exists('g:ttodo_nmap') 18 | " Call |:Ttodo|. 19 | let g:ttodo_nmap = '1' "{{{2 20 | endif 21 | 22 | 23 | if !exists('g:ttodo_nmap_important') 24 | " Call |:Ttodonext|. 25 | let g:ttodo_nmap_important = '!' "{{{2 26 | endif 27 | 28 | 29 | if !exists('g:ttodo_localmap') 30 | " Call |:Ttodo| with `%:p:h/TODO.TXT`. 31 | let g:ttodo_localmap = '1' "{{{2 32 | endif 33 | 34 | 35 | if !exists('g:ttodo_enable_ftdetect') 36 | " Set this variable to 1 in |vimrc| in order to enable the ttodo 37 | " filetype for todo.txt files. 38 | let g:ttodo_enable_ftdetect = 1 "{{{2 39 | endif 40 | 41 | 42 | " :display: :Ttodo[!] [ARGS] [INITIAL FILTER] 43 | " 44 | " ARGS is an argument list. The following arguments are supported: 45 | " --pref=PREF .... PREF is the name of a preferences set in 46 | " |g:ttodo#prefs| (default: "default") 47 | " --due=DATE ..... show only tasks with due dates >= DATE. DATE can be 48 | " - a DATE in the form YYYY-MM-DD or 49 | " - a number of days or 50 | " - a number of weeks as in "4w" 51 | " (default: |g:ttodo#default_due|) 52 | " --undated ...... Show tasks with no due dates when using the due 53 | " argument 54 | " --done ......... Show completed tasks 55 | " --pending ...... Show tasks with open dependencies 56 | " --hidden ....... Show hidden tasks, i.e. tasks with a "h:1" tag or 57 | " tasks matching |g:ttodo#task_hide_rx| 58 | " --bufnr=BUFNR .. A comma-separated list of buffer numbers (must be 59 | " numbers) 60 | " --bufname=EXPR . A buffer name expression (see |bufname()|) 61 | " --files=FILE1,FILE2... .. A comma-separated list of todo.txt files 62 | " --path=PATH .... Search files in this path (default: use 63 | " |g:ttodo#dirs|) 64 | " --pattern=PAT .. Search files matching this pattern (default: 65 | " |g:ttodo#file_pattern|) 66 | " --encoding=ENC . Encoding of the task files (default: &enc) 67 | " --sort=FIELDS .. default: |g:ttodo#sort| 68 | " --has_subtasks . Show tasks with open subtasks (i.e. indented tasks 69 | " below the parent task) 70 | " --pri=PRI ..................... Show tasks with a priority matching 71 | " [PRI] (see |/[]|) 72 | " --ignore_pri=PRI .............. Ignore tasks with a priority 73 | " matching [PRI] (see |/[]|) 74 | " --has_lists=LIST1,.. .......... Show tasks with matching lists 75 | " --ignore_lists=LIST1,.. ....... Ignore tasks with matching lista 76 | " --has_tags=TAG1,.. ............ Show tasks with matching taga 77 | " --ignore_tags=TAG1,.. ......... Ignore tasks with matching tags 78 | " -A=RX, --file_include_rx=RX ... Default: |g:ttodo#file_include_rx| 79 | " -R=RX, --file_exclude_rx=RX ... Default: |g:ttodo#file_exclude_rx| 80 | " -i=RX, --task_include_rx=RX ... Default: |g:ttodo#task_include_rx| 81 | " -x=RX, --task_exclude_rx=RX ... Default: |g:ttodo#task_exclude_rx| 82 | " 83 | " When the [!] is included show only important tasks. 84 | " 85 | " INITIAL FILTER is a |regexp| for filtering the task list. The 86 | " interpretation of INITIAL FILTER depends on the value of 87 | " |g:tlib#input#filter_mode|. The format of INITIAL FILTER depends on 88 | " the value of |g:ttodo#viewer|. 89 | command! -bang -nargs=* -complete=customlist,ttodo#CComplete Ttodo call ttodo#Show(!empty(""), []) 90 | 91 | 92 | " Add a new task. 93 | command! -nargs=+ -complete=customlist,ttodo#CComplete Ttodonew call ttodo#NewTask([]) 94 | 95 | 96 | " Show newly (maybe semi-automatically) added tasks, i.e. tasks that are in the @Inbox list. 97 | command! -bar Ttodoinbox Ttodo --has_lists=Inbox 98 | 99 | 100 | " Show tasks that should be done next, i.e. tasks that are in the @next 101 | " list. 102 | command! -bar Ttodonext Ttodo --has_lists=next 103 | 104 | 105 | " Scan todo files and notes for some text -- see |:Trag| for details. 106 | " 107 | " NOTE: This command requires the trag VIM plugin to be installed. 108 | command! -bang -nargs=+ Ttodogrep if exists(':Trag') == 2 | Trag --file_sources=*ttodo#FileSources | else | echom ':Ttodogrep requires the trag_vim plugin to be installed!' | endif 109 | 110 | 111 | if !empty(g:ttodo_nmap) 112 | exec 'noremap' g:ttodo_nmap ':Ttodo' 113 | endif 114 | 115 | 116 | if !empty(g:ttodo_nmap_important) 117 | exec 'noremap' g:ttodo_nmap_important ':Ttodonext' 118 | endif 119 | 120 | 121 | if !empty(g:ttodo_localmap) 122 | exec 'noremap' g:ttodo_localmap ':Ttodo --path=.' 123 | endif 124 | 125 | 126 | let &cpo = s:save_cpo 127 | unlet s:save_cpo 128 | -------------------------------------------------------------------------------- /syntax/ttodo.vim: -------------------------------------------------------------------------------- 1 | " @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) 2 | " @Website: https://github.com/tomtom 3 | " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) 4 | " @Last Change: 2016-03-22. 5 | 6 | if version < 600 7 | syntax clear 8 | elseif exists("b:current_syntax") 9 | finish 10 | endif 11 | 12 | if has('conceal') && &enc == 'utf-8' 13 | let s:sym_cluster = [] 14 | for [s:name, s:chars, s:cchar] in [ 15 | \ ['Dash', '--', '—'], 16 | \ ['Unequal', '!=', '≠'], 17 | \ ['Identity', '==', '≡'], 18 | \ ['Approx', '~~', '≈'], 19 | \ ['ArrowLR', '<-\+>', '↔'], 20 | \ ['ArrowL', '<-\+', '←'], 21 | \ ['ArrowR', '-\+>', '→'], 22 | \ ['ARROWLR', '<=\+>', '⇔'], 23 | \ ['ARROWL', '<=\+', '⇐'], 24 | \ ['ARROWR', '=\+>', '⇒'], 25 | \ ['ArrowTildeLR', '<~\+>', '↭'], 26 | \ ['ArrowTildeL', '<~\+', '↜'], 27 | \ ['ArrowTildeR', '~\+>', '↝'], 28 | \ ['Ellipsis', '...', '…'], 29 | \ ] 30 | 31 | exec 'syn match ttodoSymbol'. s:name .' /\V'. s:chars .'/ conceal cchar='. s:cchar 32 | endfor 33 | unlet! s:sym_cluster s:name s:chars s:cchar 34 | endif 35 | 36 | syntax match TtodoPri /([D-Z])/ 37 | syntax match TtodoPriA /(A)/ 38 | syntax match TtodoPriB /(B)/ 39 | syntax match TtodoPriC /(C)/ 40 | syntax match TtodoList /\%(^\|\s\)\zs@\S\+/ 41 | syntax match TtodoKeyword /\%(^\|\s\)\zs+\S\+/ 42 | exec 'syntax match TtodoTag /\%(^\|\s\)\zs\<\%('. join(map(keys(g:ttodo#parse_rx), 'matchstr(v:val, ''^\w\+'')'), '\|') .'\):\S\+/' 43 | syntax match TtodoDate /\<\d\{4}-\d\d-\d\d\>/ 44 | syntax match TtodoTime /\<\d\d:\d\d\>/ 45 | " syntax match TtodoDone /\.*$/ 48 | call ttodo#ftplugin#SyntaxDue() 49 | syntax cluster TtodoTask contains=TtodoPri,TtodoPriA,TtodoPriB,TtodoPriC,TtodoList,TtodoKeyword,TtodoTag,TtodoDate,TtodoTime,TtodoDone,TtodoHidden,TtodoOverdue 50 | 51 | hi def link TtodoPri Special 52 | hi def TtodoPriA term=bold,underline cterm=bold gui=bold guifg=Black ctermfg=Black ctermbg=Red guibg=Red 53 | hi def TtodoPriB term=bold,underline cterm=bold gui=bold guifg=Black ctermfg=Black ctermbg=Brown guibg=Orange 54 | hi def TtodoPriC term=bold,underline cterm=bold gui=bold guifg=Black ctermfg=Black ctermbg=Yellow guibg=Yellow 55 | 56 | hi def link TtodoList Identifier 57 | hi def link TtodoKeyword Constant 58 | hi def link TtodoTag Type 59 | hi def link TtodoDate Statement 60 | hi def link TtodoTime Statement 61 | hi def link TtodoDone Comment 62 | hi def link TtodoHidden Comment 63 | hi def link TtodoOverdue ErrorMsg 64 | hi def link TtodoDue WarningMsg 65 | 66 | let b:current_syntax = 'ttodo' 67 | --------------------------------------------------------------------------------