├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── after └── plugin │ └── cmp_r.lua ├── lua └── cmp_r │ ├── chunk.lua │ ├── figtbl.lua │ ├── init.lua │ ├── quarto.lua │ └── rhelp.lua ├── selene.toml ├── stylua.toml └── vim.toml /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to cmp-r 2 | 3 | Thank you for your interest in contributing to cmp-r. 4 | 5 | Please, follow the instruction from https://github.com/R-nvim/R.nvim/CONTRIBUTING.md 6 | 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cmp-r 2 | 3 | Completion source for [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) using 4 | [R.nvim](https://github.com/R-nvim/R.nvim) as backend. 5 | 6 | ## Installation 7 | 8 | Use a plugin manager such as [lazy.nvim](https://github.com/folke/lazy.nvim) 9 | and add `cmp-r` as a dependency of `nvim-cmp`. If you want to change any of 10 | `cmp-r` options, you could do it while configuring `nvim-cmp`. 11 | 12 | 13 | ## Setup 14 | 15 | Register the source for `nvim-cmp`: 16 | 17 | ```lua 18 | require'cmp'.setup { 19 | sources = { 20 | { name = 'cmp_r' }, 21 | } 22 | } 23 | ``` 24 | 25 | ## Configuration 26 | 27 | ### cmp-r 28 | 29 | `cmp-r` has the following options: 30 | 31 | - `filetypes`: The list of file types for which the source should be enabled. 32 | Default: `{'r', 'rmd', 'quarto', 'rnoweb', 'rhelp'}` 33 | 34 | - `doc_width`: The expected maximum width of the floating documentation 35 | window. Valid values are between `30` and `160`. Default: `58`. 36 | 37 | See also the option `maxwidth` in [lspkind.nvim](https://github.com/onsails/lspkind.nvim). 38 | 39 | - `trigger_characters`: List of characters to trigger completion. 40 | Default: `{ " ", ":", "(", '"', "@", "$" }`. 41 | 42 | - `fun_data_1`: List of functions that receive a `data.frame` as its first 43 | argument and for which the `data.frame`s columns names should be 44 | completed. This option is overridden by `g:R_fun_data_1`. Default: 45 | `{'select', 'rename', 'mutate', 'filter'}`. 46 | 47 | - `fun_data_2`: Dictionary with parent functions as keys. The value of each 48 | key is a list of functions that are expected to be nested in the parent 49 | function which receives a data.frame as its first arguments. Column names 50 | of the `data.frame` are completed as arguments of the nested function. 51 | This option is overridden by `g:R_fun_data_1`. Default: 52 | `{ggplot = {'aes'}, with = {'*'}}`. 53 | 54 | - `quarto_intel`: Path to `yaml-intelligence-resources.json` which is part 55 | of `quarto` application and has all necessary information for completion 56 | of valid YAML options in an Quarto document. Default: `nil` (`cmp-r` will 57 | try to find the file). 58 | 59 | Below is an example of how to set theses options: 60 | 61 | ```lua 62 | require("cmp_r").setup({ 63 | filetypes = {"r", "rmd", "quarto"}, 64 | doc_width = 58, 65 | quarto_intel = "~/Downloads/quarto-1.1.251/share/editor/tools/yaml/yaml-intelligence-resources.json" 66 | }) 67 | ``` 68 | 69 | Note: The algorithm for finding the first argument of the parent function is 70 | very simple and would wrongly recognize `data` as the name of the 71 | `data.frame` in the following code: 72 | 73 | ```r 74 | ggplot(data = my_data_frame, mapping = aes( 75 | ``` 76 | 77 | ### nvim-cmp 78 | 79 | The source `cmp_r` does not require any special configuration of 80 | `nvim-cmp` to work, and people have different preferences and workflows. 81 | Anyway, I share below what worked best for me: 82 | 83 | - `cmp-r` sets the field `sortText` of completed items as "0" for 84 | function arguments and "9" for everything else. This means that function 85 | arguments will always be at the top of the list of suggestions if you put 86 | `cmp.config.compare.sort_text` at the top of list of compare `nvim-cmp` 87 | functions. 88 | 89 | - Install a Nerd font and install and configure your terminal emulator to 90 | use it. Then install [lspkind.nvim](https://github.com/onsails/lspkind.nvim) 91 | to have symbols representing the kind of object whose name is being completed. 92 | 93 | - The names of kind of objects are generic names of the LSP server protocol 94 | and do not match the classes of R objects. So, it is better to hide the 95 | names and display only the symbols. 96 | 97 | There is a complete example of `nvim-cmp` configuration at the 98 | [Wiki](https://github.com/R-nvim/cmp-r/wiki). 99 | 100 | ### languageserver 101 | 102 | Since `cmp-r` and the R package `languageserver` provide completions for 103 | the same code, and completions from the `languageserver` might be the first 104 | ones to be displayed by `nvim-cmp`, you may want to put this in your `~/.Rprofile`: 105 | 106 | ```r 107 | # Disable completion from the language server 108 | options(languageserver.server_capabilities = 109 | list(completionProvider = FALSE, completionItemResolve = FALSE)) 110 | 111 | ``` 112 | -------------------------------------------------------------------------------- /after/plugin/cmp_r.lua: -------------------------------------------------------------------------------- 1 | require("cmp").register_source("cmp_r", require("cmp_r").new()) 2 | -------------------------------------------------------------------------------- /lua/cmp_r/chunk.lua: -------------------------------------------------------------------------------- 1 | local cmp = require("cmp") 2 | 3 | --- From https://yihui.org/knitr/options/#chunk-options (2021-04-19) 4 | local chunk_opts = { 5 | { 6 | word = "eval", 7 | menu = "TRUE", 8 | user_data = { 9 | descr = "Whether to evaluate the code chunk. It can also be a numeric vector to choose which R expression(s) to evaluate, e.g., eval = c(1, 3, 4) will evaluate the first, third, and fourth expressions, and eval = -(4:5) will evaluate all expressions except the fourth and fifth.", 10 | }, 11 | }, 12 | { 13 | word = "echo", 14 | menu = "TRUE", 15 | user_data = { 16 | descr = "Whether to display the source code in the output document. Besides TRUE/FALSE, which shows/hides the source code, we can also use a numeric vector to choose which R expression(s) to echo in a chunk, e.g., echo = 2:3 means to echo only the 2nd and 3rd expressions, and echo = -4 means to exclude the 4th expression.", 17 | }, 18 | }, 19 | { 20 | word = "results", 21 | menu = '"markup"', 22 | user_data = { 23 | descr = 'Controls how to display the text results. Note that this option only applies to normal text output (not warnings, messages, or errors). The possible values are as follows:\n- \\ markup\\ = Mark up text output with the appropriate environments depending on the output format.\n- \\ asis\\ = Write text output as-is, i.e., write the raw text results directly into the output document without any markups.\n- \\ hold\\ = Hold all pieces of text output in a chunk and flush them to the end of the chunk.\n- "hide" (or "FALSE"): Hide text output.', 24 | }, 25 | }, 26 | { 27 | word = "collapse", 28 | menu = "FALSE", 29 | user_data = { 30 | descr = "Whether to, if possible, collapse all the source and output blocks from one code chunk into a single block (by default, they are written to separate blocks). This option only applies to Markdown documents.", 31 | }, 32 | }, 33 | { 34 | word = "warning", 35 | menu = "TRUE", 36 | user_data = { 37 | descr = "Whether to preserve warnings (produced by `warning()`) in the output. If FALSE, all warnings will be printed in the console instead of the output document. It can also take numeric values as indices to select a subset of warnings to include in the output. Note that these values reference the indices of the warnings themselves (e.g., 3 means “the third warning thrown from this chunk”) and not the indices of which expressions are allowed to emit warnings.", 38 | }, 39 | }, 40 | { 41 | word = "error", 42 | menu = "TRUE", 43 | user_data = { 44 | descr = "Whether to preserve errors (from `stop()`). By default, the code evaluation will not stop even in case of errors! If we want to stop on errors, we need to set this option to FALSE. Note that R Markdown has changed this default value to FALSE. When the chunk option include = FALSE, knitr will stop on error, because it is easy to overlook potential errors in this case (if you understand this caveat and want to ignore potential errors anyway, you may set error = 0).", 45 | }, 46 | }, 47 | { 48 | word = "message", 49 | menu = "TRUE", 50 | user_data = { 51 | descr = "Whether to preserve messages emitted by `message()` (similar to the option warning).", 52 | }, 53 | }, 54 | { 55 | word = "include", 56 | menu = "TRUE", 57 | user_data = { 58 | descr = "Whether to include the chunk output in the output document. If FALSE, nothing will be written into the output document, but the code is still evaluated and plot files are generated if there are any plots in the chunk, so you can manually insert figures later.", 59 | }, 60 | }, 61 | { 62 | word = "strip.white", 63 | menu = "TRUE", 64 | user_data = { 65 | descr = "Whether to remove blank lines in the beginning or end of a source code block in the output.", 66 | }, 67 | }, 68 | { 69 | word = "class.output", 70 | menu = "NULL", 71 | user_data = { 72 | descr = 'A vector of class names to be added to the text output blocks. This option only works for HTML output formats in R Markdown. For example, with class.output = c("foo", "bar"), the text output will be placed in
.',
 73 |         },
 74 |     },
 75 |     {
 76 |         word = "class.message",
 77 |         menu = "NULL",
 78 |         user_data = {
 79 |             descr = "Similar to class.output, but applied to messages in R Markdown output. Please see the “Code Decoration” section for class.source, which applies similarly to source code blocks.",
 80 |         },
 81 |     },
 82 |     {
 83 |         word = "class.warning",
 84 |         menu = "NULL",
 85 |         user_data = {
 86 |             descr = "Similar to class.output, but applied to warnings in R Markdown output. Please see the “Code Decoration” section for class.source, which applies similarly to source code blocks.",
 87 |         },
 88 |     },
 89 |     {
 90 |         word = "class.error",
 91 |         menu = "NULL",
 92 |         user_data = {
 93 |             descr = "Similar to class.output, but applied to errors in R Markdown output. Please see the “Code Decoration” section for class.source, which applies similarly to source code blocks.",
 94 |         },
 95 |     },
 96 |     {
 97 |         word = "attr.output",
 98 |         menu = "NULL",
 99 |         user_data = {
100 |             descr = '(character) Similar to the class.* options, but for specifying arbitrary fenced code block attributes for Pandoc; class.* is a special application of attr.*, e.g., class.source = "numberLines" is equivalent to attr.source = ".numberLines", but attr.source can take arbitrary attribute values.',
101 |         },
102 |     },
103 |     {
104 |         word = "attr.message",
105 |         menu = "NULL",
106 |         user_data = {
107 |             descr = '(character) Similar to the class.* options, but for specifying arbitrary fenced code block attributes for Pandoc; class.* is a special application of attr.*, e.g., class.source = "numberLines" is equivalent to attr.source = ".numberLines", but attr.source can take arbitrary attribute values.',
108 |         },
109 |     },
110 |     {
111 |         word = "attr.warning",
112 |         menu = "NULL",
113 |         user_data = {
114 |             descr = '(character) Similar to the class.* options, but for specifying arbitrary fenced code block attributes for Pandoc; class.* is a special application of attr.*, e.g., class.source = "numberLines" is equivalent to attr.source = ".numberLines", but attr.source can take arbitrary attribute values.',
115 |         },
116 |     },
117 |     {
118 |         word = "attr.error",
119 |         menu = "NULL",
120 |         user_data = {
121 |             descr = '(character) Similar to the class.* options, but for specifying arbitrary fenced code block attributes for Pandoc; class.* is a special application of attr.*, e.g., class.source = "numberLines" is equivalent to attr.source = ".numberLines", but attr.source can take arbitrary attribute values.',
122 |         },
123 |     },
124 |     {
125 |         word = "render",
126 |         menu = "knitr::knit_print",
127 |         user_data = {
128 |             descr = 'A function to print the visible values in a chunk. The value passed to the first argument of this function (i.e., x) is the value evaluated from each expression in the chunk. The list of current chunk options is passed to the argument options. This function is expected to return a character string. For more information, check out the package vignette about custom chunk rendering: vignette("knit_print", package = "knitr").',
129 |         },
130 |     },
131 |     {
132 |         word = "split",
133 |         menu = "FALSE",
134 |         user_data = {
135 |             descr = "Whether to split the output into separate files and include them in LaTeX by \\input{} or HTML by . This option only works for .Rnw, .Rtex, and .Rhtml documents.",
136 |         },
137 |     },
138 |     {
139 |         word = "tidy",
140 |         menu = "FALSE",
141 |         user_data = {
142 |             descr = 'Whether to reformat the R code. Other possible values are as follows:\n- `TRUE` (equivalent to tidy = "formatR"): Call the function `formatR::tidy_source()` to reformat the code.\n- \\ styler\\ = Use `styler::style_text()` to reformat the code.\nA custom function of the form function(code, ...) {} to return the reformatted code.',
143 |         },
144 |     },
145 |     {
146 |         word = "tidy.opts",
147 |         menu = "NULL",
148 |         user_data = {
149 |             descr = 'A list of options to be passed to the function determined by the tidy option, e.g., tidy.opts = list(blank = FALSE, width.cutoff = 60) for tidy = "formatR" to remove blank lines and try to cut the code lines at 60 characters.',
150 |         },
151 |     },
152 |     {
153 |         word = "prompt",
154 |         menu = "FALSE",
155 |         user_data = {
156 |             descr = "Whether to add the prompt characters in the R code. See prompt and continue on the help page ?base::options. Note that adding prompts can make it difficult for readers to copy R code from the output, so prompt = FALSE may be a better choice. This option may not work well when the chunk option engine is not R.",
157 |         },
158 |     },
159 |     {
160 |         word = "comment",
161 |         menu = '"##"',
162 |         user_data = {
163 |             descr = "The prefix to be added before each line of the text output. By default, the text output is commented out by ##, so if readers want to copy and run the source code from the output document, they can select and copy everything from the chunk, since the text output is masked in comments (and will be ignored when running the copied text). Set comment = '' remove the default ##.",
164 |         },
165 |     },
166 |     {
167 |         word = "highlight",
168 |         menu = "TRUE",
169 |         user_data = { descr = "Whether to syntax highlight the source code." },
170 |     },
171 |     {
172 |         word = "class.source",
173 |         menu = "NULL",
174 |         user_data = {
175 |             descr = "(character) Class names for source code blocks in the output document. Similar to the class.* options for output such as class.output.",
176 |         },
177 |     },
178 |     {
179 |         word = "attr.source",
180 |         menu = "NULL",
181 |         user_data = {
182 |             descr = "Attributes for source code blocks. Similar to the attr.* options for output such as attr.output.",
183 |         },
184 |     },
185 |     {
186 |         word = "size",
187 |         menu = '"normalsize"',
188 |         user_data = {
189 |             descr = "Font size of the chunk output from .Rnw documents. See this page for possible sizes.",
190 |         },
191 |     },
192 |     {
193 |         word = "background",
194 |         menu = '"#F7F7F7"',
195 |         user_data = { descr = "Background color of the chunk output of .Rnw documents." },
196 |     },
197 |     {
198 |         word = "indent",
199 |         menu = '""',
200 |         user_data = {
201 |             descr = "(character) A string to be added to each line of the chunk output. Typically it consists of white spaces. This option is assumed to be read-only, and knitr sets its value while parsing the document.",
202 |         },
203 |     },
204 |     {
205 |         word = "cache",
206 |         menu = "FALSE",
207 |         user_data = {
208 |             descr = "Whether to cache a code chunk. When evaluating code chunks for the second time, the cached chunks are skipped (unless they have been modified), but the objects created in these chunks are loaded from previously saved databases (.rdb and .rdx files), and these files are saved when a chunk is evaluated for the first time, or when cached files are not found (e.g., you may have removed them by hand). Note that the filename consists of the chunk label with an MD5 digest of the R code and chunk options of the code chunk, which means any changes in the chunk will produce a different MD5 digest, and hence invalidate the cache. See more information on this page.",
209 |         },
210 |     },
211 |     {
212 |         word = "cache.path",
213 |         menu = '"cache/"',
214 |         user_data = {
215 |             descr = "A prefix to be used to generate the paths of cache files. For R Markdown, the default value is based on the input filename, e.g., the cache paths for the chunk with the label FOO in the file INPUT.Rmd will be of the form INPUT_cache/FOO_*.*.",
216 |         },
217 |     },
218 |     {
219 |         word = "cache.vars",
220 |         menu = "NULL",
221 |         user_data = {
222 |             descr = "A vector of variable names to be saved in the cache database. By default, all variables created in the current chunks are identified and saved, but you may want to manually specify the variables to be saved, because the automatic detection of variables may not be robust, or you may want to save only a subset of variables.",
223 |         },
224 |     },
225 |     {
226 |         word = "cache.globals",
227 |         menu = "NULL",
228 |         user_data = {
229 |             descr = "A vector of the names of variables that are not created from the current chunk. This option is mainly for autodep = TRUE to work more precisely---a chunk B depends on chunk A when any of B’s global variables are A’s local variables. In case the automatic detection of global variables in a chunk fails, you may manually specify the names of global variables via this option.",
230 |         },
231 |     },
232 |     {
233 |         word = "cache.lazy",
234 |         menu = "TRUE",
235 |         user_data = {
236 |             descr = "Whether to `lazyLoad()` or directly `load()` objects. For very large objects, lazyloading may not work, so cache.lazy = FALSE may be desirable.",
237 |         },
238 |     },
239 |     {
240 |         word = "cache.comments",
241 |         menu = "NULL",
242 |         user_data = {
243 |             descr = "If FALSE, changing comments in R code chunks will not invalidate the cache database.",
244 |         },
245 |     },
246 |     {
247 |         word = "cache.rebuild",
248 |         menu = "FALSE",
249 |         user_data = {
250 |             descr = 'If TRUE, reevaluate the chunk even if the cache does not need to be invalidated. This can be useful when you want to conditionally invalidate the cache, e.g., cache.rebuild = !file.exists("some-file") can rebuild the chunk when some-file does not exist.',
251 |         },
252 |     },
253 |     {
254 |         word = "dependson",
255 |         menu = "NULL",
256 |         user_data = {
257 |             descr = "A character vector of chunk labels to specify which other chunks this chunk depends on. This option applies to cached chunks only---sometimes the objects in a cached chunk may depend on other cached chunks, so when other chunks are changed, this chunk must be updated accordingly.If dependson is a numeric vector, it means the indices of chunk labels, e.g., dependson = 1 means this chunk depends on the first chunk in the document, and dependson = c(-1, -2) means it depends on the previous two chunks (negative indices stand for numbers of chunks before this chunk, and note they are always relative to the current chunk). Please note this option does not work when set as a global chunk option via `opts_chunk$set()`; it must be set as a local chunk option.",
258 |         },
259 |     },
260 |     {
261 |         word = "autodep",
262 |         menu = "FALSE",
263 |         user_data = {
264 |             descr = "Whether to analyze dependencies among chunks automatically by detecting global variables in the code (may not be reliable), so dependson does not need to be set explicitly.",
265 |         },
266 |     },
267 |     {
268 |         word = "fig.path",
269 |         menu = '"figure/"',
270 |         user_data = {
271 |             descr = "A prefix to be used to generate figure file paths. fig.path and chunk labels are concatenated to generate the full paths. It may contain a directory like figure/prefix-; the directory will be created if it does not exist.",
272 |         },
273 |     },
274 |     {
275 |         word = "fig.keep",
276 |         menu = '"high"',
277 |         user_data = {
278 |             descr = "How plots in chunks should be kept. Possible values are as follows:\n - \\ high\\ =  Only keep high-level plots (merge low-level changes into high-level plots).\n- \\ none\\ =  Discard all plots.\n- \\ all\\ =  Keep all plots (low-level plot changes may produce new plots).\n- \\ first\\ =  Only keep the first plot.\n- \\ last\\ =  Only keep the last plot.\n- If set to a numeric vector, the values are indices of (low-level) plots to keep.",
279 |         },
280 |     },
281 |     {
282 |         word = "fig.show",
283 |         menu = '"asis"',
284 |         user_data = {
285 |             descr = "How to show/arrange the plots. Possible values are as follows:\n- \\ asis\\ = Show plots exactly in places where they were generated (as if the code were run in an R terminal).\n- \\ hold\\ = Hold all plots and output them at the end of a code chunk.\n- \\ animate\\ = Concatenate all plots into an animation if there are multiple plots in a chunk.\n- \\ hide\\ = Generate plot files but hide them in the output document.",
286 |         },
287 |     },
288 |     {
289 |         word = "dev",
290 |         menu = '"pdf"|"png"',
291 |         user_data = {
292 |             descr = '("pdf" for LaTeX output and "png" for HTML/Markdown; character) The graphical device to generate plot files. All graphics devices in base R and those in Cairo, cairoDevice, svglite, ragg, and tikzDevice are supported, e.g., pdf, png, svg, jpeg, tiff, cairo_pdf, CairoJPEG, CairoPNG, Cairo_pdf, Cairo_png, svglite, ragg_png, tikz, and so on. See names(knitr:::auto_exts) for the full list. Besides these devices, you can also provide a character string that is the name of a function of the form function(filename, width, height). The units for the image size are always inches (even for bitmap devices, in which DPI is used to convert between pixels and inches). The chunk options dev, fig.ext, fig.width, fig.height, and dpi can be vectors (shorter ones will be recycled), e.g., dev = c("pdf", "png") creates a PDF and a PNG file for the same plot.',
293 |         },
294 |     },
295 |     {
296 |         word = "dev.args",
297 |         menu = "NULL",
298 |         user_data = {
299 |             descr = 'More arguments to be passed to the device, e.g., dev.args = list(bg = "yellow", pointsize = 10) for dev = "png". This option depends on the specific device (see the device documentation). When dev contains multiple devices, dev.args can be a list of lists of arguments, and each list of arguments is passed to each individual device, e.g., dev = c("pdf", "tiff"), dev.args = list(pdf = list(colormodel = "cmyk", useDingats = TRUE), tiff = list(compression = "lzw")).',
300 |         },
301 |     },
302 |     {
303 |         word = "fig.ext",
304 |         menu = "NULL",
305 |         user_data = {
306 |             descr = "File extension of the figure output. If NULL, it will be derived from the graphical device; see knitr:::auto_exts for details.",
307 |         },
308 |     },
309 |     {
310 |         word = "dpi",
311 |         menu = "72",
312 |         user_data = {
313 |             descr = "The DPI (dots per inch) for bitmap devices (dpi * inches = pixels).",
314 |         },
315 |     },
316 |     {
317 |         word = "fig.width",
318 |         menu = "7",
319 |         user_data = {
320 |             descr = "Width of the plot (in inches), to be used in the graphics device.",
321 |         },
322 |     },
323 |     {
324 |         word = "fig.height",
325 |         menu = "7",
326 |         user_data = {
327 |             descr = "Height of the plot (in inches), to be used in the graphics device.",
328 |         },
329 |     },
330 |     {
331 |         word = "fig.asp",
332 |         menu = "NULL",
333 |         user_data = {
334 |             descr = "The aspect ratio of the plot, i.e., the ratio of height/width. When fig.asp is specified, the height of a plot (the chunk option fig.height) is calculated from fig.width * fig.asp.",
335 |         },
336 |     },
337 |     {
338 |         word = "fig.dim",
339 |         menu = "NULL",
340 |         user_data = {
341 |             descr = "A numeric vector of length 2 to provide fig.width and fig.height, e.g., fig.dim = c(5, 7) is a shorthand of fig.width = 5, fig.height = 7. If both fig.asp and fig.dim are provided, fig.asp will be ignored (with a warning).",
342 |         },
343 |     },
344 |     {
345 |         word = "out.width",
346 |         menu = "NULL",
347 |         user_data = {
348 |             descr = "Width of the plot in the output document, which can be different with its physical fig.width and fig.height, i.e., plots can be scaled in the output document. Depending on the output format, these two options can take special values. For example, for LaTeX output, they can be .8\\linewidth, 3in, or 8cm; for HTML, they may be 300px. For .",
349 |         },
350 |     },
351 |     {
352 |         word = "out.height",
353 |         menu = "NULL",
354 |         user_data = {
355 |             descr = "Height of the plot in the output document, which can be different with its physical fig.width and fig.height, i.e., plots can be scaled in the output document. Depending on the output format, these two options can take special values. For example, for LaTeX output, they can be .8\\linewidth, 3in, or 8cm; for HTML, they may be 300px. For .",
356 |         },
357 |     },
358 |     {
359 |         word = "out.extra",
360 |         menu = "NULL",
361 |         user_data = {
362 |             descr = "Extra options for figures. It can be an arbitrary string, to be inserted in \\includegraphics[] in LaTeX output (e.g., out.extra = \"angle=90\" to rotate the figure by 90 degrees), or  in HTML output (e.g., out.extra = ''style=\"border:5px solid orange;\"'').",
363 |         },
364 |     },
365 |     {
366 |         word = "fig.retina",
367 |         menu = "1",
368 |         user_data = {
369 |             descr = "This option only applies to HTML output. For Retina displays, setting this option to a ratio (usually 2) will change the chunk option dpi to dpi * fig.retina, and out.width to fig.width * dpi / fig.retina internally. For example, the physical size of an image is doubled, and its display size is halved when fig.retina = 2.",
370 |         },
371 |     },
372 |     {
373 |         word = "resize.width",
374 |         menu = "NULL",
375 |         user_data = {
376 |             descr = "The width to be used in \\resizebox{}{} in LaTeX output. The option is not needed unless you want to resize TikZ graphics, because there is no natural way to do it. However, according to the tikzDevice authors, TikZ graphics are not meant to be resized, to maintain consistency in style with other text in LaTeX. If only one of them is NULL, ! will be used (read the documentation of graphicx if you do not understand this).",
377 |         },
378 |     },
379 |     {
380 |         word = "resize.height",
381 |         menu = "NULL",
382 |         user_data = {
383 |             descr = "The height to be used in \\resizebox{}{} in LaTeX output. The option is not needed unless you want to resize TikZ graphics, because there is no natural way to do it. However, according to the tikzDevice authors, TikZ graphics are not meant to be resized, to maintain consistency in style with other text in LaTeX. If only one of them is NULL, ! will be used (read the documentation of graphicx if you do not understand this).",
384 |         },
385 |     },
386 |     {
387 |         word = "fig.align",
388 |         menu = '"default"',
389 |         user_data = {
390 |             descr = 'Alignment of figures in the output document. Possible values are "default", "left", "right", and "center". The default is not to make any alignment adjustments.',
391 |         },
392 |     },
393 |     {
394 |         word = "fig.link",
395 |         menu = "NULL",
396 |         user_data = { descr = "A link to be added onto the figure." },
397 |     },
398 |     {
399 |         word = "fig.env",
400 |         menu = '"figure"',
401 |         user_data = {
402 |             descr = 'The LaTeX environment for figures, e.g., you may set fig.env = "marginfigure" to get \\begin{marginfigure}. This option requires fig.cap be specified.',
403 |         },
404 |     },
405 |     { word = "fig.cap", menu = "NULL", user_data = { descr = "A figure caption." } },
406 |     {
407 |         word = "fig.alt",
408 |         menu = "NULL",
409 |         user_data = {
410 |             descr = "The alternative text to be used in the alt attribute of the  tags of figures in HTML output. By default, the chunk option fig.cap will be used as the alternative text if provided.",
411 |         },
412 |     },
413 |     {
414 |         word = "fig.scap",
415 |         menu = "NULL",
416 |         user_data = {
417 |             descr = "A short caption. This option is only meaningful to LaTeX output. A short caption is inserted in \\caption[], and usually displayed in the “List of Figures” of a PDF document.",
418 |         },
419 |     },
420 |     {
421 |         word = "fig.lp",
422 |         menu = '"fig:"',
423 |         user_data = {
424 |             descr = "A label prefix for the figure label to be inserted in \\label{}. The actual label is made by concatenating this prefix and the chunk label, e.g., the figure label for `{r, foo-plot}` will be `fig:foo-plot` by default.",
425 |         },
426 |     },
427 |     {
428 |         word = "fig.pos",
429 |         menu = '""',
430 |         user_data = {
431 |             descr = "A character string for the figure position arrangement to be used in \\begin{figure}[].",
432 |         },
433 |     },
434 |     {
435 |         word = "fig.subcap",
436 |         menu = "NULL",
437 |         user_data = {
438 |             descr = "Captions for subfigures. When there are multiple plots in a chunk, and neither fig.subcap nor fig.cap is NULL, \\subfloat{} will be used for individual plots (you need to add \\usepackage{subfig} in the preamble).",
439 |         },
440 |     },
441 |     {
442 |         word = "fig.ncol",
443 |         menu = "NULL",
444 |         user_data = {
445 |             descr = "The number of columns of subfigures; see this issue for examples (note that fig.ncol and fig.sep only work for LaTeX output).",
446 |         },
447 |     },
448 |     {
449 |         word = "fig.sep",
450 |         menu = "NULL",
451 |         user_data = {
452 |             descr = 'A character vector of separators to be inserted among subfigures. When fig.ncol is specified, fig.sep defaults to a character vector of which every N-th element is \\newline (where N is the number of columns), e.g., fig.ncol = 2 means fig.sep = c("", "", "\\newline", "", "", "\\newline", "", ...).',
453 |         },
454 |     },
455 |     {
456 |         word = "fig.process",
457 |         menu = "NULL",
458 |         user_data = {
459 |             descr = "A function to post-process figure files. It should take the path of a figure file, and return the (new) path of the figure to be inserted in the output. If the function contains the options argument, the list of chunk options will be passed to this argument.",
460 |         },
461 |     },
462 |     {
463 |         word = "fig.showtext",
464 |         menu = "NULL",
465 |         user_data = {
466 |             descr = "If TRUE, call `showtext::showtext_begin()` before drawing plots. See the documentation of the showtext package for details.",
467 |         },
468 |     },
469 |     {
470 |         word = "external",
471 |         menu = "TRUE",
472 |         user_data = {
473 |             descr = 'Whether to externalize tikz graphics (pre-compile tikz graphics to PDF). It is only used for the `tikz()` device in the tikzDevice package (i.e., when dev="tikz"), and it can save time for LaTeX compilation.',
474 |         },
475 |     },
476 |     {
477 |         word = "sanitize",
478 |         menu = "FALSE",
479 |         user_data = {
480 |             descr = "Whether to sanitize tikz graphics (escape special LaTeX characters). See the documentation of the tikzDevice package.",
481 |         },
482 |     },
483 |     {
484 |         word = "interval",
485 |         menu = "1",
486 |         user_data = {
487 |             descr = "Time interval (number of seconds) between animation frames.",
488 |         },
489 |     },
490 |     {
491 |         word = "animation.hook",
492 |         menu = "knitr::hook_ffmpeg_html",
493 |         user_data = {
494 |             descr = 'A hook function to create animations in HTML output; the default hook uses FFmpeg to convert images to a WebM video. This option can also take a character string "ffmpeg" or "gifski" as a shorthand of the corresponding hook function, e.g., animation.hook = "gifski" means animation.hook = knitr::hook_gifski.',
495 |         },
496 |     },
497 |     {
498 |         word = "aniopts",
499 |         menu = '"controls,loop"',
500 |         user_data = {
501 |             descr = "Extra options for animations; see the documentation of the LaTeX animate package.",
502 |         },
503 |     },
504 |     {
505 |         word = "ffmpeg.bitrate",
506 |         menu = '"1M"',
507 |         user_data = {
508 |             descr = "To be passed to the -b:v argument of FFmpeg to control the quality of WebM videos.",
509 |         },
510 |     },
511 |     {
512 |         word = "ffmpeg.format",
513 |         menu = '"webm"',
514 |         user_data = {
515 |             descr = "The video format of FFmpeg, i.e., the filename extension of the video.",
516 |         },
517 |     },
518 |     {
519 |         word = "code",
520 |         menu = "NULL",
521 |         user_data = {
522 |             descr = 'If provided, it will override the code in the current chunk. This allows us to programmatically insert code into the current chunk. For example, code = readLines("test.R") will use the content of the file test.R as the code for the current chunk.',
523 |         },
524 |     },
525 |     {
526 |         word = "ref.label",
527 |         menu = "NULL",
528 |         user_data = {
529 |             descr = "A character vector of labels of the chunks from which the code of the current chunk is inherited (see the demo for chunk references). If the vector is wrapped in `I()` and the chunk option opts.label is not set, it means that the current chunk will also inherit the chunk options (in addition to the code) of the referenced chunks. See the chunk option opts.label for more information on inheriting chunk options.",
530 |         },
531 |     },
532 |     {
533 |         word = "child",
534 |         menu = "NULL",
535 |         user_data = {
536 |             descr = "A character vector of paths of child documents to be knitted and input into the main document.",
537 |         },
538 |     },
539 |     {
540 |         word = "engine",
541 |         menu = '"R"',
542 |         user_data = {
543 |             descr = "The language name of the code chunk. Possible values can be found in `names(knitr::knit_engines$get())`, e.g., python, sql, julia, bash, and c, etc. The object knitr::knit_engines can be used to set up engines for other languages. The demo page contains examples of different engines.",
544 |         },
545 |     },
546 |     {
547 |         word = "engine.path",
548 |         menu = "NULL",
549 |         user_data = {
550 |             descr = 'The path to the executable of the engine. This option makes it possible to use alternative executables in your system, e.g., the default python may be at /usr/bin/python, and you may set engine.path = "~/anaconda/bin/python" to use a different version of Python. engine.path can also be a list of paths, which makes it possible to set different engine paths for different engines.',
551 |         },
552 |     },
553 |     {
554 |         word = "engine.opts",
555 |         menu = "NULL",
556 |         user_data = {
557 |             descr = "Additional arguments passed to the engines. At the chunk level, the option can be specified as a string or a list of options.",
558 |         },
559 |     },
560 |     {
561 |         word = "opts.label",
562 |         menu = "NULL",
563 |         user_data = {
564 |             descr = "This option provides a mechanism to inherit chunk options from either the option template knitr::opts_template (see ?knitr::opts_template) or other code chunks. It takes a character vector of labels. For each label in the vector, knitr will first try to find chunk options set in knitr::opts_template with this label, and if found, apply these chunk options to the current chunk. Then try to find another code chunk with this label (called the “referenced code chunk”) in the document, and if found, also apply its chunk options to the current chunk. The precedence of chunk options is: local chunk options > referenced code chunk options > knitr::opts_template > knitr::opts_chunk. The special value opts.label = TRUE means opts.label = ref.label, i.e., to inherit chunk options from chunks referenced by the ref.label option.",
565 |         },
566 |     },
567 |     {
568 |         word = "purl",
569 |         menu = "TRUE",
570 |         user_data = {
571 |             descr = "When running `knitr::purl()` to extract source code from a source document, whether to include or exclude a certain code chunk.",
572 |         },
573 |     },
574 |     {
575 |         word = "R.options",
576 |         menu = "NULL",
577 |         user_data = {
578 |             descr = "Local R options for a code chunk. These options are set temporarily via `options()` before the code chunk, and restored after the chunk.",
579 |         },
580 |     },
581 | }
582 | 
583 | local M = {}
584 | 
585 | M.get_opts = function()
586 |     local copts = {}
587 |     for _, v in pairs(chunk_opts) do
588 |         table.insert(copts, {
589 |             label = v["word"] .. "=",
590 |             kind = cmp.lsp.CompletionItemKind.Field,
591 |             sortText = "0",
592 |             documentation = {
593 |                 kind = cmp.lsp.MarkupKind.Markdown,
594 |                 value = v.user_data.descr,
595 |             },
596 |         })
597 |     end
598 |     return copts
599 | end
600 | 
601 | return M
602 | 


