1

Regenerate nvim config

This commit is contained in:
2024-06-02 03:29:20 +02:00
parent 75eea0c030
commit ef2e28883d
5576 changed files with 604886 additions and 503 deletions

View File

@ -0,0 +1,5 @@
return {
_all = {
lpath = 'lua/?.lua'
},
}

View File

@ -0,0 +1,8 @@
root = true
[*.lua]
charset = utf-8
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true

View File

@ -0,0 +1,15 @@
ignore = {
"631", -- max_line_length
}
read_globals = {
"vim",
"describe",
"it",
"assert"
}
files['tests'] = {
ignore = {
'121', -- Setting a read-only global variable.
'122', -- Setting a read-only field of a global variable.
}
}

View File

@ -0,0 +1,23 @@
---
name: Lint Code Base
on:
pull_request: ~
push:
branches:
- master
jobs:
build:
name: Lint Code Base
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Lint Code Base
uses: github/super-linter/slim@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_JSCPD: false
VALIDATE_PYTHON_BLACK: false

View File

@ -0,0 +1,32 @@
---
name: Run tests
on:
pull_request: ~
push:
branches:
- master
jobs:
build:
name: Run tests
runs-on: ubuntu-latest
strategy:
matrix:
neovim_version: ['nightly', 'v0.6.1']
steps:
- uses: actions/checkout@v2
- name: Prepare plenary
run: |
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
ln -s "$(pwd)" ~/.local/share/nvim/site/pack/vendor/start
- name: Setup neovim
uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: ${{ matrix.neovim_version }}
- name: Run tests
run: |
nvim --headless --noplugin -u tests/minimal.vim -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/minimal.vim'}"

View File

@ -0,0 +1,15 @@
ignore = {
"631", -- max_line_length
}
read_globals = {
"vim",
"describe",
"it",
"assert"
}
files['tests'] = {
ignore = {
'121', -- Setting a read-only global variable.
'122', -- Setting a read-only field of a global variable.
}
}

View File

@ -0,0 +1,13 @@
{
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
"runtime": {
"version": "LuaJIT"
},
"workspace": {
"library": [
"$VIMRUNTIME",
"${3rd}/luv/library"
],
"checkThirdParty": false
},
}

View File

@ -0,0 +1,675 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -0,0 +1,529 @@
# nvim-lint
An asynchronous linter plugin for Neovim (>= 0.6.0) complementary to the
built-in Language Server Protocol support.
## Motivation & Goals
With [ale][1] we already got an asynchronous linter, why write yet another one?
Because [ale][1] also includes its own language server client.
`nvim-lint` instead has a more narrow scope: It spawns linters, parses their
output, and reports the results via the `vim.diagnostic` module.
`nvim-lint` complements the built-in language server client for languages where
there are no language servers, or where standalone linters provide better
results.
## Installation
- Requires Neovim >= 0.6.0
- `nvim-lint` is a regular plugin and can be installed via the `:h packages`
mechanism or via a plugin manager.
For example:
```bash
git clone \
https://github.com/mfussenegger/nvim-lint.git
~/.config/nvim/pack/plugins/start/nvim-lint
```
- If using [vim-plug][3]: `Plug 'mfussenegger/nvim-lint'`
- If using [packer.nvim][4]: `use 'mfussenegger/nvim-lint'`
## Usage
Configure the linters you want to run per file type. For example:
```lua
require('lint').linters_by_ft = {
markdown = {'vale',}
}
```
Then setup a autocmd to trigger linting. For example:
```vimL
au BufWritePost * lua require('lint').try_lint()
```
or with Lua autocmds (requires 0.7):
```lua
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
callback = function()
-- try_lint without arguments runs the linters defined in `linters_by_ft`
-- for the current filetype
require("lint").try_lint()
-- You can call `try_lint` with a linter name or a list of names to always
-- run specific linters, independent of the `linters_by_ft` configuration
require("lint").try_lint("cspell")
end,
})
```
Some linters require a file to be saved to disk, others support linting `stdin`
input. For such linters you could also define a more aggressive autocmd, for
example on the `InsertLeave` or `TextChanged` events.
If you want to customize how the diagnostics are displayed, read `:help
vim.diagnostic.config`.
## Available Linters
There is a generic linter called `compiler` that uses the `makeprg` and
`errorformat` options of the current buffer.
Other dedicated linters that are built-in are:
| Tool | Linter name |
| -------------------------------------- | ---------------------- |
| Set via `makeprg` | `compiler` |
| [actionlint][actionlint] | `actionlint` |
| [alex][alex] | `alex` |
| [ansible-lint][ansible-lint] | `ansible_lint` |
| [bandit][bandit] | `bandit` |
| [bean-check][bean-check] | `bean_check` |
| [biomejs][biomejs] | `biomejs` |
| [blocklint][blocklint] | `blocklint` |
| [buf_lint][buf_lint] | `buf_lint` |
| [buildifier][buildifier] | `buildifier` |
| [cfn-lint][cfn-lint] | `cfn_lint` |
| [cfn_nag][cfn_nag] | `cfn_nag` |
| [checkmake][checkmake] | `checkmake` |
| [checkpatch.pl][checkpatch] | `checkpatch` |
| [checkstyle][checkstyle] | `checkstyle` |
| [chktex][20] | `chktex` |
| [clang-tidy][23] | `clangtidy` |
| [clazy][30] | `clazy` |
| [clj-kondo][24] | `clj-kondo` |
| [cmakelint][cmakelint] | `cmakelint` |
| [codespell][18] | `codespell` |
| [commitlint][commitlint] | `commitlint` |
| [cppcheck][22] | `cppcheck` |
| [cpplint][cpplint] | `cpplint` |
| [credo][credo] | `credo` |
| [cspell][36] | `cspell` |
| [cue][cue] | `cue` |
| [curlylint][curlylint] | `curlylint` |
| [dash][dash] | `dash` |
| [deadnix][deadnix] | `deadnix` |
| [deno][deno] | `deno` |
| [DirectX Shader Compiler][dxc] | `dxc` |
| [djlint][djlint] | `djlint` |
| [dotenv-linter][dotenv-linter] | `dotenv_linter` |
| [editorconfig-checker][ec] | `editorconfig-checker` |
| [erb-lint][erb-lint] | `erb_lint` |
| [ESLint][25] | `eslint` |
| [eslint_d][37] | `eslint_d` |
| [fennel][fennel] | `fennel` |
| [fish][fish] | `fish` |
| [Flake8][13] | `flake8` |
| [flawfinder][35] | `flawfinder` |
| [gdlint (gdtoolkit)][gdlint] | `gdlint` |
| [gitlint][gitlint] | `gitlint` |
| [glslc][glslc] | `glslc` |
| [Golangci-lint][16] | `golangcilint` |
| [hadolint][28] | `hadolint` |
| [hlint][32] | `hlint` |
| [htmlhint][htmlhint] | `htmlhint` |
| [HTML Tidy][12] | `tidy` |
| [Inko][17] | `inko` |
| [janet][janet] | `janet` |
| [joker][joker] | `joker` |
| [jshint][jshint] | `jshint` |
| [jsonlint][jsonlint] | `jsonlint` |
| [ktlint][ktlint] | `ktlint` |
| [lacheck][lacheck] | `lacheck` |
| [Languagetool][5] | `languagetool` |
| [luacheck][19] | `luacheck` |
| [markdownlint][26] | `markdownlint` |
| [markdownlint-cli2][markdownlint-cli2] | `markdownlint-cli2` |
| [markuplint][markuplint] | `markuplint` |
| [mlint][34] | `mlint` |
| [Mypy][11] | `mypy` |
| [Nagelfar][nagelfar] | `nagelfar` |
| [Nix][nix] | `nix` |
| [npm-groovy-lint][npm-groovy-lint] | `npm-groovy-lint` |
| [oelint-adv][oelint-adv] | `oelint-adv` |
| [opa_check][opa_check] | `opa_check` |
| [oxlint][oxlint] | `oxlint` |
| [perlcritic][perlcritic] | `perlcritic` |
| [perlimports][perlimports] | `perlimports` |
| [phpcs][phpcs] | `phpcs` |
| [phpinsights][phpinsights] | `phpinsights` |
| [phpmd][phpmd] | `phpmd` |
| [php][php] | `php` |
| [phpstan][phpstan] | `phpstan` |
| [ponyc][ponyc] | `pony` |
| [prisma-lint][prisma-lint] | `prisma-lint` |
| [proselint][proselint] | `proselint` |
| [psalm][psalm] | `psalm` |
| [puppet-lint][puppet-lint] | `puppet-lint` |
| [pycodestyle][pcs-docs] | `pycodestyle` |
| [pydocstyle][pydocstyle] | `pydocstyle` |
| [Pylint][15] | `pylint` |
| [pyproject-flake8][pflake8] | `pflake8` |
| [quick-lint-js][quick-lint-js] | `quick-lint-js` |
| [regal][regal] | `regal` |
| [Revive][14] | `revive` |
| [rflint][rflint] | `rflint` |
| [robocop][robocop] | `robocop` |
| [RPM][rpm] | `rpmspec` |
| [rstcheck][rstcheck] | `rstcheck` |
| [rstlint][rstlint] | `rstlint` |
| [RuboCop][rubocop] | `rubocop` |
| [Ruby][ruby] | `ruby` |
| [Ruff][ruff] | `ruff` |
| [salt-lint][salt-lint] | `saltlint` |
| [Selene][31] | `selene` |
| [ShellCheck][10] | `shellcheck` |
| [snyk][snyk] | `snyk_iac` |
| [Solhint][solhint] | `solhint` |
| [sqlfluff][sqlfluff] | `sqlfluff` |
| [standardjs][standardjs] | `standardjs` |
| [StandardRB][27] | `standardrb` |
| [statix check][33] | `statix` |
| [stylelint][29] | `stylelint` |
| [SwiftLint][swiftlint] | `swiftlint` |
| [systemdlint][systemdlint] | `systemdlint` |
| [tflint][tflint] | `tflint` |
| [tfsec][tfsec] | `tfsec` |
| [tlint][tlint] | `tlint` |
| [trivy][trivy] | `trivy` |
| [typos][typos] | `typos` |
| [Vala][vala-lint] | `vala_lint` |
| [Vale][8] | `vale` |
| [Verilator][verilator] | `verilator` |
| [vint][21] | `vint` |
| [vulture][vulture] | `vulture` |
| [woke][woke] | `woke` |
| [write-good][write-good] | `write_good` |
| [yamllint][yamllint] | `yamllint` |
| [zsh][zsh] | `zsh` |
## Custom Linters
You can register custom linters by adding them to the `linters` table, but
please consider contributing a linter if it is missing.
```lua
require('lint').linters.your_linter_name = {
cmd = 'linter_cmd',
stdin = true, -- or false if it doesn't support content input via stdin. In that case the filename is automatically added to the arguments.
append_fname = true, -- Automatically append the file name to `args` if `stdin = false` (default: true)
args = {}, -- list of arguments. Can contain functions with zero arguments that will be evaluated once the linter is used.
stream = nil, -- ('stdout' | 'stderr' | 'both') configure the stream to which the linter outputs the linting result.
ignore_exitcode = false, -- set this to true if the linter exits with a code != 0 and that's considered normal.
env = nil, -- custom environment table to use with the external process. Note that this replaces the *entire* environment, it is not additive.
parser = your_parse_function
}
```
Instead of declaring the linter as a table, you can also declare it as a
function which returns the linter table in case you want to dynamically
generate some of the properties.
`your_parse_function` can be a function which takes three arguments:
- `output`
- `bufnr`
- `linter_cwd`
The `output` is the output generated by the linter command.
The function must return a list of diagnostics as specified in `:help
diagnostic-structure`.
You can override the environment that the linting process runs in by setting
the `env` key, e.g.
```lua
env = { ["FOO"] = "bar" }
```
Note that this completely overrides the environment, it does not add new
environment variables. The one exception is that the `PATH` variable will be
preserved if it is not explicitly set.
You can generate a parse function from a Lua pattern or from an `errorformat`
using the function in the `lint.parser` module:
### from_errorformat
```lua
parser = require('lint.parser').from_errorformat(errorformat)
```
The function takes two arguments: `errorformat` and `skeleton` (optional).
### from_pattern
```lua
parser = require('lint.parser').from_pattern(pattern, groups, severity_map, defaults, opts)
```
The function allows to parse the linter's output using a Lua regular expression pattern.
- pattern: The regular expression pattern applied on each line of the output
- groups: The groups specified by the pattern
Available groups:
- `lnum`
- `end_lnum`
- `col`
- `end_col`
- `message`
- `file`
- `severity`
- `code`
The order of the groups must match the order of the captures within the pattern.
An example:
```lua
local pattern = '[^:]+:(%d+):(%d+):(%w+):(.+)'
local groups = { 'lnum', 'col', 'code', 'message' }
```
- severity: A mapping from severity codes to diagnostic codes
``` lua
default_severity = {
['error'] = vim.diagnostic.severity.ERROR,
['warning'] = vim.diagnostic.severity.WARN,
['information'] = vim.diagnostic.severity.INFO,
['hint'] = vim.diagnostic.severity.HINT,
}
```
- defaults: The defaults diagnostic values
```lua
defaults = {["source"] = "mylint-name"}
```
- opts: Additional options
- `lnum_offset`: Added to `lnum`. Defaults to 0
- `end_lnum_offset`: Added to `end_lnum`. Defaults to 0
- `end_col_offset`: offset added to `end_col`. Defaults to `-1`, assuming
that the end-column position is exclusive.
## Customize built-in linters
You can import a linter and modify its properties. An example:
```lua
local phpcs = require('lint').linters.phpcs
phpcs.args = {
'-q',
-- <- Add a new parameter here
'--report=json',
'-'
}
```
You can also post-process the diagnostics produced by a linter by wrapping it.
For example, to change the severity of all diagnostics created by `cspell`:
```lua
local lint = require("lint")
lint.linters.cspell = require("lint.util").wrap(lint.linters.cspell, function(diagnostic)
diagnostic.severity = vim.diagnostic.severity.HINT
return diagnostic
end)
```
## Display configuration
See `:help vim.diagnostic.config`.
If you want to have different settings per linter, you can get the `namespace`
for a linter via `require("lint").get_namespace("linter_name")`. An example:
```lua
local ns = require("lint").get_namespace("my_linter_name")
vim.diagnostic.config({ virtual_text = true }, ns)
```
## Get the current running linters for your buffer
You can see which linters are running with `require("lint").get_running()`.
To include the running linters in the status line you could format them like this:
```lua
local lint_progress = function()
local linters = require("lint").get_running()
if #linters == 0 then
return "󰦕"
end
return "󱉶 " .. table.concat(linters, ", ")
end
```
## Alternatives
- [Ale][1]
- [efm-langserver][6]
- [diagnostic-languageserver][7]
## Development ☢️
### Run tests
Running tests requires [busted][busted].
See [neorocks][neorocks] or [Using Neovim as Lua interpreter with
Luarocks][neovim-luarocks] for installation instructions.
```bash
busted tests/
```
[1]: https://github.com/dense-analysis/ale
[3]: https://github.com/junegunn/vim-plug
[4]: https://github.com/wbthomason/packer.nvim
[5]: https://languagetool.org/
[6]: https://github.com/mattn/efm-langserver
[7]: https://github.com/iamcco/diagnostic-languageserver
[8]: https://github.com/errata-ai/vale
[10]: https://www.shellcheck.net/
[11]: http://mypy-lang.org/
[12]: https://www.html-tidy.org/
[13]: https://flake8.pycqa.org/
[14]: https://github.com/mgechev/revive
[15]: https://pylint.org/
[16]: https://golangci-lint.run/
[17]: https://inko-lang.org/
[18]: https://github.com/codespell-project/codespell
[19]: https://github.com/mpeterv/luacheck
[20]: https://www.nongnu.org/chktex
[21]: https://github.com/Vimjas/vint
[22]: https://github.com/danmar/cppcheck/
[23]: https://clang.llvm.org/extra/clang-tidy/
[24]: https://github.com/clj-kondo/clj-kondo
[25]: https://github.com/eslint/eslint
[26]: https://github.com/DavidAnson/markdownlint
[27]: https://github.com/testdouble/standard
[28]: https://github.com/hadolint/hadolint
[29]: https://github.com/stylelint/stylelint
[30]: https://github.com/KDE/clazy
[31]: https://github.com/Kampfkarren/selene
[32]: https://github.com/ndmitchell/hlint
[33]: https://github.com/NerdyPepper/statix
[34]: https://www.mathworks.com/help/matlab/ref/mlint.html
[35]: https://github.com/david-a-wheeler/flawfinder
[36]: https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell
[37]: https://github.com/mantoni/eslint_d.js
[neorocks]: https://github.com/nvim-neorocks/neorocks
[neovim-luarocks]: https://zignar.net/2023/01/21/using-luarocks-as-lua-interpreter-with-luarocks/
[busted]: https://lunarmodules.github.io/busted/
[ansible-lint]: https://docs.ansible.com/lint.html
[pcs-docs]: https://pycodestyle.pycqa.org/en/latest/
[pydocstyle]: https://www.pydocstyle.org/en/stable/
[prisma-lint]: https://github.com/loop-payments/prisma-lint
[checkpatch]: https://docs.kernel.org/dev-tools/checkpatch.html
[checkstyle]: https://checkstyle.sourceforge.io/
[jshint]: https://jshint.com/
[jsonlint]: https://github.com/zaach/jsonlint
[rflint]: https://github.com/boakley/robotframework-lint
[robocop]: https://github.com/MarketSquare/robotframework-robocop
[vulture]: https://github.com/jendrikseipp/vulture
[yamllint]: https://github.com/adrienverge/yamllint
[cpplint]: https://github.com/cpplint/cpplint
[proselint]: https://github.com/amperser/proselint
[cmakelint]: https://github.com/cmake-lint/cmake-lint
[rstcheck]: https://github.com/myint/rstcheck
[rstlint]: https://github.com/twolfson/restructuredtext-lint
[ktlint]: https://github.com/pinterest/ktlint
[php]: https://www.php.net/
[phpcs]: https://github.com/squizlabs/PHP_CodeSniffer
[phpinsights]: https://github.com/nunomaduro/phpinsights
[phpmd]: https://phpmd.org/
[phpstan]: https://phpstan.org/
[psalm]: https://psalm.dev/
[lacheck]: https://www.ctan.org/tex-archive/support/lacheck
[credo]: https://github.com/rrrene/credo
[glslc]: https://github.com/google/shaderc
[rubocop]: https://github.com/rubocop/rubocop
[dxc]: https://github.com/microsoft/DirectXShaderCompiler
[cfn-lint]: https://github.com/aws-cloudformation/cfn-lint
[fennel]: https://github.com/bakpakin/Fennel
[nix]: https://github.com/NixOS/nix
[ruby]: https://github.com/ruby/ruby
[npm-groovy-lint]: https://github.com/nvuillam/npm-groovy-lint
[nagelfar]: https://nagelfar.sourceforge.net/
[oelint-adv]: https://github.com/priv-kweihmann/oelint-adv
[cfn_nag]: https://github.com/stelligent/cfn_nag
[checkmake]: https://github.com/mrtazz/checkmake
[ruff]: https://github.com/astral-sh/ruff
[janet]: https://github.com/janet-lang/janet
[bandit]: https://bandit.readthedocs.io/en/latest/
[bean-check]: https://beancount.github.io/docs/running_beancount_and_generating_reports.html#bean-check
[cue]: https://github.com/cue-lang/cue
[curlylint]: https://www.curlylint.org/
[sqlfluff]: https://github.com/sqlfluff/sqlfluff
[verilator]: https://verilator.org/guide/latest/
[actionlint]: https://github.com/rhysd/actionlint
[buf_lint]: https://github.com/bufbuild/buf
[erb-lint]: https://github.com/shopify/erb-lint
[tfsec]: https://github.com/aquasecurity/tfsec
[tlint]: https://github.com/tighten/tlint
[trivy]: https://github.com/aquasecurity/trivy
[djlint]: https://djlint.com/
[buildifier]: https://github.com/bazelbuild/buildtools/tree/master/buildifier
[solhint]: https://protofire.github.io/solhint/
[perlimports]: https://github.com/perl-ide/App-perlimports
[perlcritic]: https://github.com/Perl-Critic/Perl-Critic
[ponyc]: https://github.com/ponylang/ponyc
[gdlint]: https://github.com/Scony/godot-gdscript-toolkit
[rpm]: https://rpm.org
[ec]: https://github.com/editorconfig-checker/editorconfig-checker
[deno]: https://github.com/denoland/deno
[standardjs]: https://standardjs.com/
[biomejs]: https://github.com/biomejs/biome
[commitlint]: https://commitlint.js.org
[alex]: https://alexjs.com/
[blocklint]: https://github.com/PrincetonUniversity/blocklint
[woke]: https://docs.getwoke.tech/
[write-good]: https://github.com/btford/write-good
[dotenv-linter]: https://dotenv-linter.github.io/
[puppet-lint]: https://github.com/puppetlabs/puppet-lint
[snyk]: https://github.com/snyk/cli
[gitlint]: https://github.com/jorisroovers/gitlint
[pflake8]: https://github.com/csachs/pyproject-flake8
[fish]: https://github.com/fish-shell/fish-shell
[zsh]: https://www.zsh.org/
[typos]: https://github.com/crate-ci/typos
[joker]: https://github.com/candid82/joker
[dash]: http://gondor.apana.org.au/~herbert/dash
[deadnix]: https://github.com/astro/deadnix
[salt-lint]: https://github.com/warpnet/salt-lint
[quick-lint-js]: https://quick-lint-js.com
[opa_check]: https://www.openpolicyagent.org/
[oxlint]: https://oxc-project.github.io/
[regal]: https://github.com/StyraInc/regal
[vala-lint]: https://github.com/vala-lang/vala-lint
[systemdlint]: https://github.com/priv-kweihmann/systemdlint
[htmlhint]: https://htmlhint.com/
[markuplint]: https://markuplint.dev/
[markdownlint-cli2]: https://github.com/DavidAnson/markdownlint-cli2
[swiftlint]: https://github.com/realm/SwiftLint
[tflint]: https://github.com/terraform-linters/tflint