--------------------------------------------------------------------------------
/lua/cmp_r/figtbl.lua:
--------------------------------------------------------------------------------
 1 | local cmp = require("cmp")
 2 | 
 3 | local M = {}
 4 | 
 5 | --- Get fig and tbl labels
 6 | ---@param input string
 7 | ---@return table
 8 | M.get_labels = function(input)
 9 |     local chunks = require("r.quarto").get_code_chunks(0)
10 |     if not chunks then return {} end
11 |     local resp = {}
12 |     for _, c in pairs(chunks) do
13 |         if
14 |             c.comment_params.label
15 |             and (
16 |                 c.comment_params.label:find("^fig") or c.comment_params.label:find("^tbl")
17 |             )
18 |         then
19 |             local lbl = "@" .. c.comment_params.label
20 |             local cap = nil
21 |             if lbl:find("^" .. input) then
22 |                 local item = {
23 |                     label = lbl,
24 |                     kind = cmp.lsp.CompletionItemKind.Reference,
25 |                 }
26 |                 if c.comment_params["fig-cap"] then
27 |                     cap = c.comment_params["fig-cap"]
28 |                 elseif c.comment_params["tbl-cap"] then
29 |                     cap = c.comment_params["tbl-cap"]
30 |                 end
31 |                 if cap then
32 |                     item.documentation = {
33 |                         kind = cmp.lsp.MarkupKind.Markdown,
34 |                         value = cap,
35 |                     }
36 |                 end
37 |                 table.insert(resp, item)
38 |             end
39 |         end
40 |     end
41 |     return resp
42 | end
43 | 
44 | return M
45 | 


--------------------------------------------------------------------------------
/lua/cmp_r/init.lua:
--------------------------------------------------------------------------------
  1 | local cmp = require("cmp")
  2 | local send_to_nvimcom
  3 | 
  4 | local last_compl_item
  5 | local cb_cmp
  6 | local cb_rsv
  7 | local compl_id = 0
  8 | local ter = nil
  9 | local qcell_opts = nil
 10 | local chunk_opts = nil
 11 | local rhelp_keys = nil
 12 | 
 13 | -- Translate symbols added by nvimcom to LSP kinds
 14 | local kindtbl = {
 15 |     ["("] = cmp.lsp.CompletionItemKind.Function, -- function
 16 |     ["$"] = cmp.lsp.CompletionItemKind.Struct, -- data.frame
 17 |     ["%"] = cmp.lsp.CompletionItemKind.Method, -- logical
 18 |     ["~"] = cmp.lsp.CompletionItemKind.Text, -- character
 19 |     ["{"] = cmp.lsp.CompletionItemKind.Value, -- numeric
 20 |     ["!"] = cmp.lsp.CompletionItemKind.Field, -- factor
 21 |     [";"] = cmp.lsp.CompletionItemKind.Constructor, -- control
 22 |     ["["] = cmp.lsp.CompletionItemKind.Struct, -- list
 23 |     ["<"] = cmp.lsp.CompletionItemKind.Class, -- S4
 24 |     [">"] = cmp.lsp.CompletionItemKind.Class, -- S7
 25 |     [":"] = cmp.lsp.CompletionItemKind.Interface, -- environment
 26 |     ["&"] = cmp.lsp.CompletionItemKind.Event, -- promise
 27 |     ["l"] = cmp.lsp.CompletionItemKind.Module, -- library
 28 |     ["a"] = cmp.lsp.CompletionItemKind.Variable, -- function argument
 29 |     ["c"] = cmp.lsp.CompletionItemKind.Field, -- data.frame column
 30 |     ["*"] = cmp.lsp.CompletionItemKind.TypeParameter, -- other
 31 | }
 32 | 
 33 | local options = {
 34 |     filetypes = { "r", "rmd", "quarto", "rnoweb", "rhelp" },
 35 |     doc_width = 58,
 36 |     trigger_characters = { " ", ":", "(", '"', "@", "$" },
 37 |     fun_data_1 = { "select", "rename", "mutate", "filter" },
 38 |     fun_data_2 = { ggplot = { "aes" }, with = { "*" } },
 39 |     quarto_intel = nil,
 40 | }
 41 | 
 42 | local reset_r_compl = function()
 43 |     for _, v in pairs(cmp.core.sources or {}) do
 44 |         if v.name == "cmp_r" then
 45 |             v:reset()
 46 |             break
 47 |         end
 48 |     end
 49 | end
 50 | 
 51 | local send_to_nrs = function(msg)
 52 |     if vim.g.R_Nvim_status and vim.g.R_Nvim_status > 2 then
 53 |         require("r.job").stdin("Server", msg)
 54 |     end
 55 | end
 56 | 
 57 | local fix_doc = function(txt)
 58 |     -- The rnvimserver replaces ' with \019 and \n with \020. We have to revert this:
 59 |     txt = string.gsub(txt, "\020", "\n")
 60 |     txt = string.gsub(txt, "\019", "'")
 61 |     txt = string.gsub(txt, "\018", "\\")
 62 |     return txt
 63 | end
 64 | 
 65 | local backtick = function(s)
 66 |     local t1 = {}
 67 |     for token in string.gmatch(s, "[^$]+") do
 68 |         table.insert(t1, token)
 69 |     end
 70 | 
 71 |     local t3 = {}
 72 |     for _, v in pairs(t1) do
 73 |         local t2 = {}
 74 |         for token in string.gmatch(v, "[^@]+") do
 75 |             if
 76 |                 (not string.find(token, " = $"))
 77 |                 and (
 78 |                     string.find(token, " ")
 79 |                     or string.find(token, "^_")
 80 |                     or string.find(token, "^[0-9]")
 81 |                 )
 82 |             then
 83 |                 table.insert(t2, "`" .. token .. "`")
 84 |             else
 85 |                 table.insert(t2, token)
 86 |             end
 87 |         end
 88 |         table.insert(t3, table.concat(t2, "@"))
 89 |     end
 90 |     return table.concat(t3, "$")
 91 | end
 92 | 
 93 | local get_piped_obj
 94 | get_piped_obj = function(line, lnum)
 95 |     local l
 96 |     l = vim.fn.getline(lnum - 1)
 97 |     if type(l) == "string" and string.find(l, "|>%s*$") then
 98 |         return get_piped_obj(l, lnum - 1)
 99 |     end