View File

@ -0,0 +1,383 @@
local uv = vim.loop
local api = vim.api
local notify = vim.notify_once or vim.notify
local M = {}
---@class lint.Parser
---@field on_chunk fun(chunk: string)
---@field on_done fun(publish: fun(diagnostics: vim.Diagnostic[]), bufnr: number, linter_cwd: string)
---@class lint.Linter
---@field name string
---@field cmd string
---@field args? (string|fun():string)[] command arguments
---@field stdin? boolean send content via stdin. Defaults to false
---@field append_fname? boolean add current file name to the commands arguments
---@field stream? "stdout"|"stderr"|"both" result stream. Defaults to stdout
---@field ignore_exitcode? boolean if exit code != 1 should be ignored or result in a warning. Defaults to false
---@field env? table
---@field cwd? string
---@field parser lint.Parser|fun(output:string, bufnr:number, linter_cwd:string):vim.Diagnostic[]
---@class lint.LintProc
---@field bufnr integer
---@field handle uv.uv_process_t
---@field stdout uv.uv_pipe_t
---@field stderr uv.uv_pipe_t
---@field linter lint.Linter
---@field cwd string
---@field ns integer
---@field stream? "stdout"|"stderr"|"both"
---@field cancelled boolean
---@type table<string, lint.Linter|fun():lint.Linter>
M.linters = setmetatable({}, {
__index = function(_, key)
local ok, linter = pcall(require, 'lint.linters.' .. key)
if ok then
return linter
end
return nil
end,
})
M.linters_by_ft = {
text = {'vale',},
json = {'jsonlint',},
markdown = {'vale',},
rst = {'vale',},
ruby = {'ruby',},
janet = {'janet',},
inko = {'inko',},
clojure = {'clj-kondo',},
dockerfile = {'hadolint',},
terraform = {'tflint'},
}
local namespaces = setmetatable({}, {
__index = function(tbl, key)
local ns = api.nvim_create_namespace(key)
rawset(tbl, key, ns)
return ns
end
})
local function read_output(cwd, bufnr, parser, publish_fn)
return function(err, chunk)
assert(not err, err)
if chunk then
parser.on_chunk(chunk, bufnr)
else
parser.on_done(publish_fn, bufnr, cwd)
end
end
end
function M._resolve_linter_by_ft(ft)
local names = M.linters_by_ft[ft]
if names then
return names
end
local dedup_linters = {}
local filetypes = vim.split(ft, '.', { plain = true })
for _, ft_ in pairs(filetypes) do
local linters = M.linters_by_ft[ft_]
if linters then
for _, linter in ipairs(linters) do
dedup_linters[linter] = true
end
end
end
return vim.tbl_keys(dedup_linters)
end
---@class lint.LintProc
local LintProc = {}
local linter_proc_mt = {
__index = LintProc
}
function LintProc:publish(diagnostics)
-- By the time the linter is finished the user might have deleted the buffer
if api.nvim_buf_is_valid(self.bufnr) and not self.cancelled then
vim.diagnostic.set(self.ns, self.bufnr, diagnostics)
end
self.stdout:shutdown()
self.stdout:close()
self.stderr:shutdown()
self.stderr:close()
end
function LintProc:start_read()
local linter_proc = self
local publish = function(diagnostics)
linter_proc:publish(diagnostics)
end
local parser = self.linter.parser
if type(parser) == 'function' then
parser = require('lint.parser').accumulate_chunks(parser)
end
assert(
parser.on_chunk and type(parser.on_chunk == 'function'),
'Parser requires a `on_chunk` function'
)
assert(
parser.on_done and type(parser.on_done == 'function'),
'Parser requires a `on_done` function'
)
local stream = self.linter.stream
local cwd = self.cwd
local bufnr = self.bufnr
if not stream or stream == 'stdout' then
self.stdout:read_start(read_output(cwd, bufnr, parser, publish))
elseif stream == 'stderr' then
self.stderr:read_start(read_output(cwd, bufnr, parser, publish))
elseif stream == 'both' then
local parser1, parser2 = require('lint.parser').split(parser)
self.stdout:read_start(read_output(cwd, bufnr, parser1, publish))
self.stderr:read_start(read_output(cwd, bufnr, parser2, publish))
else
error('Invalid `stream` setting: ' .. stream)
end
end
function LintProc:cancel()
self.cancelled = true
local handle = self.handle
if not handle or handle:is_closing() then
return
end
-- Use sigint so the process can safely close any child processes.
-- This is mostly useful for when `cmd` is a script with a shebang.
handle:kill('sigint')
vim.wait(10000, function()
return handle:is_closing() or false
end)
if not handle:is_closing() then
-- 'sigint' didn't work, hit it with a 'sigkill'.
-- This should also kill any attached child processes since
-- handle is a process group leader (due to it being detached).
handle:kill('sigkill')
end
end
--- Return the namespace for a given linter.
---
--- Can be used to configure diagnostics for a given linter. For example:
---
--- ```lua
--- local ns = require("lint").get_namespace("my_linter_name")
--- vim.diagnostic.config({ virtual_text = true }, ns)
---
--- ```
---
---@param name string linter
function M.get_namespace(name)
return namespaces[name]
end
--- Running processes by buffer -> by linter name
---@type table<integer, table<string, lint.LintProc>> bufnr: {linter: handle}
local running_procs_by_buf = {}
--- Returns the names of the running linters
---
---@param bufnr? integer buffer for which to get the running linters. nil=all buffers
---@return string[]
function M.get_running(bufnr)
local linters = {}
if bufnr then
bufnr = bufnr == 0 and api.nvim_get_current_buf() or bufnr
local running_procs = (running_procs_by_buf[bufnr] or {})
for linter_name, _ in pairs(running_procs) do
table.insert(linters, linter_name)
end
else
for _, running_procs in pairs(running_procs_by_buf) do
for linter_name, _ in pairs(running_procs) do
table.insert(linters, linter_name)
end
end
end
return linters
end
---@param names? string|string[] name of the linter
---@param opts? {cwd?: string, ignore_errors?: boolean} options
function M.try_lint(names, opts)
assert(
vim.diagnostic,
"nvim-lint requires neovim 0.6.0+. If you're using an older version, use the `nvim-05` tag of nvim-lint'"
)
opts = opts or {}
if type(names) == "string" then
names = { names }
end
if not names then
names = M._resolve_linter_by_ft(vim.bo.filetype)
end
local lookup_linter = function(name)
local linter = M.linters[name]
assert(linter, 'Linter with name `' .. name .. '` not available')
if type(linter) == "function" then
linter = linter()
end
linter.name = linter.name or name
return linter
end
local bufnr = api.nvim_get_current_buf()
local running_procs = running_procs_by_buf[bufnr] or {}
for _, linter_name in pairs(names) do
local linter = lookup_linter(linter_name)
local proc = running_procs[linter.name]
if proc then
proc:cancel()
end
running_procs[linter.name] = nil
local ok, lintproc_or_error = pcall(M.lint, linter, opts)
if ok then
running_procs[linter.name] = lintproc_or_error
elseif not opts.ignore_errors then
notify(lintproc_or_error --[[@as string]], vim.log.levels.WARN)
end
end
running_procs_by_buf[bufnr] = running_procs
end
local function eval_fn_or_id(x)
if type(x) == 'function' then
return x()
else
return x
end
end
---@param linter lint.Linter
---@param opts? {cwd?: string, ignore_errors?: boolean}
---@return lint.LintProc|nil
function M.lint(linter, opts)
assert(linter, 'lint must be called with a linter')
local stdin = assert(uv.new_pipe(false), "Must be able to create pipe")
local stdout = assert(uv.new_pipe(false), "Must be able to create pipe")
local stderr = assert(uv.new_pipe(false), "Must be able to create pipe")
local handle
local env
local pid_or_err
local args = {}
local bufnr = api.nvim_get_current_buf()
local iswin = vim.fn.has("win32") == 1
if iswin then
linter = vim.tbl_extend("force", linter, {
cmd = "cmd.exe",
args = { "/C", linter.cmd, unpack(linter.args or {}) },
})
end
opts = opts or {}
if linter.args then
vim.list_extend(args, vim.tbl_map(eval_fn_or_id, linter.args))
end
if not linter.stdin and linter.append_fname ~= false then
table.insert(args, api.nvim_buf_get_name(bufnr))
end
if linter.env then
env = {}
if not linter.env["PATH"] then
-- Always include PATH as we need it to execute the linter command
table.insert(env, "PATH=" .. os.getenv("PATH"))
end
for k, v in pairs(linter.env) do
table.insert(env, k .. "=" .. v)
end
end
local linter_opts = {
args = args,
stdio = { stdin, stdout, stderr },
env = env,
cwd = opts.cwd or linter.cwd or vim.fn.getcwd(),
-- Linter may launch child processes so set this as a group leader and
-- manually track and kill processes as we need to.
-- Don't detach on windows since that may cause shells to
-- pop up shortly.
detached = not iswin
}
local cmd = eval_fn_or_id(linter.cmd)
assert(cmd, 'Linter definition must have a `cmd` set: ' .. vim.inspect(linter))
handle, pid_or_err = uv.spawn(cmd, linter_opts, function(code)
if handle and not handle:is_closing() then
local procs = (running_procs_by_buf[bufnr] or {})
-- Only cleanup if there has not been another procs in between
local proc = procs[linter.name] or {}
if handle == proc.handle then
procs[linter.name] = nil
if not next(procs) then
running_procs_by_buf[bufnr] = nil
end
end
handle:close()
end
if code ~= 0 and not linter.ignore_exitcode then
vim.schedule(function()
vim.notify('Linter command `' .. cmd .. '` exited with code: ' .. code, vim.log.levels.WARN)
end)
end
end)
if not handle then
stdout:close()
stderr:close()
stdin:close()
if not opts.ignore_errors then
vim.notify('Error running ' .. cmd .. ': ' .. pid_or_err, vim.log.levels.ERROR)
end
return nil
end
local state = {
bufnr = bufnr,
stdout = stdout,
stderr = stderr,
handle = handle,
linter = linter,
cwd = linter_opts.cwd,
ns = namespaces[linter.name],
cancelled = false,
}
local linter_proc = setmetatable(state, linter_proc_mt)
linter_proc:start_read()
if linter.stdin then
local lines = api.nvim_buf_get_lines(0, 0, -1, true)
for _, line in ipairs(lines) do
stdin:write(line .. '\n')
end
stdin:write('', function()
stdin:shutdown(function()
stdin:close()
end)
end)
else
stdin:close()
end
return linter_proc
end
return M

View File

@ -0,0 +1,28 @@
return {
cmd = 'actionlint',
stdin = true,
args = { '-format', '{{json .}}', '-' },
ignore_exitcode = true,
parser = function(output)
if output == '' then
return {}
end
local decoded = vim.json.decode(output)
if decoded == nil then
return {}
end
local diagnostics = {}
for _, item in ipairs(decoded) do
table.insert(diagnostics, {
lnum = item.line - 1,
end_lnum = item.line - 1,
col = item.column - 1,
end_col = item.end_column,
severity = vim.diagnostic.severity.WARN,
source = 'actionlint: ' .. item.kind,
message = item.message,
})
end
return diagnostics
end,
}

View File

@ -0,0 +1,29 @@
local pattern = "%s*(%d+):(%d+)-(%d+):(%d+)%s+(%w+)%s+(.-)%s+%s+(%g+)%s+%g+"
local groups = { "lnum", "col", "end_lnum", "end_col", "severity", "message", "code" }
local severity_map = {
warning = vim.diagnostic.severity.WARN,
error = vim.diagnostic.severity.ERROR,
}
return {
cmd = "alex",
stdin = true,
stream = "stderr",
ignore_exitcode = true,
args = {
"--stdin",
function()
if vim.bo.ft == "html" then
return "--html"
elseif vim.bo.ft ~= "markdown" then
return "--text"
end
end,
},
parser = require("lint.parser").from_pattern(
pattern,
groups,
severity_map,
{ severity = vim.diagnostic.severity.WARN, source = "alex" }
),
}

View File

@ -0,0 +1,9 @@
return {
cmd = 'ansible-lint',
args = { '-p', '--nocolor' },
ignore_exitcode = true,
parser = require('lint.parser').from_errorformat('%f:%l: %m', {
source = 'ansible-lint',
severity = vim.diagnostic.severity.INFO
})
}

View File

@ -0,0 +1,28 @@
local pattern = [[(%d+):(%d+):(%u+):(%w+) (.*)]]
local groups = { "lnum", "col", "severity", "code", "message" }
local severity_map = {
["HIGH"] = vim.diagnostic.severity.ERROR,
["MEDIUM"] = vim.diagnostic.severity.WARN,
["LOW"] = vim.diagnostic.severity.INFO,
}
local defaults = {
source = "bandit",
}
return {
cmd = "bandit",
stdin = false,
args = {
"-f",
"custom",
"--msg-template",
"{line}:{col}:{severity}:{test_id} {msg}",
},
stream = "stdout",
ignore_exitcode = true,
parser = require("lint.parser").from_pattern(pattern, groups, severity_map, defaults, {
col_offset = 0,
}),
}

View File

@ -0,0 +1,10 @@
return {
cmd = 'bean-check',
stdin = false,
stream = 'stderr',
ignore_exitcode = true,
parser = require('lint.parser').from_errorformat('%f:%l: %m', {
source = 'bean-check',
severity = vim.diagnostic.severity.ERROR,
})
}

View File