100 |     if type(l) == "string" and string.find(l, "%%>%%%s*$") then
101 |         return get_piped_obj(l, lnum - 1)
102 |     end
103 |     if string.find(line, "|>") then return string.match(line, ".-([%w%._]+)%s*|>") end
104 |     if string.find(line, "%%>%%") then
105 |         return string.match(line, ".-([%w%._]+)%s*%%>%%")
106 |     end
107 |     return nil
108 | end
109 | 
110 | local get_first_obj = function(line, lnum)
111 |     local no
112 |     local piece
113 |     local funname
114 |     local firstobj
115 |     local pkg
116 |     no = 0
117 |     local op
118 |     op = string.byte("(")
119 |     local cp
120 |     cp = string.byte(")")
121 |     local idx
122 |     repeat
123 |         idx = #line
124 |         while idx > 0 do
125 |             if line:byte(idx) == op then
126 |                 no = no + 1
127 |             elseif line:byte(idx) == cp then
128 |                 no = no - 1
129 |             end
130 |             if no == 1 then
131 |                 -- The opening parenthesis is here. Now, get the function and
132 |                 -- its first object (if in the same line)
133 |                 piece = string.sub(line, 1, idx - 1)
134 |                 funname = string.match(piece, ".-([%w%._]+)%s*$")
135 |                 if funname then pkg = string.match(piece, ".-([%w%._]+)::" .. funname) end
136 |                 piece = string.sub(line, idx + 1)
137 |                 firstobj = string.match(piece, "%s-([%w%.%_]+)")
138 |                 if funname then idx = string.find(line, funname) end
139 |                 break
140 |             end
141 |             idx = idx - 1
142 |         end
143 |         if funname then break end
144 |         lnum = lnum - 1
145 |         line = vim.fn.getline(lnum)
146 |     until type(line) == "string" and string.find(line, "^%S") or lnum == 0
147 |     return pkg, funname, firstobj, line, lnum, idx
148 | end
149 | 
150 | local need_R_args = function(line, lnum)
151 |     local funname = nil
152 |     local firstobj = nil
153 |     local funname2 = nil
154 |     local firstobj2 = nil
155 |     local listdf = nil
156 |     local nline = nil
157 |     local nlnum = nil
158 |     local cnum = nil
159 |     local lib = nil
160 |     lib, funname, firstobj, nline, nlnum, cnum = get_first_obj(line, lnum)
161 | 
162 |     -- Check if this is function for which we expect to complete data frame column names
163 |     if funname then
164 |         -- Check if the data.frame is supposed to be the first argument:
165 |         for _, v in pairs(options.fun_data_1) do
166 |             if v == funname then
167 |                 listdf = 1
168 |                 break
169 |             end
170 |         end
171 | 
172 |         -- Check if the data.frame is supposed to be the first argument of the
173 |         -- nesting function:
174 |         if not listdf and cnum > 1 then
175 |             nline = string.sub(nline, 1, cnum)
176 |             for k, v in pairs(options.fun_data_2) do
177 |                 for _, a in pairs(v) do
178 |                     if a == "*" or funname == a then
179 |                         _, funname2, firstobj2, nline, nlnum, _ =
180 |                             get_first_obj(nline, nlnum)
181 |                         if funname2 == k then
182 |                             firstobj = firstobj2
183 |                             listdf = 2
184 |                             break
185 |                         end
186 |                     end
187 |                 end
188 |             end
189 |         end
190 |     end
191 | 
192 |     -- Check if the first object was piped
193 |     local pobj = get_piped_obj(nline, nlnum)
194 |     if pobj then firstobj = pobj end
195 |     local resp
196 |     resp = {
197 |         lib = lib,
198 |         fnm = funname,
199 |         fnm2 = funname2,
200 |         firstobj = firstobj,
201 |         listdf = listdf,
202 |         firstobj2 = firstobj2,
203 |         pobj = pobj,
204 |     }
205 |     return resp
206 | end
207 | 
208 | local source = {}
209 | 
210 | source.new = function()
211 |     local self = setmetatable({}, { __index = source })
212 |     return self
213 | end
214 | 
215 | source.setup = function(opts)
216 |     options = vim.tbl_extend("force", options, opts or {})
217 |     if options.doc_width < 30 or options.doc_width > 160 then options.doc_width = 58 end
218 |     vim.env.CMPR_DOC_WIDTH = tostring(options.doc_width)
219 |     if vim.g.R_Nvim_status and vim.g.R_Nvim_status > 2 then
220 |         local job = require("r.job")
221 |         job.stdin("Server", "45" .. tostring(options.doc_width) .. "\n")
222 |     end
223 | end
224 | 
225 | source.get_keyword_pattern = function()
226 |     return "[`\\._@\\$:_[:digit:][:lower:][:upper:]\\u00FF-\\uFFFF]*"
227 | end
228 | 
229 | source.get_trigger_characters = function() return options.trigger_characters end
230 | 
231 | source.get_debug_name = function() return "cmp_r" end
232 | 
233 | source.is_available = function()
234 |     for _, v in pairs(options.filetypes) do
235 |         if vim.bo.filetype == v then return true end
236 |     end
237 |     return false
238 | end
239 | 
240 | source.resolve = function(_, citem, callback)
241 |     cb_rsv = callback
242 |     last_compl_item = citem
243 | 
244 |     if not citem.cls then
245 |         callback(citem)
246 |         return nil
247 |     end
248 | 
249 |     if citem.env == ".GlobalEnv" then
250 |         if citem.cls == "a" then
251 |             callback(citem)
252 |         elseif
253 |             citem.cls == "!"
254 |             or citem.cls == "%"
255 |             or citem.cls == "~"
256 |             or citem.cls == "{"
257 |         then
258 |             send_to_nvimcom(
259 |                 "E",
260 |                 "nvimcom:::nvim.get.summary(" .. citem.label .. ", '" .. citem.env .. "')"
261 |             )
262 |         elseif citem.cls == "(" then
263 |             send_to_nvimcom(
264 |                 "E",
265 |                 'nvimcom:::nvim.GlobalEnv.fun.args("' .. citem.label .. '")'
266 |             )
267 |         else
268 |             send_to_nvimcom(
269 |                 "E",
270 |                 "nvimcom:::nvim.min.info(" .. citem.label .. ", '" .. citem.env .. "')"
271 |             )
272 |         end
273 |         return nil
274 |     end
275 | 
276 |     -- Column of data.frame for fun_data_1 or fun_data_2
277 |     if citem.cls == "c" then
278 |         send_to_nvimcom(
279 |             "E",
280 |             "nvimcom:::nvim.get.summary("
281 |                 .. citem.env
282 |                 .. "$"
283 |                 .. citem.label
284 |                 .. ", '"
285 |                 .. citem.env
286 |                 .. "')"
287 |         )
288 |     elseif citem.cls == "a" then
289 |         local itm = citem.label:gsub(" = ", "")
290 |         local pf = vim.fn.split(citem.env, "\002")
291 |         send_to_nrs("7" .. pf[1] .. "\002" .. pf[2] .. "\002" .. itm .. "\n")
292 |     elseif citem.cls == "l" then
293 |         citem.documentation = {
294 |             value = fix_doc(citem.env),
295 |             kind = cmp.lsp.MarkupKind.Markdown,
296 |         }
297 |         callback(citem)
298 |     elseif
299 |         citem.label:find("%$")
300 |         and (citem.cls == "!" or citem.cls == "%" or citem.cls == "~" or citem.cls == "{")
301 |     then
302 |         send_to_nvimcom(
303 |             "E",
304 |             "nvimcom:::nvim.get.summary(" .. citem.label .. ", '" .. citem.env .. "')"
305 |         )
306 |     else
307 |         send_to_nrs("6" .. citem.label .. "\002" .. citem.env .. "\n")
308 |     end
309 | end
310 | 
311 | source.complete = function(_, request, callback)
312 |     if not vim.g.R_Nvim_status or vim.g.R_Nvim_status < 3 then return end
313 |     cb_cmp = callback
314 | 
315 |     if not send_to_nvimcom then send_to_nvimcom = require("r.run").send_to_nvimcom end
316 | 
317 |     -- Check if this is Rmd and the cursor is in the chunk header
318 |     if
319 |         request.context.filetype == "rmd"
320 |         and string.find(request.context.cursor_before_line, "^```{r")
321 |     then
322 |         if not chunk_opts then chunk_opts = require("cmp_r.chunk").get_opts() end
323 |         callback({ items = chunk_opts })
324 |         return
325 |     end
326 | 
327 |     -- Check if the cursor is in R code
328 |     local lang = "r"
329 |     if request.context.filetype ~= "r" then
330 |         lang = "other"
331 |         local lines = vim.api.nvim_buf_get_lines(
332 |             request.context.bufnr,
333 |             0,
334 |             request.context.cursor.row,
335 |             true
336 |         )
337 |         local lnum = request.context.cursor.row
338 |         if request.context.filetype == "rmd" or request.context.filetype == "quarto" then
339 |             lang = require("r.utils").get_lang()
340 |             if lang == "markdown_inline" then
341 |                 local wrd = string.sub(request.context.cursor_before_line, request.offset)
342 |                 if wrd == "@" then
343 |                     reset_r_compl()
344 |                 elseif wrd:find("^@[tf]") then
345 |                     local lbls = require("cmp_r.figtbl").get_labels(wrd)
346 |                     callback({ items = lbls })
347 |                 end
348 |                 return {}
349 |             end
350 |         elseif request.context.filetype == "rnoweb" then
351 |             for i = lnum, 1, -1 do
352 |                 if string.find(lines[i], "^%s*<<.*>>=") then
353 |                     lang = "r"
354 |                     break
355 |                 elseif string.find(lines[i], "^@") then
356 |                     return {}
357 |                 end
358 |             end
359 |         elseif request.context.filetype == "rhelp" then
360 |             for i = lnum, 1, -1 do
361 |                 if string.find(lines[i], [[\%S+{]]) then
362 |                     if
363 |                         string.find(lines[i], [[\examples{]])
364 |                         or string.find(lines[i], [[\usage{]])
365 |                     then
366 |                         lang = "r"
367 |                     end
368 |                     break
369 |                 end
370 |             end
371 |             if lang ~= "r" then
372 |                 local wrd = string.sub(request.context.cursor_before_line, request.offset)
373 |                 if #wrd == 0 then
374 |                     reset_r_compl()
375 |                     return nil
376 |                 end
377 |                 if wrd == "\\" then
378 |                     if not rhelp_keys then
379 |                         rhelp_keys = require("cmp_r.rhelp").get_keys()
380 |                     end
381 |                     callback({ items = rhelp_keys })
382 |                     return
383 |                 end
384 |             end
385 |         end
386 |     end
387 | 
388 |     -- Is the current cursor position within the YAML header of an R or Python block of code?
389 |     if
390 |         (lang == "r" or lang == "python")
391 |         and string.find(request.context.cursor_before_line, "^#| ")
392 |     then
393 |         if
394 |             string.find(request.context.cursor_before_line, "^#| .*:")
395 |             and not string.find(request.context.cursor_before_line, "^#| .*: !expr ")
396 |         then
397 |             return nil
398 |         end
399 |         if not string.find(request.context.cursor_before_line, "^#| .*: !expr ") then
400 |             if not qcell_opts then
401 |                 qcell_opts = require("cmp_r.quarto").get_cell_opts(options.quarto_intel)
402 |             end
403 |             callback({ items = qcell_opts })
404 |             return
405 |         end
406 |     end
407 | 
408 |     if lang ~= "r" then return {} end
409 | 
410 |     -- check if the cursor is within comment or string
411 |     local snm = ""
412 |     local c = vim.treesitter.get_captures_at_pos(
413 |         0,
414 |         request.context.cursor.row - 1,
415 |         request.context.cursor.col - 2
416 |     )
417 |     if #c > 0 then
418 |         for _, v in pairs(c) do
419 |             if v.capture == "string" then
420 |                 snm = "rString"
421 |             elseif v.capture == "comment" then
422 |                 return nil
423 |             end
424 |         end
425 |     else
426 |         -- We still need to call synIDattr because there is no treesitter parser for rhelp
427 |         snm = vim.fn.synIDattr(
428 |             vim.fn.synID(request.context.cursor.row, request.context.cursor.col - 1, 1),
429 |             "name"
430 |         )
431 |         if snm == "rComment" then return nil end
432 |     end
433 | 
434 |     -- required by rnvimserver
435 |     compl_id = compl_id + 1
436 | 
437 |     local wrd = string.sub(request.context.cursor_before_line, request.offset)
438 |     wrd = string.gsub(wrd, "`", "")
439 |     ter = {
440 |         start = {
441 |             line = request.context.cursor.line,
442 |             character = request.offset - 1,
443 |         },
444 |         ["end"] = {
445 |             line = request.context.cursor.line,
446 |             character = request.context.cursor.character,
447 |         },
448 |     }
449 | 
450 |     -- Should we complete function arguments?
451 |     local nra
452 |     nra = need_R_args(request.context.cursor_before_line, request.context.cursor.row)
453 | 
454 |     if nra.fnm then
455 |         -- We are passing arguments for a function
456 | 
457 |         -- Special completion for library and require
458 |         if
459 |             (nra.fnm == "library" or nra.fnm == "require")
460 |             and (not nra.firstobj or nra.firstobj == wrd)
461 |         then
462 |             send_to_nrs("5" .. compl_id .. "\003\004" .. wrd .. "\n")
463 |             return nil
464 |         end
465 | 
466 |         if snm == "rString" then return nil end
467 | 
468 |         if vim.g.R_Nvim_status < 7 then
469 |             -- Get the arguments of the first function whose name matches nra.fnm
470 |             if nra.lib then
471 |                 send_to_nrs(
472 |                     "5"
473 |                         .. compl_id
474 |                         .. "\003\005"
475 |                         .. wrd
476 |                         .. "\005"
477 |                         .. nra.lib
478 |                         .. "::"
479 |                         .. nra.fnm
480 |                         .. "\n"
481 |                 )
482 |             else
483 |                 send_to_nrs(
484 |                     "5" .. compl_id .. "\003\005" .. wrd .. "\005" .. nra.fnm .. "\n"
485 |                 )
486 |             end
487 |             return nil
488 |         else
489 |             -- Get arguments according to class of first object
490 |             local msg
491 |             msg = 'nvimcom:::nvim_complete_args("'
492 |                 .. compl_id
493 |                 .. '", "'
494 |                 .. nra.fnm
495 |                 .. '", "'
496 |                 .. wrd
497 |                 .. '"'
498 |             if nra.firstobj then
499 |                 msg = msg .. ', firstobj = "' .. nra.firstobj .. '"'
500 |             elseif nra.lib then
501 |                 msg = msg .. ', lib = "' .. nra.lib .. '"'
502 |             end
503 |             if nra.firstobj and nra.listdf then msg = msg .. ", ldf = TRUE" end
504 |             msg = msg .. ")"
505 | 
506 |             -- Save documentation of arguments to be used by rnvimserver
507 |             send_to_nvimcom("E", msg)
508 |             return nil
509 |         end
510 |     end
511 | 
512 |     if snm == "rString" then return nil end
513 | 
514 |     if #wrd == 0 then
515 |         reset_r_compl()
516 |         return nil
517 |     end
518 | 
519 |     send_to_nrs("5" .. compl_id .. "\003" .. wrd .. "\n")
520 | 
521 |     return nil
522 | end
523 | 
524 | ---Callback function for source.resolve(). When cmp_r doesn't have the necessary
525 | ---data for resolving the completion (which happens in most cases), it request
526 | ---the data to rnvimserver which calls back this function.
527 | ---@param txt string The text almost ready to be displayed.
528 | source.resolve_cb = function(txt)
529 |     local s = fix_doc(txt)
530 |     if last_compl_item.def then
531 |         s = last_compl_item.label .. fix_doc(last_compl_item.def) .. "\n---\n" .. s
532 |     end
533 |     last_compl_item.documentation = { kind = cmp.lsp.MarkupKind.Markdown, value = s }
534 |     cb_rsv({ items = { last_compl_item } })
535 | end
536 | 
537 | ---Callback function for source.complete(). When cmp_r doesn't have the
538 | ---necessary data for completion (which happens in most cases), it request the
539 | ---completion data to rnvimserver which calls back this function.
540 | ---@param cid number The completion ID.
541 | ---@param compl table The completion data.
542 | source.complete_cb = function(cid, compl)
543 |     if cid ~= compl_id then return nil end
544 | 
545 |     local resp = {}
546 |     for _, v in pairs(compl) do
547 |         local lbl = string.gsub(v.label, "\019", "'")
548 |         table.insert(resp, {
549 |             label = lbl,
550 |             env = v.env,
551 |             cls = v.cls,
552 |             def = v.def or nil,
553 |             kind = kindtbl[v.cls],
554 |             sortText = v.cls == "a" and "0" or "9",
555 |             textEdit = { newText = backtick(lbl), range = ter },
556 |         })
557 |     end
558 |     cb_cmp(resp)
559 | end
560 | 
561 | return source
562 | 


--------------------------------------------------------------------------------
/lua/cmp_r/quarto.lua:
--------------------------------------------------------------------------------
  1 | local cmp = require("cmp")
  2 | 
  3 | local find_quarto_intel_unix = function(qpath2)
  4 |     if vim.fn.executable("quarto") ~= 1 then return nil end
  5 | 
  6 |     local handle = io.popen("which quarto")
  7 |     if handle then
  8 |         local quarto_bin = handle:read("*a")
  9 |         handle:close()
 10 |         local qpath1 = string.gsub(quarto_bin, "(.*)/.-/.*", "%1")
 11 |         local f = io.open(qpath1 .. qpath2, "r")
 12 |         if f then
 13 |             io.close(f)
 14 |             return qpath1 .. qpath2
 15 |         end
 16 | 
 17 |         handle = io.popen("readlink " .. quarto_bin)
 18 |         if handle then
 19 |             local quarto_dir2 = handle:read("*a")
 20 |             handle:close()
 21 |             quarto_dir2 = string.gsub(quarto_dir2, "(.*)/.-/.*", "%1")
 22 |             if string.find(quarto_dir2, "^%.%./") then
 23 |                 while string.find(quarto_dir2, "^%.%./") do
 24 |                     quarto_dir2 = string.gsub(quarto_dir2, "^%.%./*", "")
 25 |                 end
 26 |                 quarto_dir2 = qpath1 .. "/" .. quarto_dir2
 27 |             end
 28 |             f = io.open(quarto_dir2 .. qpath2, "r")
 29 |             if f then
 30 |                 io.close(f)
 31 |                 return quarto_dir2 .. qpath2
 32 |             end
 33 |         end
 34 |     end
 35 | end
 36 | 
 37 | local find_quarto_intel_windows = function(qpath2)
 38 |     local path = os.getenv("PATH")
 39 |     if path then
 40 |         local paths = vim.fn.split(path, ";")
 41 |         vim.fn.filter(paths, 'v:val =~? "quarto"')
 42 |         if #paths > 0 then
 43 |             local qjson = string.gsub(paths[1], "bin$", qpath2)
 44 |             qjson = string.gsub(qjson, "\\", "/")
 45 |             local f = io.open(qjson, "r")
 46 |             if f then
 47 |                 io.close(f)
 48 |                 return qjson
 49 |             end
 50 |         end
 51 |     end
 52 |     return nil
 53 | end
 54 | 
 55 | local find_quarto_intel = function()
 56 |     local is_windows = vim.loop.os_uname().sysname:find("Windows") ~= nil
 57 |     local qpath2 = "/share/editor/tools/yaml/yaml-intelligence-resources.json"
 58 |     if is_windows then return find_quarto_intel_windows(qpath2) end
 59 |     return find_quarto_intel_unix(qpath2)
 60 | end
 61 | 
 62 | local M = {}
 63 | 
 64 | M.get_cell_opts = function(qmd_intel)
 65 |     local qopts = {}
 66 |     local quarto_yaml_intel
 67 | 
 68 |     if qmd_intel then
 69 |         quarto_yaml_intel = qmd_intel
 70 |     else
 71 |         quarto_yaml_intel = find_quarto_intel()
 72 |     end
 73 | 
 74 |     if not quarto_yaml_intel then return nil end
 75 | 
 76 |     local f = io.open(quarto_yaml_intel, "r")
 77 |     if not f then return nil end
 78 |     local yaml_txt = f:read("*all")
 79 |     f:close()
 80 | 
 81 |     local intel = vim.fn.json_decode(yaml_txt)
 82 |     if not intel then return nil end
 83 | 
 84 |     local cell_keys = {
 85 |         "schema/cell-attributes.yml",
 86 |         "schema/cell-cache.yml",
 87 |         "schema/cell-codeoutput.yml",
 88 |         "schema/cell-figure.yml",
 89 |         "schema/cell-include.yml",
 90 |         "schema/cell-layout.yml",
 91 |         "schema/cell-pagelayout.yml",
 92 |         "schema/cell-table.yml",
 93 |         "schema/cell-textoutput.yml",
 94 |     }
 95 |     for _, s in pairs(cell_keys) do
 96 |         if intel[s] then
 97 |             for _, item in pairs(intel[s]) do
 98 |                 local lbl = item["name"] .. ": "
 99 |                 local descr = nil
100 |                 if type(item["description"]) == "string" then
101 |                     descr = item["description"]
102 |                 else
103 |                     descr = item["description"]["long"]
104 |                 end
105 |                 table.insert(qopts, {
106 |                     label = lbl,
107 |                     kind = cmp.lsp.CompletionItemKind.Field,
108 |                     sortText = "0",
109 |                     documentation = {
110 |                         kind = cmp.lsp.MarkupKind.Markdown,
111 |                         value = descr,
112 |                     },
113 |                 })
114 |             end
115 |         end
116 |     end
117 |     return qopts
118 | end
119 | 
120 | return M
121 | 


--------------------------------------------------------------------------------
/lua/cmp_r/rhelp.lua:
--------------------------------------------------------------------------------
  1 | local cmp = require("cmp")
  2 | 
  3 | local rhelp_opts = {
  4 |     "\\Alpha",
  5 |     "\\Beta",
  6 |     "\\Chi",
  7 |     "\\Delta",
  8 |     "\\Epsilon",
  9 |     "\\Eta",
 10 |     "\\Gamma",
 11 |     "\\Iota",
 12 |     "\\Kappa",
 13 |     "\\Lambda",
 14 |     "\\Mu",
 15 |     "\\Nu",
 16 |     "\\Omega",
 17 |     "\\Omicron",
 18 |     "\\Phi",
 19 |     "\\Pi",
 20 |     "\\Psi",
 21 |     "\\R",
 22 |     "\\Rdversion",
 23 |     "\\Rho",
 24 |     "\\S4method",
 25 |     "\\Sexpr",
 26 |     "\\Sigma",
 27 |     "\\Tau",
 28 |     "\\Theta",
 29 |     "\\Upsilon",
 30 |     "\\Xi",
 31 |     "\\Zeta",
 32 |     "\\acronym",
 33 |     "\\alias",
 34 |     "\\alpha",
 35 |     "\\arguments",
 36 |     "\\author",
 37 |     "\\beta",
 38 |     "\\bold",
 39 |     "\\chi",
 40 |     "\\cite",
 41 |     "\\code",
 42 |     "\\command",
 43 |     "\\concept",
 44 |     "\\cr",
 45 |     "\\dQuote",
 46 |     "\\delta",
 47 |     "\\deqn",
 48 |     "\\describe",
 49 |     "\\description",
 50 |     "\\details",
 51 |     "\\dfn",
 52 |     "\\docType",
 53 |     "\\dontrun",
 54 |     "\\dontshow",
 55 |     "\\donttest",
 56 |     "\\dots",
 57 |     "\\email",
 58 |     "\\emph",
 59 |     "\\encoding",
 60 |     "\\enumerate",
 61 |     "\\env",
 62 |     "\\epsilon",
 63 |     "\\eqn",
 64 |     "\\eta",
 65 |     "\\examples",
 66 |     "\\file",
 67 |     "\\format",
 68 |     "\\gamma",
 69 |     "\\ge",
 70 |     "\\href",
 71 |     "\\iota",
 72 |     "\\item",
 73 |     "\\itemize",
 74 |     "\\kappa",
 75 |     "\\kbd",
 76 |     "\\keyword",
 77 |     "\\lambda",
 78 |     "\\ldots",
 79 |     "\\le",
 80 |     "\\link",
 81 |     "\\linkS4class",
 82 |     "\\method",
 83 |     "\\mu",
 84 |     "\\name",
 85 |     "\\newcommand",
 86 |     "\\note",
 87 |     "\\nu",
 88 |     "\\omega",
 89 |     "\\omicron",
 90 |     "\\option",
 91 |     "\\phi",
 92 |     "\\pi",
 93 |     "\\pkg",
 94 |     "\\preformatted",
 95 |     "\\psi",
 96 |     "\\references",
 97 |     "\\renewcommand",
 98 |     "\\rho",
 99 |     "\\sQuote",
100 |     "\\samp",
101 |     "\\section",
102 |     "\\seealso",
103 |     "\\sigma",
104 |     "\\source",
105 |     "\\special",
106 |     "\\strong",
107 |     "\\subsection",
108 |     "\\synopsis",
109 |     "\\tab",
110 |     "\\tabular",
111 |     "\\tau",
112 |     "\\testonly",
113 |     "\\theta",
114 |     "\\title",
115 |     "\\upsilon",
116 |     "\\url",
117 |     "\\usage",
118 |     "\\value",
119 |     "\\var",
120 |     "\\verb",
121 |     "\\xi",
122 |     "\\zeta",
123 | }
124 | 
125 | local M = {}
126 | 
127 | M.get_keys = function()
128 |     local rhopts = {}
129 |     for _, v in pairs(rhelp_opts) do
130 |         table.insert(rhopts, {
131 |             word = v,
132 |             label = v,
133 |             kind = cmp.lsp.CompletionItemKind.TypeParameter,
134 |         })
135 |     end
136 |     return rhopts
137 | end
138 | 
139 | return M
140 | 


--------------------------------------------------------------------------------
/selene.toml:
--------------------------------------------------------------------------------
1 | std="lua51+vim"
2 | 
3 | [rules]
4 | multiple_statements = "allow"
5 | 


--------------------------------------------------------------------------------
/stylua.toml:
--------------------------------------------------------------------------------
 1 | column_width = 90
 2 | line_endings = "Unix"
 3 | indent_type = "Spaces"
 4 | indent_width = 4
 5 | quote_style = "AutoPreferDouble"
 6 | call_parentheses = "Always"
 7 | collapse_simple_statement = "Always"
 8 | 
 9 | [sort_requires]
10 | enabled = false
11 | 


--------------------------------------------------------------------------------
/vim.toml:
--------------------------------------------------------------------------------
 1 | # This template was adapted from github.com/folke/lazy.nvim
 2 | [selene]
 3 | base = "lua51"
 4 | name = "vim"
 5 | 
 6 | [vim]
 7 | any = true
 8 | 
 9 | [jit]
10 | any = true
11 | 
12 | [[describe.args]]
13 | type = "string"
14 | [[describe.args]]
15 | type = "function"
16 | 
17 | [[it.args]]
18 | type = "string"
19 | [[it.args]]
20 | type = "function"
21 | 
22 | [[before_each.args]]
23 | type = "function"
24 | [[after_each.args]]
25 | type = "function"
26 | 
27 | [assert.is_not]
28 | any = true
29 | 
30 | [[assert.equals.args]]
31 | type = "any"
32 | [[assert.equals.args]]
33 | type = "any"
34 | [[assert.equals.args]]
35 | type = "any"
36 | required = false
37 | 
38 | [[assert.same.args]]
39 | type = "any"
40 | [[assert.same.args]]
41 | type = "any"
42 | 
43 | [[assert.truthy.args]]
44 | type = "any"
45 | 
46 | [[assert.spy.args]]
47 | type = "any"
48 | 
49 | [[assert.stub.args]]
50 | type = "any"
51 | 


--------------------------------------------------------------------------------