@ -0,0 +1,83 @@
-- Sample biome lint output:
--
-- index.js:6:13 lint/suspicious/noDoubleEquals FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
--
-- ✖ Use === instead of ==
--
-- 4 │ count += 1;
-- 5 │ var f = function (opt) {
-- > 6 │ if (opt == true) {
-- │ ^^
-- 7 │ return "true";
-- 8 │ }
--
-- == is only allowed when comparing against null
--
-- 4 │ count += 1;
-- 5 │ var f = function (opt) {
-- > 6 │ if (opt == true) {
-- │ ^^
-- 7 │ return "true";
-- 8 │ }
--
-- Using === may be unsafe if you are relying on type coercion
--
-- Suggested fix: Use ===
--
-- 6 │ ····if·(opt·===·true)·{
-- │
local binary_name = "biome"
return {
cmd = function()
local local_binary = vim.fn.fnamemodify('./node_modules/.bin/' .. binary_name, ':p')
return vim.loop.fs_stat(local_binary) and local_binary or binary_name
end,
args = { "lint" },
stdin = false,
ignore_exitcode = true,
stream = "both",
parser = function(output)
local diagnostics = {}
-- The diagnostic details we need are spread in the first 3 lines of
-- each error report. These variables are declared out of the FOR
-- loop because we need to carry their values to parse multiple lines.
local fetch_message = false
local lnum, col, code, message
-- When a lnum:col:code line is detected fetch_message is set to true.
-- While fetch_message is true we will search for the error message.
-- When a error message is detected, we will create the diagnostic and
-- set fetch_message to false to restart the process and get the next
-- diagnostic.
for _, line in ipairs(vim.fn.split(output, "\n")) do
if fetch_message then
_, _, message = string.find(line, "%s×(.+)")
if message then
message = (message):gsub("^%s+×%s*", "")
table.insert(diagnostics, {
source = "biomejs",
lnum = tonumber(lnum) - 1,
col = tonumber(col),
message = message,
code = code
})
fetch_message = false
end
else
_, _, lnum, col, code = string.find(line, "[^:]+:(%d+):(%d+)%s([%a%/]+)")
if lnum then
fetch_message = true
end
end
end
return diagnostics
end
}

View File

@ -0,0 +1,9 @@
return {
cmd = "blocklint",
args = { "--stdin", "--end-pos" },
stdin = true,
parser = require("lint.parser").from_errorformat("stdin:%l:%c:%k: %m", {
source = "blocklint",
severity = vim.diagnostic.severity.INFO,
}),
}

View File

@ -0,0 +1,31 @@
return {
cmd = 'buf',
args = { 'lint', '--error-format', 'json' },
stdin = false,
ignore_exitcode = true,
parser = function(output)
if output == '' then
return {}
end
local lines = vim.split(output, '\n')
local diagnostics = {}
for _, line in ipairs(lines) do
if line == '' then
break
end
local item = vim.json.decode(line)
if item then
table.insert(diagnostics, {
lnum = (item.start_line or 1) - 1,
col = (item.start_column or 1) - 1,
end_lnum = (item.end_line or 1) - 1,
end_col = (item.end_column or 1) - 1,
severity = vim.diagnostic.severity.WARN,
source = item.type,
message = item.message,
})
end
end
return diagnostics
end,
}

View File

@ -0,0 +1,134 @@
-- See the source for the formats
-- https://github.com/bazelbuild/buildtools/blob/b31f2c13c407575100d4614bcc9a3c60be07cc1c/buildifier/utils/diagnostics.go#L39
local function get_cur_file_type(bufnr)
-- Logic taken from https://github.com/bazelbuild/buildtools/blob/master/build/lex.go#L125
bufnr = bufnr or 0
local fname = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(bufnr), ':t')
fname = string.lower(fname)
if fname == "module.bazel" then
return "module"
elseif vim.endswith(fname, ".bzl") then
return "bzl"
elseif vim.endswith(fname, ".sky") then
return "default"
elseif fname == "build" or vim.startswith(fname, "build.") or vim.endswith(fname, ".build") then
return "build"
elseif fname == "workspace" or vim.startswith(fname, "workspace.") or vim.endswith(fname, ".workspace") then
return "workspace"
else
return "default"
end
end
local function parse_stdout_json(bufnr, line)
local diagnostics = {}
local out = vim.json.decode(line)
if out.success == true then
return diagnostics
end
local f = out.files[1]
if not f.warnings then
return diagnostics
end
if not f.formatted then
table.insert(diagnostics, {
bufnr = bufnr,
lnum = 0,
col = 0,
severity = vim.diagnostic.severity.HINT,
source = 'buildifier',
message = 'Please run buildifier to reformat the file contents.',
code = 'reformat',
})
end
for _, item in ipairs(f.warnings) do
local severity = vim.diagnostic.severity.INFO
if item.actionable == true then
severity = vim.diagnostic.severity.WARN
end
table.insert(diagnostics, {
bufnr = bufnr,
lnum = item.start.line - 1,
col = item.start.column - 1,
end_lnum = item["end"].line - 1,
end_col = item["end"].column - 1,
severity = severity,
source = 'buildifier',
message = item.message .. '\n\n' .. item.url,
code = item.category,
})
end
return diagnostics
end
local function parse_stderr_line(bufnr, line)
-- This part parses the buildifier output that usually comes via stderr which
-- is not in JSON format yet.
local parts = vim.split(line, ":")
local lnum, col, message = 0, 0, ""
if #parts >= 4 then
lnum = tonumber(parts[2]) - 1
col = tonumber(parts[3]) - 1
message = table.concat(parts, ":", 4)
elseif #parts == 3 then
message = parts[3]
elseif #parts == 2 then
message = parts[2]
elseif #parts == 1 then
message = line
end
if message ~= "" then
return {{
bufnr = bufnr,
lnum = lnum,
col = col,
severity = vim.diagnostic.severity.ERROR,
source = 'buildifier',
message = message:gsub("^%s+", ""),
code = 'syntax',
}}
end
return {}
end
return {
cmd = 'buildifier',
args = {
"-lint", "warn",
"-mode", "check",
"-warnings", "all",
"-format", "json",
"-type", get_cur_file_type
},
stdin = true,
append_fname = false,
stream = "both",
parser = function(output, bufnr)
local diagnostics = {}
local lines = vim.split(output, '\n')
for _, line in ipairs(lines) do
if vim.startswith(line, '{') then
for _, d in ipairs(parse_stdout_json(bufnr, line)) do
table.insert(diagnostics, d)
end
else
for _, d in ipairs(parse_stderr_line(bufnr, line)) do
table.insert(diagnostics, d)
end
end
end
return diagnostics
end,
}

View File

@ -0,0 +1,13 @@
local pattern = "([^:]+):(%d+):(%d+):(%d+):(%d+):(%w)(%d+):(.*)"
local groups = { "file", "lnum", "col", "end_lnum", "end_col", "severity", "code", "message" }
local severity_map = {
["W"] = vim.diagnostic.severity.WARN,
["E"] = vim.diagnostic.severity.ERROR,
}
return {
cmd = "cfn-lint",
args = { "--format", "parseable" },
stdin = false,
parser = require("lint.parser").from_pattern(pattern, groups, severity_map, { ["source"] = "cfn-lint" }),
}

View File

@ -0,0 +1,34 @@
local severity_map = {
["WARN"] = vim.diagnostic.severity.WARN,
["FAIL"] = vim.diagnostic.severity.ERROR,
}
return {
cmd = "cfn_nag_scan",
stdin = false,
args = { "--output-format", "json", "--input-path" },
parser = function(output)
if output == nil then
return {}
end
local diagnostics = {}
local decoded = vim.json.decode(output)
local violations = decoded[1].file_results.violations
for _, violation in pairs(violations) do
for _, line in pairs(violation.line_numbers) do
table.insert(diagnostics, {
lnum = line,
end_lnum = line,
col = 1,
code = violation.id,
severity = assert(severity_map[violation.type], "missing mapping for severity " .. violation.type),
message = violation.message,
})
end
end
return diagnostics
end,
}

View File

@ -0,0 +1,16 @@
local pattern = "(%d+):(%w+):(.+)"
local groups = { "lnum", "code", "message" }
return {
cmd = "checkmake",
stdin = false,
append_fname = true,
args = {
"--format='{{.LineNumber}}:{{.Rule}}:{{.Violation}}\n'",
},
ignore_exitcode = true,
parser = require("lint.parser").from_pattern(pattern, groups, nil, {
["source"] = "checkmake",
["severity"] = vim.diagnostic.severity.WARN,
}),
}

View File

@ -0,0 +1,27 @@
-- The scripts/ directory of the Linux kernel tree needs to be in your PATH or
-- the full path to the checkpatch.pl script can be overriden from user config:
-- require("lint").linters.checkpatch.cmd = '…/checkpatch.pl'
-- path/to/file:line: severity: message
local pattern = '([^:]+):(%d+): (%a+): (.+)'
local groups = { 'file', 'lnum', 'severity', 'message' }
local severity_map = {
['ERROR'] = vim.diagnostic.severity.ERROR,
['WARNING'] = vim.diagnostic.severity.WARN,
['CHECK'] = vim.diagnostic.severity.INFO,
}
return {
cmd = 'checkpatch.pl',
stdin = false,
args = {
'--strict',
'--terse',
'--file',
},
ignore_exitcode = true,
parser = require('lint.parser').from_pattern(
pattern, groups, severity_map,
{ ['source'] = 'checkpatch' }
),
}

View File

@ -0,0 +1,23 @@
local format = '[%tRROR] %f:%l:%c: %m, [%tRROR] %f:%l: %m, [%tARN] %f:%l:%c: %m, [%tARN] %f:%l: %m'
local M
local function config()
if M.config_file == nil then
error "Missing checkstyle config. e.g.: `require('lint.linters.checkstyle').config_file = '/path/to/checkstyle_config.xml'`"
end
return M.config_file
end
M = {
cmd = 'checkstyle',
args = {'-c', config},
ignore_exitcode = true,
parser = require('lint.parser').from_errorformat(format, {
source = 'checkstyle',
}),
-- use the bundled Google style by default
config_file = '/google_checks.xml'
}
return M

View File

@ -0,0 +1,42 @@
local pattern = '(%d+):(%d+):(%d+):(.+):(%d+):(.*)'
local severities = {
Error = vim.diagnostic.severity.ERROR,
Warning = vim.diagnostic.severity.WARN,
Message = vim.diagnostic.severity.INFO
}
return {
cmd = 'chktex',
stdin = true,
args = {'-v0', '-I0', '-s', ':', '-f', '%l%b%c%b%d%b%k%b%n%b%m%b%b%b'},
parser = function(output, _)
local result = vim.fn.split(output, ":::")
local diagnostics = {}
for _, line in ipairs(result) do
local lineno, off, d, sev, code, desc = string.match(line, pattern)
lineno = tonumber(lineno or 1) - 1
off = tonumber(off or 1) - 1
d = tonumber(d or 1)
table.insert(diagnostics, {
source = 'chktex',
lnum = lineno,
col = off,
end_lnum = lineno,
end_col = off + d,
message = desc,
severity = assert(severities[sev],
'missing mapping for severity ' .. sev),
code = code,
user_data = {
lsp = {
code = code
},
}
})
end
return diagnostics
end
}

View File

@ -0,0 +1,18 @@
local pattern = [[([^:]*):(%d+):(%d+): (%w+): ([^[]+)]]
local groups = { 'file', 'lnum', 'col', 'severity', 'message' }
local severity_map = {
['error'] = vim.diagnostic.severity.ERROR,
['warning'] = vim.diagnostic.severity.WARN,
['information'] = vim.diagnostic.severity.INFO,
['hint'] = vim.diagnostic.severity.HINT,
['note'] = vim.diagnostic.severity.HINT,
}
return {
cmd = 'clang-tidy',
stdin = false,
args = { '--quiet' },
ignore_exitcode = true,
parser = require('lint.parser').from_pattern(pattern, groups, severity_map, { ['source'] = 'clang-tidy' }),
}

View File

@ -0,0 +1,13 @@
-- Clazy will also emit clang's regular compiler warnings.
-- There doesn't seem to be a way to disable this,
-- so only filter out the ones starting with -Wclazy-
local pattern = [=[([^:]*):(%d+):(%d+): (%w+): ([^[]+) %[%-Wclazy%-(.*)%]]=]
local groups = { 'file', 'lnum', 'col', 'severity', 'message', 'code'}
return {
cmd = 'clazy-standalone',
stdin = false,
args = {},
stream = 'stderr',
parser = require('lint.parser').from_pattern(pattern, groups, nil, { ['source'] = 'clazy' }),
}

View File

@ -0,0 +1,36 @@
local severities = {
error = vim.diagnostic.severity.ERROR,
warning = vim.diagnostic.severity.WARN,
}
local function get_file_name()
return vim.api.nvim_buf_get_name(0)
end
return {
cmd = 'clj-kondo',
stdin = true,
stream = 'stdout',
ignore_exitcode = true,
args = {
'--config', '{:output {:format :json}}', '--filename', get_file_name, '--lint', '-',
},
parser = function(output)
local decoded = vim.json.decode(output) or {}
local findings = decoded.findings
local diagnostics = {}
for _, finding in pairs(findings or {}) do
table.insert(diagnostics, {
lnum = finding.row - 1,
col = finding.col - 1,
end_lnum = finding.row - 1,
end_col = finding.col - 1,
severity = assert(severities[finding.level], 'missing mapping for severity ' .. finding.level),
message = finding.message,
})
end
return diagnostics
end,
}

View File

@ -0,0 +1,15 @@
-- path/to/file:line: message [code]
local pattern = '([^:]+):(%d+): (.+) %[(.+)%]'
local groups = { 'file', 'lnum', 'message', 'code' }
local is_windows = vim.loop.os_uname().version:match('Windows')
return {
cmd = is_windows and 'cmakelint.cmd' or 'cmakelint',
stdin = false,
args = {'--quiet'},
ignore_exitcode = true,
parser = require('lint.parser').from_pattern(pattern, groups, nil, {
['source'] = 'cmakelint',
['severity'] = vim.diagnostic.severity.WARN,
}),
}

View File

@ -0,0 +1,11 @@
return {
cmd = 'codespell',
stdin = false,
ignore_exitcode = true,
parser = require('lint.parser').from_errorformat(
'%f:%l:%m',
{ severity = vim.diagnostic.severity.INFO,
source = 'codespell'}
)
}

View File

@ -0,0 +1,27 @@
return {
cmd = "commitlint",
stdin = true,
args = {},
ignore_exitcode = true,
parser = function(output)
local diagnostics = {}
local result = vim.fn.split(output, "\n")
for _, line in ipairs(result) do
local label = line:sub(1, 3)
if label == "" then
if not string.find(line, "found") then
table.insert(diagnostics, {
source = "commitlint",
lnum = 0,
col = 0,
severity = vim.diagnostic.severity.ERROR,
message = vim.fn.split(line, " ")[2],
})
end
end
end
return diagnostics
end,
}

View File

@ -0,0 +1,28 @@
local api = vim.api
return function()
local ok, errorformat = pcall(api.nvim_buf_get_option, 0, 'errorformat')
if not ok then
errorformat = vim.o.errorformat
end
local makeprg
ok, makeprg = pcall(api.nvim_buf_get_option, 0, 'makeprg')
if not ok then
makeprg = vim.o.makeprg
end
local bufname = api.nvim_buf_get_name(0)
local args = {
api.nvim_get_option('shellcmdflag'),
makeprg:gsub(' %%', ' ' .. bufname),
}
return {
cmd = vim.opt.shell:get(),
args = args,
stdin = false,
append_fname = false,
stream = 'both',
ignore_exitcode = true,
parser = require('lint.parser').from_errorformat(errorformat)
}
end

View File

@ -0,0 +1,37 @@
-- cppcheck <= 1.84 doesn't support {column} so the start_col group is ambiguous
local pattern = [[([^:]*):(%d*):([^:]*): %[([^%]\]*)%] ([^:]*): (.*)]]
local groups = { "file", "lnum", "col", "code", "severity", "message" }
local severity_map = {
["error"] = vim.diagnostic.severity.ERROR,
["warning"] = vim.diagnostic.severity.WARN,
["performance"] = vim.diagnostic.severity.WARN,
["style"] = vim.diagnostic.severity.INFO,
["information"] = vim.diagnostic.severity.INFO,
}
return {
cmd = "cppcheck",
stdin = false,
args = {
"--enable=warning,style,performance,information",
function()
if vim.bo.filetype == "cpp" then
return "--language=c++"
else
return "--language=c"
end
end,
"--inline-suppr",
"--quiet",
function()
if vim.fn.isdirectory("build") == 1 then
return "--cppcheck-build-dir=build"
else
return nil
end
end,
"--template={file}:{line}:{column}: [{id}] {severity}: {message}",
},
stream = "stderr",
parser = require("lint.parser").from_pattern(pattern, groups, severity_map, { ["source"] = "cppcheck" }),
}

View File

@ -0,0 +1,15 @@
-- path/to/file:line: message [code] [code_id]
local pattern = '([^:]+):(%d+): (.+) (.+)'
local groups = { 'file', 'lnum', 'message', 'code'}
return {
cmd = 'cpplint',
stdin = false,
args = {},
ignore_exitcode = true,
stream = 'stderr',
parser = require('lint.parser').from_pattern(pattern, groups, nil, {
['source'] = 'cpplint',
['severity'] = vim.diagnostic.severity.WARN,
}),
}

View File

@ -0,0 +1,10 @@
local errorfmt = '[%t] %. stdin:%l:%c %m, [%t] %. stdin:%l %m'
return {
cmd = 'mix',
stdin = true,
args = { 'credo', 'list', '--format=oneline', '--read-from-stdin', '--strict'},
stream = 'stdout',
ignore_exitcode = true, -- credo only returns 0 if there are no errors
parser = require('lint.parser').from_errorformat(errorfmt, { ['source'] = 'credo' })
}

View File

@ -0,0 +1,38 @@
local efm = '%f:%l:%c - %m'
return {
cmd = 'cspell',
ignore_exitcode = true,
args = {
'lint',
'--no-color',
'--no-progress',
'--no-summary',
},
stream = 'stdout',
parser = function(output)
local lines = vim.split(output, '\n')
local qflist = vim.fn.getqflist({ efm = efm, lines = lines })
local result = {}
for _, item in pairs(qflist.items) do
if item.valid == 1 then
local message = item.text:match('^%s*(.-)%s*$')
local word = message:match('%(.*%)')
local lnum = math.max(0, item.lnum - 1)
local col = math.max(0, item.col - 1)
local end_lnum = item.end_lnum > 0 and (item.end_lnum - 1) or lnum
local end_col = col + word:len() - 2 or col
local diagnostic = {
lnum = lnum,
col = col,
end_lnum = end_lnum,
end_col = end_col,
message = message,
source = 'cspell',
severity = vim.diagnostic.severity.INFO
}
table.insert(result, diagnostic)
end
end
return result
end
}

View File

@ -0,0 +1,12 @@
local efm = "%E%m:,%C%f:%l:%c"
return {
cmd = "cue",
args = { "vet" },
stdin = false,
ignore_exitcode = true,
stream = "stderr",
parser = require("lint.parser").from_errorformat(efm, {
source = "cue vet",
}),
}

View File

@ -0,0 +1,12 @@
local efm = '%f:%l:%c: %m'
return {
cmd = 'curlylint',
args = {'--format', 'compact'},
stdin = false,
stream = 'stdout',
ignore_exitcode = true,
parser = require('lint.parser').from_errorformat(efm, {
source = 'curlylint',
severity = vim.diagnostic.severity.WARN
})
}

View File

@ -0,0 +1,14 @@
local pattern = "(.+): (%d+): (.+)"
local groups = { "file", "lnum", "message" }
return {
cmd = "dash",
stdin = false,
ignore_exitcode = true,
args = { "-n" },
stream = "stderr",
parser = require("lint.parser").from_pattern(pattern, groups, nil, {
["source"] = "dash",
["severity"] = vim.diagnostic.severity.ERROR,
}),
}

View File

@ -0,0 +1,31 @@
return {
cmd = "deadnix",
stdin = false,
append_fname = true,
args = { "--output-format=json" },
stream = nil,
ignore_exitcode = false,
env = nil,
parser = function(output, _)
local diagnostics = {}
if output == "" then
return diagnostics
end
local decoded = vim.json.decode(output) or {}
for _, diag in ipairs(decoded.results) do
table.insert(diagnostics, {
lnum = diag.line - 1,
end_lnum = diag.line - 1,
col = diag.column - 1,
end_col = diag.endColumn,
message = diag.message,
severity = vim.diagnostic.severity.WARN,
})
end
return diagnostics
end,
}

View File

@ -0,0 +1,47 @@
return {
cmd = "deno",
stdin = false,
args = { 'lint', '--json' },
ignore_exitcode = true,
parser = function(output)
local decoded = vim.json.decode(output)
local diagnostics = {}
local groups = {
{ name = "diagnostics", severity = vim.diagnostic.severity.WARN },
{ name = "errors", severity = vim.diagnostic.severity.ERROR }
}
for _, group in ipairs(groups) do
for _, diag in ipairs(decoded[group.name]) do
-- Parse Error data
if group.name == "errors" then
local message, line, col
_, _, message, line, col = string.find(diag.message, "([%a%p%s]+):(%d+):(%d+)%s*")
-- build range data
diag["range"] = {
start = { line = tonumber(line), col = tonumber(col) },
["end"] = { line = tonumber(line), col = tonumber(col) },
}
-- override message
diag["message"] = message
end
table.insert(diagnostics, {
source = "deno",
lnum = diag.range.start.line - 1,
col = diag.range.start.col - 1,
end_lnum = diag.range["end"].line - 1,
end_col = diag.range["end"].col,
severity = group.severity,
message = diag.message,
code = diag.code
})
end
end
return diagnostics
end
}

View File

@ -0,0 +1,20 @@
local pattern = [[(%d+):(%d+):(%a%d+): (.*)]]
local groups = { 'lnum', 'col', 'code', 'message' }
local defaults = {
['source'] = 'djlint',
['severity'] = vim.diagnostic.severity.INFO
}
return {
cmd = 'djlint',
stdin = true,
args = {
'--linter-output-format',
'{line}:{code}: {message}',
'-',
},
stream = 'both',
ignore_exitcode = true,
parser = require('lint.parser').from_pattern(pattern, groups, nil, defaults, {}),
}

View File

@ -0,0 +1,15 @@
return {
cmd = "dotenv-linter",
stdin = false,
args = { "--quiet", "--no-color" },
stream = "stdout",
ignore_exitcode = true,
env = nil,
parser = require("lint.parser").from_pattern(
[=[%w+:(%d+) (%w+): (.*)]=],
{ "lnum", "code", "message" },
nil,
{ ["source"] = "dotenv_linter", ["severity"] = vim.diagnostic.severity.INFO }
),
}

View File

@ -0,0 +1,19 @@
-- example:
-- blur.hlsl:18:6: error: expected ';' after top level declarator
local pattern = "%s*([^:]+):(%d+):(%d+): (.+): (.+)"
local groups = { "file", "lnum", "col", "severity", "message" }
return {
cmd = "dxc",
stdin = false,
args = { "-T", "cs_6_5" },
ignore_exitcode = true,
stream = "stderr",
parser = require("lint.parser").from_pattern(pattern, groups, {
error = vim.diagnostic.severity.ERROR,
warning = vim.diagnostic.severity.WARN,
}, {
["source"] = "dxc",
["severity"] = vim.diagnostic.severity.WARN,
}),
}

View File

@ -0,0 +1,15 @@
local pattern = "%s*(%d+): (.+)"
local groups = { "lnum", "message" }
return {
cmd = "editorconfig-checker",
stdin = false,
ignore_exitcode = true,
args = { "-no-color" },
parser = require("lint.parser").from_pattern(
pattern,
groups,
nil,
{ severity = vim.diagnostic.severity.INFO, source = "editorconfig-checker" }
),
}

View File

@ -0,0 +1,13 @@
local efm = '%f:%l:%c: %m'
return {
cmd = 'bundle',
args = { 'exec', 'erblint', '--format', 'compact' },
stream = 'stdout',
ignore_exitcode = true,
parser = require('lint.parser').from_errorformat(efm, {
source = 'erb-lint',
severity = vim.diagnostic.severity.WARN
})
}

View File

@ -0,0 +1,56 @@
local binary_name = "eslint"
local severities = {
vim.diagnostic.severity.WARN,
vim.diagnostic.severity.ERROR,
}
return {
cmd = function()
local local_binary = vim.fn.fnamemodify('./node_modules/.bin/' .. binary_name, ':p')
return vim.loop.fs_stat(local_binary) and local_binary or binary_name
end,
args = {
'--format',
'json',
'--stdin',
'--stdin-filename',
function() return vim.api.nvim_buf_get_name(0) end,
},
stdin = true,
stream = 'stdout',
ignore_exitcode = true,
parser = function(output, bufnr)
if vim.trim(output) == "" then
return {}
end
local decode_opts = { luanil = { object = true, array = true } }
local ok, data = pcall(vim.json.decode, output, decode_opts)
if not ok then
return {
{
bufnr = bufnr,
lnum = 0,
col = 0,
message = "Could not parse linter output due to: " .. data .. "\noutput: " .. output
}
}
end
-- See https://eslint.org/docs/latest/use/formatters/#json
local diagnostics = {}
for _, result in ipairs(data or {}) do
for _, msg in ipairs(result.messages or {}) do
table.insert(diagnostics, {
lnum = msg.line and (msg.line - 1) or 0,
end_lnum = msg.endLine and (msg.endLine - 1) or nil,
col = msg.column and (msg.column - 1) or 0,
end_col = msg.endColumn and (msg.endColumn - 1) or nil,
message = msg.message,
code = msg.ruleId,
severity = severities[msg.severity],
source = binary_name
})
end
end
return diagnostics
end
}

View File

@ -0,0 +1,24 @@
local binary_name = "eslint_d"
return {
cmd = function()
local local_binary = vim.fn.fnamemodify('./node_modules/.bin/' .. binary_name, ':p')
return vim.loop.fs_stat(local_binary) and local_binary or binary_name
end,
args = {
'--format',
'json',
'--stdin',
'--stdin-filename',
function() return vim.api.nvim_buf_get_name(0) end,
},
stdin = true,
stream = 'stdout',
ignore_exitcode = true,
parser = function(output, bufnr)
local result = require("lint.linters.eslint").parser(output, bufnr)
for _, d in ipairs(result) do
d.source = binary_name
end
return result
end
}

View File

@ -0,0 +1,25 @@
local efm = "%C%[%^^]%#,%E%>Parse error in %f:%l,%E%>Compile error in %f:%l,%-Z%p^%.%#,%C%m,%-G* %.%#"
local M
local function globals()
return table.concat(M.globals, ",")
end
M = {
cmd = "fennel",
args = { "--globals", globals, "--compile" },
stdin = false,
ignore_exitcode = true,
stream = "stderr",
parser = require("lint.parser").from_errorformat(efm, {
source = "fennel",
severity = vim.diagnostic.severity.ERROR,
}),
-- Users can modify this list like this:
-- require("lint.linters.fennel").globals = { "foo", "bar" }
globals = {},
}
return M

View File

@ -0,0 +1,12 @@
local efm = "%E%f (line %l): %m,%C%p^,%C%.%#"
return {
cmd = "fish",
args = { "--no-execute" },
stdin = false,
ignore_exitcode = true,
stream = "stderr",
parser = require("lint.parser").from_errorformat(efm, {
source = "fish",
severity = vim.diagnostic.severity.ERROR,
}),
}

View File

@ -0,0 +1,20 @@
-- path/to/file:line:col: code message
local pattern = '[^:]+:(%d+):(%d+):(%w+):(.+)'
local groups = { 'lnum', 'col', 'code', 'message' }
return {
cmd = 'flake8',
stdin = true,
args = {
'--format=%(path)s:%(row)d:%(col)d:%(code)s:%(text)s',
'--no-show-source',
'--stdin-display-name',
function() return vim.api.nvim_buf_get_name(0) end,
'-',
},
ignore_exitcode = true,
parser = require('lint.parser').from_pattern(pattern, groups, nil, {
['source'] = 'flake8',
['severity'] = vim.diagnostic.severity.WARN,
}),
}

View File

@ -0,0 +1,24 @@
-- Look for patterns like the following:
--
-- vuln.c:6:3: [5] (buffer) gets:Does not check for buffer overflows (CWE-120, CWE-20). Use fgets() instead.
local pattern = [[^(.*):(%d+):(%d+): *%[([0-5])%] (.*)$]]
local groups = { 'file', 'lnum', 'col', 'severity', 'message' }
local severity_map = {
['5'] = vim.diagnostic.severity.WARN,
['4'] = vim.diagnostic.severity.WARN,
['3'] = vim.diagnostic.severity.WARN,
['2'] = vim.diagnostic.severity.WARN,
['1'] = vim.diagnostic.severity.WARN,
}
return {
cmd = 'flawfinder',
stdin = false,
args = {'-S', '-Q', '-D', '-C', '--'},
stream = 'stdout',
parser = require('lint.parser').from_pattern(pattern, groups, severity_map, {
['source'] = 'flawfinder'
})
}

View File

@ -0,0 +1,25 @@
local pattern = [[(%S+):(%d+):%s(%a+):%s(.*)]]
local groups = {
'file',
'lnum',
'severity',
'message',
}
local severity_map = {
['Error'] = vim.diagnostic.severity.WARN,
}
return {
cmd = 'gdlint',
stdin = false,
append_fname = true,
args = {},
stream = 'stderr',
ignore_exitcode = true,
parser = require('lint.parser').from_pattern(
pattern,
groups,
severity_map,
{ ['source'] = 'gdlint' }
),
}

View File

@ -0,0 +1,15 @@
local pattern = "^(%d+): (%w+) (.*)$"
local groups = { "lnum", "code", "message" }
return {
cmd = "gitlint",
stdin = true,
args = {
"--staged",
"--msg-filename",
function() return vim.api.nvim_buf_get_name(0) end
},
stream = "stderr",
ignore_exitcode = true,
parser = require("lint.parser").from_pattern(pattern, groups),
}

View File

@ -0,0 +1,18 @@
-- path/to/file:line: severity: 'offending part of source code': message
local pattern = "%s*([^:]+):(%d+): (.+): (.+: .+)"
local groups = { "file", "lnum", "severity", "message" }
return {
cmd = "glslc",
stdin = false,
args = {"-o", "-"}, -- "-" represents output of compilation result to stdout
ignore_exitcode = true,
stream = "stderr",
parser = require("lint.parser").from_pattern(pattern, groups, {
error = vim.diagnostic.severity.ERROR,
warning = vim.diagnostic.severity.WARN,
}, {
["source"] = "glslc",
["severity"] = vim.diagnostic.severity.WARN,
}),
}

View File

@ -0,0 +1,53 @@
local severities = {
error = vim.diagnostic.severity.ERROR,
warning = vim.diagnostic.severity.WARN,
refactor = vim.diagnostic.severity.INFO,
convention = vim.diagnostic.severity.HINT,
}
return {
cmd = 'golangci-lint',
append_fname = false,
args = {
'run',
'--out-format',
'json',
'--show-stats=false',
'--print-issued-lines=false',
'--print-linter-name=false',
function()
return vim.fn.fnamemodify(vim.api.nvim_buf_get_name(0), ":h")
end
},
stream = 'stdout',
ignore_exitcode = true,
parser = function(output, bufnr, cwd)
if output == '' then
return {}
end
local decoded = vim.json.decode(output)
if decoded["Issues"] == nil or type(decoded["Issues"]) == 'userdata' then
return {}
end
local diagnostics = {}
for _, item in ipairs(decoded["Issues"]) do
local curfile = vim.api.nvim_buf_get_name(bufnr)
local lintedfile = cwd .. "/" .. item.Pos.Filename
if curfile == lintedfile then
-- only publish if those are the current file diagnostics
local sv = severities[item.Severity] or severities.warning
table.insert(diagnostics, {
lnum = item.Pos.Line > 0 and item.Pos.Line - 1 or 0,
col = item.Pos.Column > 0 and item.Pos.Column - 1 or 0,
end_lnum = item.Pos.Line > 0 and item.Pos.Line - 1 or 0,
end_col = item.Pos.Column > 0 and item.Pos.Column - 1 or 0,
severity = sv,
source = item.FromLinter,
message = item.Text,
})
end
end
return diagnostics
end
}

View File

@ -0,0 +1,33 @@
local severities = {
error = vim.diagnostic.severity.ERROR,
warning = vim.diagnostic.severity.WARN,
info = vim.diagnostic.severity.INFO,
style = vim.diagnostic.severity.HINT,
}
return {
cmd = 'hadolint',
stdin = true,
stream = 'stdout',
ignore_exitcode = true,
args = {'-f', 'json', '-'},
parser = function(output)
local findings = vim.json.decode(output)
local diagnostics = {}
for _, finding in pairs(findings or {}) do
table.insert(diagnostics, {
lnum = finding.line - 1,
col = finding.column,
end_lnum = finding.line - 1,
end_col = finding.column,
severity = assert(severities[finding.level], 'missing mapping for severity ' .. finding.level),
message = finding.message,
source = 'hadolint',
code = finding.code,
})
end
return diagnostics
end,
}

View File

@ -0,0 +1,26 @@
local severities = {
error = vim.diagnostic.severity.ERROR,
warning = vim.diagnostic.severity.WARN,
suggestion = vim.diagnostic.severity.HINT,
}
return {
cmd = "hlint",
args = { "--json", "--no-exit-code" },
parser = function(output)
local diagnostics = {}
local items = #output > 0 and vim.json.decode(output) or {}
for _, item in ipairs(items) do
table.insert(diagnostics, {
lnum = item.startLine,
col = item.startColumn,
end_lnum = item.endLine,
end_col = item.endColumn,
severity = severities[item.severity:lower()],
source = "hlint",
message = item.hint .. (item.to ~= vim.NIL and (": " .. item.to) or ""),
})
end
return diagnostics
end,
}

View File

@ -0,0 +1,24 @@
local pattern = '.*: line (%d+), col (%d+), (%a+) %- (.+) %((.+)%)'
local groups = { 'lnum', 'col', 'severity', 'message', 'code' }
local severities = {
error = vim.diagnostic.severity.ERROR,
warning = vim.diagnostic.severity.WARN,
}
return {
cmd = "htmlhint",
stdin = true,
args = {
"stdin",
"-f",
"compact",
},
stream = "stdout",
ignore_exitcode = true,
parser = require('lint.parser').from_pattern(
pattern,
groups,
severities,
{ source = "htmlhint" }
)
}

View File

@ -0,0 +1,64 @@
local util = require('lint.util')
local severities = {
error = vim.diagnostic.severity.ERROR,
warning = vim.diagnostic.severity.WARN,
}
-- Inko unit tests require the inclusion of an extra directory, otherwise we
-- won't be able to find some of the files imported into unit tests.
local function include_tests()
local path = vim.fn.expand('%:p')
local separator = vim.fn.has('win32') == 1 and '\\' or '/'
local find = 'tests' .. separator .. 'test' .. separator
if not path:match(find) then
return
end
local tests_dir = util.find_nearest_directory('tests')
return '--include=' .. tests_dir
end
return {
cmd = 'inko',
args = {
'build',
include_tests,
'--format=json',
'--check',
},
stream = 'stderr',
stdin = false,
ignore_exitcode = true,
parser = function(output, _)
local items = {}
if output == '' then
return items
end
local decoded = vim.json.decode(output) or {}
local bufpath = vim.fn.expand('%:p')
for _, diag in ipairs(decoded) do
if diag.file == bufpath then
table.insert(items, {
source = 'inko',
lnum = diag.line - 1,
col = diag.column - 1,
end_lnum = diag.line - 1,
end_col = diag.column,
message = diag.message,
severity = assert(
severities[diag.level],
'missing mapping for severity ' .. diag.level
)
})
end
end
return items
end
}

View File

@ -0,0 +1,17 @@
-- error: path/to/file:line:col: message
local pattern = '[^:]+:[^:]+:(%d+):(%d+):(.+)'
local groups = { 'lnum', 'col', 'message' }
return {
cmd = 'janet',
stdin = true,
args = {
'-k',
},
stream = 'stderr',
ignore_exitcode = true,
parser = require('lint.parser').from_pattern(pattern, groups, nil, {
['source'] = 'janet',
['severity'] = vim.diagnostic.severity.ERROR,
}),
}

View File

@ -0,0 +1,10 @@
return {
cmd = "joker",
stdin = false,
stream = "stderr",
args = { "--lint" },
ignore_exitcode = true,
parser = require("lint.parser").from_errorformat("%f:%l:%c: %m", {
source = "joker",
}),
}

View File

@ -0,0 +1,13 @@
return {
cmd = "jq",
stdin = true,
stream = "stderr",
ignore_exitcode = true,
parser = require("lint.parser").from_pattern(
"^(.+): (.+) at line (%d+), column (%d+)$",
{ "code", "message", "lnum", "col" },
nil,
nil,
{ lnum_offset = -1 }
),
}

View File

@ -0,0 +1,11 @@
return {
cmd = 'jshint',
stdin = false,
args = {'--reporter', 'unix', '--extract', 'auto'},
stream = 'stdout',
ignore_exitcode = true,
parser = require('lint.parser').from_errorformat('%f:%l:%c: %m', {
source = 'jshint',
severity = vim.diagnostic.severity.WARN,
})
}

View File

@ -0,0 +1,15 @@
local pattern = "line (%d+), col (%d+), (.*)"
local groups = { "lnum", "col", "message" }
local severities = nil -- none provided
return {
cmd = 'jsonlint',
stream = 'stderr',
args = { '--compact' },
stdin = true,
ignore_exitcode = true,
parser = require('lint.parser').from_pattern(pattern, groups, severities, {
source = 'jsonlint',
severity = vim.diagnostic.severity.ERROR,
}),
}

View File

@ -0,0 +1,26 @@
return {
cmd = 'ktlint',
stdin = true,
args = { '--reporter=json', '--stdin' },
stream = 'stderr',
ignore_exitcode = true,
parser = function(output)
local ktlint_output = vim.json.decode(output)
if vim.tbl_isempty(ktlint_output) then
return {}
end
local diagnostics = {}
for _, error in pairs(ktlint_output[1].errors) do
table.insert(diagnostics, {
lnum = error.line - 1,
col = error.column - 1,
end_lnum = error.line - 1,
end_col = error.column - 1,
message = error.message,
severity = vim.diagnostic.severity.WARN,
source = 'ktlint',
})
end
return diagnostics
end
}

View File

@ -0,0 +1,15 @@
-- path/to/file, line <linum>: <message>
local pattern = '[^:]+, line (%d+):(.+)'
local groups = { 'lnum', 'message' }
return {
cmd = 'lacheck',
stdin = false,
args = {},
stream = 'stdout',
ignore_exitcode = false,
parser = require('lint.parser').from_pattern(pattern, groups, nil, {
["source"] = "lacheck",
['severity'] = vim.diagnostic.severity.WARN,
}),
}

View File

@ -0,0 +1,42 @@
-- LanguageTool might give output like "Err: 'yada yada'\n{ ... json here ... }'
local function parse_err_json(str)
local json_start = str:find('{', 1, true)
local err = nil
local json = str
if json_start and json_start > 1 then
err = str:sub(1, json_start - 1):gsub("^%s*(.-)%s*$", "%1") -- trim spaces
json = str:sub(json_start)
end
return err, json
end
return {
cmd = 'languagetool',
args = {'--autoDetect', '--json'},
stream = 'stdout',
parser = function(output, bufnr)
local err, json = parse_err_json(output)
if err then
vim.notify_once(err, vim.log.levels.INFO)
end
local decoded = vim.json.decode(json)
local diagnostics = {}
local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, true)
local content = table.concat(lines, '\n')
for _, match in pairs(decoded.matches or {}) do
local byteidx = vim.fn.byteidx(content, match.offset)
local line = vim.fn.byte2line(byteidx)
local col = byteidx - vim.fn.line2byte(line)
table.insert(diagnostics, {
lnum = line - 1,
end_lnum = line - 1,
col = col + 1,
end_col = col + 1,
message = match.message,
})
end
return diagnostics
end,
}

View File

@ -0,0 +1,55 @@
local function get_cur_file_name(bufnr)
bufnr = bufnr or 0
local str, _ = string.gsub(vim.api.nvim_buf_get_name(bufnr), '\\', '/')
return str
end
local severities = {
error = vim.diagnostic.severity.ERROR,
warning = vim.diagnostic.severity.WARN,
information = vim.diagnostic.severity.INFO,
hint = vim.diagnostic.severity.HINT,
}
return {
cmd = 'lint-openapi.cmd',
stdin = true,
args = {
'--json',
get_cur_file_name(0)
},
ignore_exitcode = true,
append_fname = false,
parser = function(output, _)
if vim.trim(output) == '' then
return {}
end
local decoded = vim.fn.json_decode(output)
local diagnostics = {}
local items_err = decoded['errors']
local items_warn = decoded['warnings']
for _, item in pairs(items_err or {}) do
table.insert(diagnostics, {
lnum = item.line - 1,
end_lnum = item.line - 1,
col = 1,
end_col = 1,
message = item.message .. ' | rule: ' .. item.rule,
source = 'lint-openapi',
severity = severities['error'],
})
end
for _, item in pairs(items_warn or {}) do
table.insert(diagnostics, {
lnum = item.line - 1,
end_lnum = item.line - 1,
col = 1,
end_col = 1,
message = item.message .. ' | rule: ' .. item.rule,
source = 'lint-openapi',
severity = severities['warning'],
})
end
return diagnostics
end
}

View File

@ -0,0 +1,20 @@
local pattern = '[^:]+:(%d+):(%d+)-(%d+): %((%a)(%d+)%) (.*)'
local groups = { 'lnum', 'col', 'end_col', 'severity', 'code', 'message' }
local severities = {
W = vim.diagnostic.severity.WARN,
E = vim.diagnostic.severity.ERROR,
}
return {
cmd = 'luacheck',
stdin = true,
args = { '--formatter', 'plain', '--codes', '--ranges', '-' },
ignore_exitcode = true,
parser = require('lint.parser').from_pattern(
pattern,
groups,
severities,
{ ['source'] = 'luacheck' },
{ end_col_offset = 0 }
),
}

View File

@ -0,0 +1,10 @@
local efm = "%f:%l:%c %m,%f:%l %m"
return {
cmd = "markdownlint-cli2",
ignore_exitcode = true,
stream = "stderr",
parser = require("lint.parser").from_errorformat(efm, {
source = "markdownlint",
severity = vim.diagnostic.severity.WARN,
}),
}

View File

@ -0,0 +1,11 @@
local efm = '%f:%l:%c %m,%f:%l %m'
local is_windows = vim.loop.os_uname().version:match('Windows')
return {
cmd = is_windows and 'markdownlint.cmd' or 'markdownlint',
ignore_exitcode = true,
stream = 'stderr',
parser = require('lint.parser').from_errorformat(efm, {
source = 'markdownlint',
severity = vim.diagnostic.severity.WARN,
})
}

View File

@ -0,0 +1,38 @@
local binary_name = "markuplint"
local severity_map = {
error = vim.diagnostic.severity.ERROR,
warning = vim.diagnostic.severity.WARN,
}
return {
cmd = function()
local local_binary = vim.fn.fnamemodify("./node_modules/.bin/" .. binary_name, ":p")
return vim.loop.fs_stat(local_binary) and local_binary or binary_name
end,
args = { "--format", "JSON" },
stdin = false,
stream = "stdout",
ignore_exitcode = true,
parser = function(output)
if vim.trim(output) == "" then
return {}
end
local decode_opts = { luanil = { object = true, array = true } }
local data = vim.json.decode(output, decode_opts)
local diagnostics = {}
for _, result in ipairs(data or {}) do
table.insert(diagnostics, {
lnum = result.line and result.line - 1 or 0,
col = result.col and result.col - 1 or 0,
message = result.message,
code = result.ruleId,
severity = severity_map[result.severity] or vim.diagnostic.severity.ERROR,
source = "markuplint",
})
end
return diagnostics
end,
}

View File

@ -0,0 +1,19 @@
local pattern = "L (%d+) %(C (%d+)[-]?([%d]*)%): (.-): (.-): (.*)"
local groups = { "lnum", "col", "end_col", "code", "severity", "message" }
local severities = {
ML2 = vim.diagnostic.severity.ERROR,
ML3 = vim.diagnostic.severity.ERROR,
ML4 = vim.diagnostic.severity.ERROR,
ML1 = vim.diagnostic.severity.WARN,
ML0 = vim.diagnostic.severity.INFO,
ML5 = vim.diagnostic.severity.HINT,
}
return {
cmd = "mlint",
stdin = false,
stream = "stderr",
args = { "-cyc", "-id", "-severity" },
ignore_exitcode = true,
parser = require("lint.parser").from_pattern(pattern, groups, severities, { ["source"] = "mlint" }),
}

View File

@ -0,0 +1,30 @@
-- path/to/file:line:col: severity: message
local pattern = '([^:]+):(%d+):(%d+):(%d+):(%d+): (%a+): (.*)'
local groups = { 'file', 'lnum', 'col', 'end_lnum', 'end_col', 'severity', 'message' }
local severities = {
error = vim.diagnostic.severity.ERROR,
warning = vim.diagnostic.severity.WARN,
note = vim.diagnostic.severity.HINT,
}
return {
cmd = 'mypy',
stdin = false,
ignore_exitcode = true,
args = {
'--show-column-numbers',
'--show-error-end',
'--hide-error-codes',
'--hide-error-context',
'--no-color-output',
'--no-error-summary',
'--no-pretty',
},
parser = require('lint.parser').from_pattern(
pattern,
groups,
severities,
{ ['source'] = 'mypy' },
{ end_col_offset = 0 }
),
}

View File

@ -0,0 +1,12 @@
local pattern = '%f: %l: %t %m,%-GChecking file %f'
return {
cmd = 'nagelfar',
args = {'-H'},
append_fname = true,
stdin = false,
stream = 'both',
ignore_exitcode = true,
env = nil,
parser = require('lint.parser').from_errorformat(pattern)
}

View File

@ -0,0 +1,18 @@
local pattern = '^(%w+): (.+) at .+:(%d+):(%d+)$'
local groups = { 'severity', 'message', 'lnum', 'col' }
local severity_map = { error = vim.diagnostic.severity.ERROR }
return {
cmd = 'nix-instantiate',
stdin = true,
args = {
'--parse',
'-',
},
stream = 'stderr',
ignore_exitcode = true,
parser = require('lint.parser').from_pattern(pattern, groups, severity_map, {
['source'] = 'nix',
['severity'] = vim.diagnostic.severity.WARN,
})
}

View File

@ -0,0 +1,13 @@
local pattern = "^%s+(%d+)%s+[^a-z]+m([a-z]+)[^a-z]+m%s+(.*)%s+(%w+)"
local groups = { "lnum", "severity", "message", "code" }
local severity_map = {
["info"] = vim.diagnostic.severity.INFO,
["warning"] = vim.diagnostic.severity.WARN,
["error"] = vim.diagnostic.severity.ERROR,
}
return {
cmd = "npm-groovy-lint",
stdin = false,
parser = require("lint.parser").from_pattern(pattern, groups, severity_map, { ["source"] = "npm-groovy-lint" }),
}

View File

@ -0,0 +1,23 @@
-- path/to/file:line:severity:code:message
local pattern = '([^:]+):(%d+):(%a+):(.+):(.+)'
local groups = { 'file', 'lnum', 'severity', 'code', 'message' }
local severity_map = {
['error'] = vim.diagnostic.severity.ERROR,
['warning'] = vim.diagnostic.severity.WARN,
['info'] = vim.diagnostic.severity.INFO,
}
return {
cmd = 'oelint-adv',
stdin = false,
args = {
'--quiet',
'--messageformat={path}:{line}:{severity}:{id}:{msg}',
},
ignore_exitcode = true,
stream = 'stderr',
parser = require('lint.parser').from_pattern(
pattern, groups, severity_map,
{ ['source'] = 'oelint-adv' }
),
}

View File

@ -0,0 +1,36 @@
-- https://github.com/open-policy-agent/opa
return {
cmd = "opa",
args = { "check", "--strict", "--format", "json" },
stdin = false,
append_fname = true,
stream = "stderr",
ignore_exitcode = true,
parser = function(output, _)
local diagnostics = {}
if output == "" then
return diagnostics
end
local decoded = vim.json.decode(output)
if decoded ~= nil then
for _, item in ipairs(decoded.errors or {}) do
local lnum = item.location.row - 1
table.insert(diagnostics, {
lnum = lnum,
end_lnum = lnum,
col = item.location.col - 1,
end_col = item.location.col,
severity = vim.diagnostic.severity.ERROR,
source = "opa_check",
message = item.message,
code = item.code,
})
end
end
return diagnostics
end,
}

View File

@ -0,0 +1,11 @@
return {
cmd = "oxlint",
stdin = false,
args = { "--format", "unix" },
stream = "stdout",
ignore_exitcode = true,
parser = require("lint.parser").from_errorformat("%f:%l:%c: %m", {
source = "oxlint",
severity = vim.diagnostic.severity.WARN,
}),
}

View File

@ -0,0 +1,32 @@
local pattern = '(%d+):(%d+):(%w+) (.+)'
local groups = { 'lnum', 'col', 'severity', 'message' }
local severity_map = {
['1'] = vim.diagnostic.severity.HINT,
['2'] = vim.diagnostic.severity.INFO,
['3'] = vim.diagnostic.severity.WARN,
['4'] = vim.diagnostic.severity.WARN,
['5'] = vim.diagnostic.severity.ERROR,
}
local find_conf = function()
local conf = vim.fs.find('.perlcriticrc', {
upward = true,
stop = vim.fs.dirname(vim.loop.os_homedir()),
path = vim.fs.dirname(vim.api.nvim_buf_get_name(0)),
})
return conf[1] or ''
end
return function()
local profile = find_conf()
return {
cmd = 'perlcritic',
stdin = true,
args = { '--nocolor', '--verbose', '%l:%c:%s %m [%p]\n', '--profile', profile },
stream = 'stdout',
ignore_exitcode = true, -- returns 2 if policy violations are found, but 1 if perlcritic itself has errors. :-(
parser = require('lint.parser').from_pattern(pattern, groups, severity_map, {
['source'] = 'perlcritic',
}),
}
end

View File

@ -0,0 +1,27 @@
-- perlimports requires both to read from stdin *and*
-- to have the filename appended.
return function()
local filename = vim.api.nvim_buf_get_name(0)
return {
cmd = 'perlimports',
stdin = true,
args = { '--lint', '--json', '--read-stdin', '--filename', filename },
stream = 'stderr',
parser = function(output)
local result = vim.fn.split(output, '\n')
local diagnostics = {}
for _, message in ipairs(result) do
local decoded = vim.json.decode(message)
table.insert(diagnostics, {
lnum = decoded.location.start.line - 1,
col = decoded.location.start.column - 1,
end_lnum = decoded.location['end'].line - 1,
end_col = decoded.location['end'].column - 1,
severity = vim.diagnostic.severity.INFO,
message = decoded.reason,
})
end
return diagnostics
end,
}
end

View File

@ -0,0 +1,18 @@
-- path/to/file:line:col: code message
local pattern = "[^:]+:(%d+):(%d+):(%w+):(.+)"
local groups = { "lnum", "col", "code", "message" }
return {
cmd = "pflake8",
stdin = true,
args = {
"--format=%(path)s:%(row)d:%(col)d:%(code)s:%(text)s",
"--no-show-source",
"-",
},
ignore_exitcode = true,
parser = require("lint.parser").from_pattern(pattern, groups, nil, {
["source"] = "flake8",
["severity"] = vim.diagnostic.severity.WARN,
}),
}

View File

@ -0,0 +1,21 @@
local efm = table.concat({
'Deprecated:\\ %m\\ %tn\\ Standard\\ input\\ code\\ on\\ line\\ %l', -- nasty hack for %t
'%tarning:\\ %m\\ in\\ Standard\\ input\\ code\\ on\\ line\\ %l',
'Parse\\ %trror:\\ %m\\ in\\ Standard\\ input\\ code\\ on\\ line\\ %l',
'Fatal\\ %trror:\\ %m\\ in\\ Standard\\ input\\ code\\ on\\ line\\ %l',
}, ',')
return {
cmd = 'php',
stdin = true,
args = {
-- '-d error_reporting=-1',
'-d display_errors=stdout',
'-l',
},
stream = 'stdout',
ignore_exitcode = true,
parser = require('lint.parser').from_errorformat(efm, {
source = 'php'
})
}

View File

@ -0,0 +1,49 @@
local severities = {
ERROR = vim.diagnostic.severity.ERROR,
WARNING = vim.diagnostic.severity.WARN,
}
local bin ='phpcs'
return {
cmd = function()
local local_bin = vim.fn.fnamemodify('vendor/bin/' .. bin, ':p')
return vim.loop.fs_stat(local_bin) and local_bin or bin
end,
stdin = true,
args = {
'-q',
'--report=json',
'-', -- need `-` at the end for stdin support
},
ignore_exitcode = true,
parser = function(output, _)
if vim.trim(output) == '' or output == nil then
return {}
end
if not vim.startswith(output,'{') then
vim.notify(output)
return {}
end
local decoded = vim.json.decode(output)
local diagnostics = {}
local messages = decoded['files']['STDIN']['messages']
for _, msg in ipairs(messages or {}) do
table.insert(diagnostics, {
lnum = msg.line - 1,
end_lnum = msg.line - 1,
col = msg.column - 1,
end_col = msg.column - 1,
message = msg.message,
code = msg.source,
source = bin,
severity = assert(severities[msg.type], 'missing mapping for severity ' .. msg.type),
})
end
return diagnostics
end
}

View File

@ -0,0 +1,39 @@
local bin = 'phpinsights'
local insight_to_severity = {
Code = vim.diagnostic.severity.ERROR,
Complexity = vim.diagnostic.severity.WARN,
Architecture = vim.diagnostic.severity.WARN,
Style = vim.diagnostic.severity.HINT,
Security = vim.diagnostic.severity.ERROR,
}
return {
cmd = function ()
local local_bin = vim.fn.fnamemodify('vendor/bin/' .. bin, ':p')
return vim.loop.fs_stat(local_bin) and local_bin or bin
end,
stdin = false,
args = { 'analyse', '--format', 'json' },
parser = function(output)
if output == nil then
return {}
end
local diagnostics = {}
local json = vim.json.decode(output) or {}
for insight, severity in pairs(insight_to_severity) do
for _, message in ipairs(json[insight] or {}) do
table.insert(diagnostics, {
lnum = message.line - 1,
col = 0,
message = message.message,
severity = severity,
source = bin,
})
end
end
return diagnostics
end,
}

View File

@ -0,0 +1,56 @@
local severities = {}
severities[1] = vim.diagnostic.severity.ERROR
severities[2] = vim.diagnostic.severity.WARN
severities[3] = vim.diagnostic.severity.INFO
severities[4] = vim.diagnostic.severity.HINT
severities[5] = vim.diagnostic.severity.HINT
local bin = 'phpmd'
return {
cmd = function ()
local local_bin = vim.fn.fnamemodify('vendor/bin/' .. bin, ':p')
return vim.loop.fs_stat(local_bin) and local_bin or bin
end,
stdin = true,
args = {
'-',
'json',
'cleancode,codesize,controversial,design,naming,unusedcode',
},
stream = 'stdout',
ignore_exitcode = true,
parser = function(output, _)
if vim.trim(output) == '' or output == nil then
return {}
end
if not vim.startswith(output, '{') then
vim.notify(output)
return {}
end
local decoded = vim.json.decode(output)
local diagnostics = {}
local messages = {}
if decoded['files'] and decoded['files'][1] and decoded['files'][1]['violations'] then
messages = decoded['files'][1]['violations']
end
for _, msg in ipairs(messages or {}) do
table.insert(diagnostics, {
lnum = msg.beginLine - 1,
end_lnum = msg.endLine - 1,
col = 0,
end_col = 0,
message = msg.description,
code = msg.rule,
source = bin,
severity = assert(severities[msg.priority], 'missing mapping for severity ' .. msg.priority),
})
end
return diagnostics
end
}

View File

@ -0,0 +1,38 @@
local bin = 'phpstan'
return {
cmd = function ()
local local_bin = vim.fn.fnamemodify('vendor/bin/' .. bin, ':p')
return vim.loop.fs_stat(local_bin) and local_bin or bin
end,
args = {
'analyze',
'--error-format=json',
'--no-progress',
},
ignore_exitcode = true,
parser = function(output, bufnr)
if vim.trim(output) == '' or output == nil then
return {}
end
local file = vim.json.decode(output).files[vim.api.nvim_buf_get_name(bufnr)]
if file == nil then
return {}
end
local diagnostics = {}
for _, message in ipairs(file.messages or {}) do
table.insert(diagnostics, {
lnum = type(message.line) == 'number' and (message.line - 1) or 0,
col = 0,
message = message.message,
source = bin,
})
end
return diagnostics
end,
}

View File

@ -0,0 +1,15 @@
local pattern = [[([^:]*):(%d+):(%d+): ([^[]+)]]
local groups = { 'file', 'lnum', 'col', 'message'}
return {
cmd = "ponyc",
stdin = false,
append_fname = false,
args = { "--pass=verify" },
stream = "stderr",
ignore_exitcode = true,
parser = require("lint.parser").from_pattern(pattern, groups, nil, {
["source"] = "ponyc",
["severity"] = vim.diagnostic.severity.ERROR,
}),
}

View File

@ -0,0 +1,38 @@
local binary_name = "prisma-lint"
return {
cmd = function()
local local_binary = vim.fn.fnamemodify('./node_modules/.bin/' .. binary_name, ':p')
return vim.loop.fs_stat(local_binary) and local_binary or binary_name
end,
stdin = false,
args = {
"--output-format",
"json"
},
append_fname = true,
stream = 'both',
ignore_exitcode = true,
parser = function(output)
local decoded = vim.json.decode(output)
local diagnostics = {}
if decoded == nil then
return diagnostics
end
for _, violation in pairs(decoded["violations"]) do
local location = violation.location
table.insert(diagnostics, {
source = binary_name,
lnum = location.startLine - 1,
end_lnum = location.endLine - 1,
col = location.startColumn - 1,
-- endColumn is inclusive, but end_col is exclusive.
end_col = location.endColumn,
message = violation.message,
code = violation.ruleName,
severity = vim.diagnostic.severity.ERROR,
})
end
return diagnostics
end,
}

View File

@ -0,0 +1,14 @@
-- path/to/file:line:col: code.subcode.subsubcode message
local pattern = '([^:]+):(%d+):(%d+): ([^ ]+) (.*)'
local groups = { 'file', 'lnum', 'col', 'code', 'message' }
return {
cmd = 'proselint',
stdin = false,
args = {},
ignore_exitcode = true,
parser = require('lint.parser').from_pattern(pattern, groups, nil, {
['source'] = 'proselint',
['severity'] = vim.diagnostic.severity.INFO,
}),
}

View File

@ -0,0 +1,43 @@
return {
cmd = function ()
for _, fname in ipairs({ './vendor/bin/psalm', './vendor/bin/psalm.phar' }) do
local local_psalm = vim.fn.fnamemodify(fname, ':p')
local stat = vim.loop.fs_stat(local_psalm)
if stat then
return local_psalm
end
end
return 'psalm'
end,
args = {
'--output-format=json',
'--show-info=true',
'--no-progress',
},
parser = function(output, bufnr)
if output == nil then
return {}
end
local filename = vim.api.nvim_buf_get_name(bufnr)
local messages = vim.json.decode(output)
local diagnostics = {}
for _, message in ipairs(messages or {}) do
if message.file_path == filename then
table.insert(diagnostics, {
lnum = message.line_from - 1,
end_lnum = message.line_to - 1,
col = message.column_from - 1,
end_col = message.column_to - 1,
message = message.message,
source = 'psalm',
severity = message.severity,
})
end
end
return diagnostics
end
}

View File

@ -0,0 +1,20 @@
local pattern = '(.+):(%d+):(%d+):(%l+):(.+):(.+)'
local groups = { 'file', 'lnum', 'col', 'severity', 'code', 'message' }
local severities = {
['error'] = vim.diagnostic.severity.ERROR,
['warning'] = vim.diagnostic.severity.WARN,
}
return {
cmd = 'puppet-lint',
stdin = false,
args = {
'--no-autoloader_layout-check',
'--log-format', '%{path}:%{line}:%{column}:%{kind}:%{check}:%{message}'
},
ignore_exitcode = true,
parser = require('lint.parser').from_pattern(pattern, groups, severities, {
['source'] = 'puppet-lint',
}),
}

View File

@ -0,0 +1,17 @@
-- path/to/file:line:col:code:message
local pattern = '[^:]+:(%d+):(%d+):(%w+):(.+)'
local groups = { 'lnum', 'col', 'code', 'message' }
return {
cmd = 'pycodestyle',
stdin = true,
args = {
'--format=%(path)s:%(row)d:%(col)d:%(code)s:%(text)s',
'-',
},
ignore_exitcode = true,
parser = require('lint.parser').from_pattern(pattern, groups, nil, {
['source'] = 'pycodestyle',
['severity'] = vim.diagnostic.severity.WARN,
}),
}

View File

@ -0,0 +1,9 @@
return {
cmd = 'pydocstyle',
stdin = false,
ignore_exitcode = true,
parser = require('lint.parser').from_errorformat(
'%N%f:%l%.%#,%Z%s%#D%n: %m',
{source = 'pydocstyle'}
),
}

View File

@ -0,0 +1,45 @@
local severities = {
error = vim.diagnostic.severity.ERROR,
fatal = vim.diagnostic.severity.ERROR,
warning = vim.diagnostic.severity.WARN,
refactor = vim.diagnostic.severity.INFO,
info = vim.diagnostic.severity.INFO,
convention = vim.diagnostic.severity.HINT,
}
return {
cmd = 'pylint',
stdin = false,
args = {
'-f', 'json'
},
ignore_exitcode = true,
parser = function(output, bufnr)
if output == "" then return {} end
local diagnostics = {}
local buffer_path = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(bufnr), ":~:.")
for _, item in ipairs(vim.json.decode(output) or {}) do
if not item.path or vim.fn.fnamemodify(item.path, ":~:.") == buffer_path then
local column = item.column > 0 and item.column or 0
local end_column = item.endColumn ~= vim.NIL and item.endColumn or column
table.insert(diagnostics, {
source = 'pylint',
lnum = item.line - 1,
col = column,
end_lnum = item.line - 1,
end_col = end_column,
severity = assert(severities[item.type], 'missing mapping for severity ' .. item.type),
message = item.message .. " (" .. item.symbol .. ")",
code = item['message-id'],
user_data = {
lsp = {
code = item['message-id'],
},
},
})
end
end
return diagnostics
end,
}

View File

@ -0,0 +1,26 @@
-- example output:
-- hello_world.ts:48:5: warning: use of undeclared variable: DEV_MODE [E0057]
local pattern = "[^:]+:(%d+):(%d+): (%w+): (.+)"
local groups = { "lnum", "col", "severity", "message" }
local severities = {
["error"] = vim.diagnostic.severity.ERROR,
["warning"] = vim.diagnostic.severity.WARN,
}
local defaults = { ["source"] = "quick-lint-js" }
return {
cmd = "quick-lint-js",
args = {
"--stdin",
-- --stdin-path is required to determine the language
"--stdin-path",
function()
return vim.api.nvim_buf_get_name(0)
end,
},
ignore_exitcode = true,
stream = "stderr",
parser = require("lint.parser").from_pattern(pattern, groups, severities, defaults),
}

View File

@ -0,0 +1,43 @@
-- https://github.com/StyraInc/regal
local severities = {
error = vim.diagnostic.severity.ERROR,
warning = vim.diagnostic.severity.WARN,
}
return {
cmd = "regal",
args = { "lint", "--format", "json" },
stdin = false,
append_fname = true,
stream = "stdout",
ignore_exitcode = true,
parser = function(output, _)
local diagnostics = {}
if output == "" then
return diagnostics
end
local decoded = vim.json.decode(output)
if decoded ~= nil then
for _, item in ipairs(decoded.violations or {}) do
local end_col = item.location.text ~= nil and item.location.text:len() + 1 or item.location.col
local lnum = math.max(item.location.row - 1, 0)
table.insert(diagnostics, {
lnum = lnum,
end_lnum = lnum,
col = math.max(item.location.col - 1, 0),
end_col = end_col,
severity = severities[item.level] or severities.error,
source = "[regal] " .. item.category,
message = item.description,
code = item.title,
})
end
end
return diagnostics
end,
}

View File

@ -0,0 +1,12 @@
-- path/to/file:line:col: code message
local pattern = '[^:]+:(%d+):(%d+): (.*)'
local groups = { 'lnum', 'col', 'message' }
return {
cmd = 'revive',
stdin = false,
args = {},
parser = require('lint.parser').from_pattern(pattern, groups, nil, {
['source'] = 'revive',
}),
}

Some files were not shown because too many files have changed in this diff Show More