mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-07 13:14:29 +08:00
Compare commits
468 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5556fcbd1c | ||
|
|
cf599f4470 | ||
|
|
e71d831119 | ||
|
|
d8abe0d6a2 | ||
|
|
55757e3d78 | ||
|
|
8e7ede3be8 | ||
|
|
6f8db3e5c4 | ||
|
|
2398fd7456 | ||
|
|
c1366f8a62 | ||
|
|
5089b09b7e | ||
|
|
220ebb3a79 | ||
|
|
25b5fad15c | ||
|
|
39f15811c3 | ||
|
|
34171774eb | ||
|
|
80328fa156 | ||
|
|
1fcf6444dc | ||
|
|
e57978ddd6 | ||
|
|
be5c7a09ce | ||
|
|
b952dda386 | ||
|
|
231398dddc | ||
|
|
c4579e1809 | ||
|
|
5b986ce5d3 | ||
|
|
0b0cbfa80a | ||
|
|
841acf725c | ||
|
|
3878be9977 | ||
|
|
b43ed6baf5 | ||
|
|
e023e7a2fe | ||
|
|
346c91fb6b | ||
|
|
a97afd3380 | ||
|
|
658ec4b10e | ||
|
|
4339af2bb6 | ||
|
|
5292d2f349 | ||
|
|
81d993086e | ||
|
|
5946a128c3 | ||
|
|
8a8879a28f | ||
|
|
07ebfbeef0 | ||
|
|
a790077136 | ||
|
|
090f8a8f38 | ||
|
|
90d4fb139c | ||
|
|
515dcdef29 | ||
|
|
d090dec8b4 | ||
|
|
ef495ba32d | ||
|
|
010ebc2459 | ||
|
|
b2e6d0dff8 | ||
|
|
69d6ff6020 | ||
|
|
40e69794eb | ||
|
|
d8ea83e344 | ||
|
|
8eb41dc94c | ||
|
|
6fd10f80de | ||
|
|
5204f2dbc2 | ||
|
|
618074a053 | ||
|
|
663fe75d0f | ||
|
|
e71c4a8bea | ||
|
|
dded246aba | ||
|
|
221cb0f8cf | ||
|
|
3ddbe48d84 | ||
|
|
d8a638f38a | ||
|
|
844354cfed | ||
|
|
02c8793c53 | ||
|
|
be547a0111 | ||
|
|
620ec32da1 | ||
|
|
3859ac0c9b | ||
|
|
70177480ba | ||
|
|
a809c4fa3a | ||
|
|
65aa88a7d5 | ||
|
|
f21f52343d | ||
|
|
47577564a2 | ||
|
|
25045641fb | ||
|
|
a300014396 | ||
|
|
e376f0ae44 | ||
|
|
3ab414de1a | ||
|
|
7392f808c0 | ||
|
|
753592ca66 | ||
|
|
e0bd490ed9 | ||
|
|
54a08c5f8c | ||
|
|
5091e2de45 | ||
|
|
638ca42082 | ||
|
|
4634b1be93 | ||
|
|
5731616cd2 | ||
|
|
c76f721b59 | ||
|
|
a640d3b022 | ||
|
|
1d1b5155e6 | ||
|
|
c989ef0fc6 | ||
|
|
9fc01bd246 | ||
|
|
8f6044b8b6 | ||
|
|
49b6805b09 | ||
|
|
0be77c60c5 | ||
|
|
cde50f1091 | ||
|
|
cb56cbb714 | ||
|
|
2bd352370f | ||
|
|
3910b025b2 | ||
|
|
70fdeb7c22 | ||
|
|
5a1ebdb633 | ||
|
|
8bc66cff39 | ||
|
|
6ebd8f355c | ||
|
|
a59d1ddbf3 | ||
|
|
71c2e65d64 | ||
|
|
52c933cd72 | ||
|
|
3d2bddf4af | ||
|
|
677263f115 | ||
|
|
7302bedc5e | ||
|
|
91df9ba2c0 | ||
|
|
4e9420d1f5 | ||
|
|
e2271b769c | ||
|
|
7f42aedaec | ||
|
|
661ed6e40b | ||
|
|
a7614d9502 | ||
|
|
8eb99c3cec | ||
|
|
b6a487ccf9 | ||
|
|
cb8a140141 | ||
|
|
e19a81cb09 | ||
|
|
65e6e50bf8 | ||
|
|
9d24cc4047 | ||
|
|
c4ad92e458 | ||
|
|
18a7d32c4c | ||
|
|
c11d2ae375 | ||
|
|
1a52a2b880 | ||
|
|
18f4d5a6da | ||
|
|
f3da8f45c1 | ||
|
|
b3a9a0e3e8 | ||
|
|
8055a03067 | ||
|
|
f238e15f10 | ||
|
|
574cb11594 | ||
|
|
d9bdbd5a58 | ||
|
|
a33b3f189d | ||
|
|
26195efa0b | ||
|
|
1c5253b928 | ||
|
|
89cc8ca314 | ||
|
|
ff28836616 | ||
|
|
73d031d7ea | ||
|
|
555d23c035 | ||
|
|
8198c2b63c | ||
|
|
b8963f21bf | ||
|
|
9474a9d319 | ||
|
|
963e16870b | ||
|
|
02aad45aa6 | ||
|
|
59fd98b8b2 | ||
|
|
fbc846b4ba | ||
|
|
dd77b6eac5 | ||
|
|
e951056e7b | ||
|
|
2be39d3e1c | ||
|
|
2b34cf098a | ||
|
|
9821b2c414 | ||
|
|
6661ff9794 | ||
|
|
a9823cbfd5 | ||
|
|
03f1c1e81b | ||
|
|
c277cdef8c | ||
|
|
ad1bd424fa | ||
|
|
a170cc806a | ||
|
|
22a0cd6e05 | ||
|
|
a21a75c19e | ||
|
|
8595fcdeb9 | ||
|
|
5239ef9c83 | ||
|
|
edfe65a22c | ||
|
|
e53debe000 | ||
|
|
c2f547b6e3 | ||
|
|
984c4f0658 | ||
|
|
1ea5400e8d | ||
|
|
b60a7224ab | ||
|
|
29ffd5134f | ||
|
|
6833e01f23 | ||
|
|
0aa8640d07 | ||
|
|
e235e5a6a5 | ||
|
|
63e8946fc8 | ||
|
|
c7fbcb3c02 | ||
|
|
d482b8e3b7 | ||
|
|
f9b43a566c | ||
|
|
52eff3bd83 | ||
|
|
7c2a5052a8 | ||
|
|
1d86a724f2 | ||
|
|
f36f38c960 | ||
|
|
301d30229b | ||
|
|
05ce86ea33 | ||
|
|
6e423a94cd | ||
|
|
c09f8f5764 | ||
|
|
33278f0fce | ||
|
|
9958a8d32e | ||
|
|
ed9cdca127 | ||
|
|
fca77266bd | ||
|
|
688212130d | ||
|
|
3bde390c58 | ||
|
|
0cdb653c9c | ||
|
|
40dca63891 | ||
|
|
b8f5a4923c | ||
|
|
f4c5d29c64 | ||
|
|
c7536fb4fd | ||
|
|
3152e5c207 | ||
|
|
d08d2dac79 | ||
|
|
8264e265a8 | ||
|
|
ec178b0b3b | ||
|
|
b36882e72e | ||
|
|
87fb72346a | ||
|
|
2a238fda9e | ||
|
|
54900d5216 | ||
|
|
22db934db9 | ||
|
|
4a0735a195 | ||
|
|
0827cb5483 | ||
|
|
8e3c1dbd11 | ||
|
|
b031531e79 | ||
|
|
73ec83d055 | ||
|
|
908e94622e | ||
|
|
b9cf450684 | ||
|
|
e13651c16d | ||
|
|
cdd1ddffdb | ||
|
|
8f8d015dae | ||
|
|
4bea50b82f | ||
|
|
623fdf212c | ||
|
|
0507503aa7 | ||
|
|
80c7fbcefe | ||
|
|
2f19cf874b | ||
|
|
1a524ca63e | ||
|
|
47a8ebc8b9 | ||
|
|
9d3bda4441 | ||
|
|
b356d56448 | ||
|
|
a3299bf03a | ||
|
|
cc02eb8a5a | ||
|
|
456378cb53 | ||
|
|
47e681529b | ||
|
|
4c6b58f70c | ||
|
|
d646ebda72 | ||
|
|
c7193e775e | ||
|
|
753cf5da95 | ||
|
|
5a9a365aed | ||
|
|
e5d0a17694 | ||
|
|
7112776d1b | ||
|
|
fb0adc602e | ||
|
|
9d6883561c | ||
|
|
b2d3764a18 | ||
|
|
20e64fbae0 | ||
|
|
f8de08faf0 | ||
|
|
18cb9a725d | ||
|
|
e9e1bec772 | ||
|
|
fb0c931b2d | ||
|
|
5c839c4825 | ||
|
|
9c6e25d8d8 | ||
|
|
be4347084e | ||
|
|
8cc7cd3aa1 | ||
|
|
41c4f3431c | ||
|
|
2560cdd56e | ||
|
|
2365fd2948 | ||
|
|
0a282eb76a | ||
|
|
342e83db60 | ||
|
|
17a76a7403 | ||
|
|
797b03b35e | ||
|
|
5af82312fb | ||
|
|
1680f7af63 | ||
|
|
79701f6f20 | ||
|
|
2d02de33d4 | ||
|
|
ea124c49d0 | ||
|
|
a5d7bb449b | ||
|
|
626568d66d | ||
|
|
ae6cecabb6 | ||
|
|
f67fc43d9b | ||
|
|
c6d11f4281 | ||
|
|
b6f0b17eaf | ||
|
|
bc548b2ef9 | ||
|
|
e6b6146731 | ||
|
|
b300b0646d | ||
|
|
c14886e479 | ||
|
|
c52a4910bf | ||
|
|
7614560a6e | ||
|
|
8e9130d66e | ||
|
|
78b9ae0f1c | ||
|
|
d5ae3201a4 | ||
|
|
b1462ac66c | ||
|
|
322910dc0b | ||
|
|
dcf7cbe366 | ||
|
|
34aa3437e0 | ||
|
|
0c26e8945c | ||
|
|
9ae2df1958 | ||
|
|
7dee9da0f2 | ||
|
|
2dcd2ee4da | ||
|
|
b9f31621e4 | ||
|
|
abcf2909e6 | ||
|
|
4709e67627 | ||
|
|
2b546a50dc | ||
|
|
fe95fcd357 | ||
|
|
670858f774 | ||
|
|
ac8cc6d991 | ||
|
|
16772298ab | ||
|
|
a535d07f28 | ||
|
|
5010ddc28f | ||
|
|
16cfedf04a | ||
|
|
2edea15358 | ||
|
|
c18451fba9 | ||
|
|
2c4700ab7f | ||
|
|
39ebb431b6 | ||
|
|
f7d7abe5b2 | ||
|
|
2d608b9329 | ||
|
|
e4a6da936d | ||
|
|
70cd1d5a57 | ||
|
|
593cafa18b | ||
|
|
747d4fe80b | ||
|
|
a767578d44 | ||
|
|
666cfc6ee2 | ||
|
|
9ac74c44fe | ||
|
|
d1023e9c2c | ||
|
|
09d50ebe31 | ||
|
|
a3d2fb5688 | ||
|
|
617582c5d3 | ||
|
|
6e07cf5b12 | ||
|
|
1356cf8e01 | ||
|
|
db531171ac | ||
|
|
d6557b2c5c | ||
|
|
ad4c7f92cf | ||
|
|
bc1cf285c2 | ||
|
|
7eb84242ee | ||
|
|
35913d9ce7 | ||
|
|
a4ffd2f37c | ||
|
|
ec82530247 | ||
|
|
7c32ef104b | ||
|
|
eaeb71993f | ||
|
|
79d4935ccf | ||
|
|
2c252c0f12 | ||
|
|
6000d956f0 | ||
|
|
5810d7faa0 | ||
|
|
84af543907 | ||
|
|
63b9d9e9df | ||
|
|
fa33faad9e | ||
|
|
db4d68eae7 | ||
|
|
ded1bc14df | ||
|
|
810e884dbe | ||
|
|
fbf59fd4ce | ||
|
|
cfdb41f4d2 | ||
|
|
e6f527f954 | ||
|
|
cd860e3e8d | ||
|
|
86297a7c65 | ||
|
|
e45c16d9bb | ||
|
|
e0c014ab8c | ||
|
|
b4d23d700b | ||
|
|
d1424de1f9 | ||
|
|
8ab632e6f2 | ||
|
|
a0059cfe03 | ||
|
|
12217480f9 | ||
|
|
c1998b170c | ||
|
|
78e37dabb7 | ||
|
|
6d732b9fb4 | ||
|
|
710c3ee3d2 | ||
|
|
3bb75a6fde | ||
|
|
8ea9044667 | ||
|
|
cddb26558f | ||
|
|
f3fec6685e | ||
|
|
ee6dabcc4e | ||
|
|
af6830a722 | ||
|
|
ce845e51f2 | ||
|
|
87616c5e91 | ||
|
|
7d1fde292d | ||
|
|
a5f754a5e0 | ||
|
|
ca83f11bee | ||
|
|
f133ce96f8 | ||
|
|
cbdf10a129 | ||
|
|
0b50ebb0f0 | ||
|
|
235fc90e22 | ||
|
|
aa94d0902a | ||
|
|
5a6ffc2804 | ||
|
|
0931e99ea4 | ||
|
|
a8a4df05e6 | ||
|
|
da410caff8 | ||
|
|
a6cc492a99 | ||
|
|
27feab7e3a | ||
|
|
eab77b7072 | ||
|
|
3b1bc2bd13 | ||
|
|
92918fd841 | ||
|
|
23ea62d40a | ||
|
|
3352a6c9df | ||
|
|
fe70742bb9 | ||
|
|
9e83878900 | ||
|
|
58717e05a3 | ||
|
|
54ff573174 | ||
|
|
bd5ff5b1e5 | ||
|
|
7d174b0056 | ||
|
|
1aea6a34ff | ||
|
|
4fa66ab627 | ||
|
|
15c48650e7 | ||
|
|
cad9fc19c6 | ||
|
|
507e32e91c | ||
|
|
5afbc9b701 | ||
|
|
4c50aec79c | ||
|
|
4c6c5bf84f | ||
|
|
b50ae96413 | ||
|
|
f7f6f6541d | ||
|
|
bc97735b6d | ||
|
|
dcbb0ffee5 | ||
|
|
5885954197 | ||
|
|
bc32e24203 | ||
|
|
400580e4e8 | ||
|
|
9e0d7a9d8c | ||
|
|
ff80b23ee1 | ||
|
|
b2be833744 | ||
|
|
340c0bbac5 | ||
|
|
d12e990f73 | ||
|
|
bbabdd0043 | ||
|
|
a96cc92edf | ||
|
|
7b73204f25 | ||
|
|
505d114a68 | ||
|
|
5c7b55edec | ||
|
|
768f761017 | ||
|
|
05d3bb12dd | ||
|
|
78e0029488 | ||
|
|
eb79b52a9a | ||
|
|
d787050fa8 | ||
|
|
29d0a20dc3 | ||
|
|
751d965265 | ||
|
|
b44f6053d1 | ||
|
|
82dd80c692 | ||
|
|
6a84605c57 | ||
|
|
b50a7318fb | ||
|
|
47ff514878 | ||
|
|
025f3407d6 | ||
|
|
ab0e76dbd5 | ||
|
|
836a2cfe3b | ||
|
|
c67d3b7e60 | ||
|
|
a70591fa76 | ||
|
|
ab47011ef2 | ||
|
|
1b55e5edab | ||
|
|
4fd5bf81be | ||
|
|
7def00d5a9 | ||
|
|
dd5806662a | ||
|
|
996732d5a6 | ||
|
|
fdc7166c3c | ||
|
|
f9aa7d3b9a | ||
|
|
8eb4f95766 | ||
|
|
46225f3bb1 | ||
|
|
d9a7364dae | ||
|
|
7ce960ae51 | ||
|
|
130928590b | ||
|
|
8315c0e337 | ||
|
|
854066e849 | ||
|
|
b43413916d | ||
|
|
5859050d29 | ||
|
|
af02fb5183 | ||
|
|
871ce1c8f5 | ||
|
|
1bd9b0fbe2 | ||
|
|
a04e73ddbc | ||
|
|
1b8450e7a0 | ||
|
|
35093e8f0d | ||
|
|
6ab92af181 | ||
|
|
e134eca694 | ||
|
|
18fef18ab1 | ||
|
|
7b7a275902 | ||
|
|
bb293b297c | ||
|
|
a1cf7f67a1 | ||
|
|
638eb1f000 | ||
|
|
84b280b881 | ||
|
|
def4466671 | ||
|
|
160b9548ee | ||
|
|
fd6f05c9ea | ||
|
|
5a3cfbbdf5 | ||
|
|
51f256e897 | ||
|
|
857ca941d2 | ||
|
|
b731bd77ab | ||
|
|
5b731f761f | ||
|
|
9f21e45156 | ||
|
|
0d8be55c51 | ||
|
|
2330837747 | ||
|
|
b2e730fb5e | ||
|
|
29746d492e | ||
|
|
64c6cbee48 | ||
|
|
3f1cab3e7e | ||
|
|
411c6b5e9f | ||
|
|
518f99b480 | ||
|
|
79e8e063af | ||
|
|
01ecf2a75f | ||
|
|
7eec1f2efc | ||
|
|
8846a8860f | ||
|
|
f883d4d4fd | ||
|
|
f984c5fb83 | ||
|
|
72161b82ef |
40
.appveyor.yml
Normal file
40
.appveyor.yml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
---
|
||||||
|
# Disabling building for AppVeyor. We are just testing things.
|
||||||
|
build: false
|
||||||
|
clone_depth: 10
|
||||||
|
# Use the directory C:\testplugin so test directories will mostly work.
|
||||||
|
clone_folder: C:\testplugin
|
||||||
|
|
||||||
|
# Cache the vim and vader directories between builds.
|
||||||
|
cache:
|
||||||
|
- C:\vim -> .appveyor.yml
|
||||||
|
- C:\vader -> .appveyor.yml
|
||||||
|
|
||||||
|
init:
|
||||||
|
# Stop git from changing newlines
|
||||||
|
- git config --global core.autocrlf input
|
||||||
|
|
||||||
|
install:
|
||||||
|
# Download and unpack Vim
|
||||||
|
- ps: >-
|
||||||
|
if (!(Test-Path -Path C:\vim)){
|
||||||
|
Add-Type -A System.IO.Compression.FileSystem
|
||||||
|
Invoke-WebRequest ftp://ftp.vim.org/pub/vim/pc/vim80-586w32.zip `
|
||||||
|
-OutFile C:\vim.zip
|
||||||
|
[IO.Compression.ZipFile]::ExtractToDirectory('C:\vim.zip', 'C:\vim')
|
||||||
|
Invoke-WebRequest ftp://ftp.vim.org/pub/vim/pc/vim80-586rt.zip `
|
||||||
|
-OutFile C:\rt.zip
|
||||||
|
[IO.Compression.ZipFile]::ExtractToDirectory('C:\rt.zip', 'C:\vim')
|
||||||
|
}
|
||||||
|
# Clone Vader and check out the commit we want
|
||||||
|
- ps: >-
|
||||||
|
if (!(Test-Path -Path C:\vader)){
|
||||||
|
git clone https://github.com/junegunn/vader.vim C:\vader 2> $null
|
||||||
|
cd C:\vader
|
||||||
|
git checkout -qf c6243dd81c98350df4dec608fa972df98fa2a3af 2> $null
|
||||||
|
}
|
||||||
|
|
||||||
|
test_script:
|
||||||
|
- cd C:\testplugin
|
||||||
|
- 'C:\vim\vim\vim80\vim.exe -u test\vimrc "+Vader!
|
||||||
|
test/*.vader test/*/*.vader test/*/*/*.vader test/*/*/*.vader"'
|
||||||
14
.editorconfig
Normal file
14
.editorconfig
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# EditorConfig is awesome: http://EditorConfig.org
|
||||||
|
|
||||||
|
# Top-most EditorConfig file
|
||||||
|
root = true
|
||||||
|
|
||||||
|
# Match and apply these rules for all file
|
||||||
|
# types you open in your code editor
|
||||||
|
[*]
|
||||||
|
# Unix-style newlines
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
trim_trailing_whitespace = true
|
||||||
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -6,7 +6,7 @@
|
|||||||
/Makefile export-ignore
|
/Makefile export-ignore
|
||||||
/PULL_REQUEST_TEMPLATE.md export-ignore
|
/PULL_REQUEST_TEMPLATE.md export-ignore
|
||||||
/README.md export-ignore
|
/README.md export-ignore
|
||||||
/custom-checks export-ignore
|
|
||||||
/img export-ignore
|
/img export-ignore
|
||||||
/run-tests export-ignore
|
/run-tests export-ignore
|
||||||
|
/run-tests.bat export-ignore
|
||||||
/test export-ignore
|
/test export-ignore
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,6 @@
|
|||||||
/init.vim
|
/init.vim
|
||||||
/doc/tags
|
/doc/tags
|
||||||
.*
|
.*
|
||||||
|
!.editorconfig
|
||||||
*.obj
|
*.obj
|
||||||
tags
|
tags
|
||||||
|
|||||||
@@ -2,9 +2,6 @@
|
|||||||
sudo: required
|
sudo: required
|
||||||
services:
|
services:
|
||||||
- docker
|
- docker
|
||||||
branches:
|
|
||||||
only:
|
|
||||||
- master
|
|
||||||
language: python
|
language: python
|
||||||
script: |
|
script: |
|
||||||
./run-tests
|
./run-tests
|
||||||
|
|||||||
@@ -74,10 +74,10 @@ If you want to credit multiple authors, you can comma separate them.
|
|||||||
### 3.i. Adding a New Linter
|
### 3.i. Adding a New Linter
|
||||||
|
|
||||||
If you add a new linter, look for existing handlers first in the
|
If you add a new linter, look for existing handlers first in the
|
||||||
[handlers.vim](autoload/ale/handlers.vim) file. One of the handlers there may
|
[handlers](autoload/ale/handlers) directory. One of the handlers there may
|
||||||
already be able to handle your lines of output. If you find that your new
|
already be able to handle your lines of output. If you find that your new
|
||||||
linter replicates an existing error handler, consider pulling it up into the
|
linter replicates an existing error handler, consider pulling it up into the
|
||||||
[handlers.vim](autoload/ale/handlers.vim) file, and use the generic handler in
|
[handlers](autoload/ale/handlers) directory, and use the generic handler in
|
||||||
both places.
|
both places.
|
||||||
|
|
||||||
When you add a linter, make sure the language for the linter and the linter
|
When you add a linter, make sure the language for the linter and the linter
|
||||||
@@ -129,7 +129,7 @@ giving some unfair preference to any particular tool or language.
|
|||||||
|
|
||||||
The "online documentation" file used for this project lives in `doc/ale.txt`.
|
The "online documentation" file used for this project lives in `doc/ale.txt`.
|
||||||
This is the file used for generating `:help` text inside Vim itself. There are
|
This is the file used for generating `:help` text inside Vim itself. There are
|
||||||
some guidlines to follow for this file.
|
some guidelines to follow for this file.
|
||||||
|
|
||||||
1. Keep all text within a column size of 79 characters, inclusive.
|
1. Keep all text within a column size of 79 characters, inclusive.
|
||||||
2. Open a section with 79 `=` or `-` characters, for headings and subheadings.
|
2. Open a section with 79 `=` or `-` characters, for headings and subheadings.
|
||||||
@@ -160,7 +160,7 @@ to look up the default value easily by typing `:echo g:ale_...`.
|
|||||||
Should the principal author of the ALE project and all collaborators with the
|
Should the principal author of the ALE project and all collaborators with the
|
||||||
required access needed to properly administrate the project on GitHub or any
|
required access needed to properly administrate the project on GitHub or any
|
||||||
other website either perish or disappear, whether by tragic traffic accident
|
other website either perish or disappear, whether by tragic traffic accident
|
||||||
or government adduction, etc., action should be taken to ensure that the
|
or government abduction, etc., action should be taken to ensure that the
|
||||||
project continues. If no one is left to administer the project where it is
|
project continues. If no one is left to administer the project where it is
|
||||||
hosted, please fork the project and nominate someone capable to administer it.
|
hosted, please fork the project and nominate someone capable to administer it.
|
||||||
Preferably, in such an event, a single fork of the project will replace the
|
Preferably, in such an event, a single fork of the project will replace the
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
<!--
|
<!--
|
||||||
READ THIS FIRST: If you are experiencing any bug whatsoever dealing with
|
|
||||||
the output of linters, please use `let g:ale_history_log_output = 1` before
|
|
||||||
pasting output. It will capture the output of commands that are run.
|
|
||||||
|
|
||||||
For bugs, paste output from your clipboard after running :ALEInfoToClipboard
|
For bugs, paste output from your clipboard after running :ALEInfoToClipboard
|
||||||
here. If that doesn't work for some reason, try running :ALEInfo and copying
|
here. If that doesn't work for some reason, try running :ALEInfo and copying
|
||||||
the output from that here instead. If everything is broken, run around in
|
the output from that here instead. If everything is broken, run around in
|
||||||
|
|||||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2016, w0rp <devw0rp@gmail.com>
|
Copyright (c) 2016-2017, w0rp <devw0rp@gmail.com>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
<!--
|
<!--
|
||||||
When creating new pull requests, please consider the following.
|
READ THIS: Before creating a pull request, please consider the following first.
|
||||||
|
|
||||||
|
* The most important thing you can do is write tests. Code without tests
|
||||||
|
probably doesn't work, and will almost certainly stop working later on. Pull
|
||||||
|
requests without tests probably won't be accepted, although there are some
|
||||||
|
exceptions.
|
||||||
* Read the Contributing guide linked above first.
|
* Read the Contributing guide linked above first.
|
||||||
* If you are adding a new linter, remember to update the README.md file and
|
* If you are adding a new linter, remember to update the README.md file and
|
||||||
doc/ale.txt first.
|
doc/ale.txt first.
|
||||||
|
|||||||
327
README.md
327
README.md
@@ -1,4 +1,5 @@
|
|||||||
# Asynchronous Lint Engine [](https://travis-ci.org/w0rp/ale)
|
# Asynchronous Lint Engine [](https://travis-ci.org/w0rp/ale) [](https://ci.appveyor.com/project/w0rp/ale)
|
||||||
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -15,30 +16,35 @@ back to a filesystem.
|
|||||||
|
|
||||||
In other words, this plugin allows you to lint while you type.
|
In other words, this plugin allows you to lint while you type.
|
||||||
|
|
||||||
ALE also supports fixing problems with files by running commands in the
|
In addition to linting support, ALE offers some support for fixing code with
|
||||||
background with a command `ALEFix`.
|
formatting tools, and completion via Language Server Protocol servers, or
|
||||||
|
servers with similar enough protocols, like `tsserver`.
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
1. [Supported Languages and Tools](#supported-languages)
|
1. [Supported Languages and Tools](#supported-languages)
|
||||||
2. [Usage](#usage)
|
2. [Usage](#usage)
|
||||||
|
1. [Linting](#usage-linting)
|
||||||
|
2. [Fixing](#usage-fixing)
|
||||||
|
3. [Completion](#usage-completion)
|
||||||
3. [Installation](#installation)
|
3. [Installation](#installation)
|
||||||
1. [Installation with Pathogen](#installation-with-pathogen)
|
1. [Installation with Vim package management](#standard-installation)
|
||||||
2. [Installation with Vundle](#installation-with-vundle)
|
2. [Installation with Pathogen](#installation-with-pathogen)
|
||||||
3. [Manual Installation](#manual-installation)
|
3. [Installation with Vundle](#installation-with-vundle)
|
||||||
4. [Contributing](#contributing)
|
4. [Contributing](#contributing)
|
||||||
5. [FAQ](#faq)
|
5. [FAQ](#faq)
|
||||||
1. [How do I disable particular linters?](#faq-disable-linters)
|
1. [How do I disable particular linters?](#faq-disable-linters)
|
||||||
2. [How can I keep the sign gutter open?](#faq-keep-signs)
|
2. [How can I keep the sign gutter open?](#faq-keep-signs)
|
||||||
3. [How can I change the signs ALE uses?](#faq-change-signs)
|
3. [How can I change the signs ALE uses?](#faq-change-signs)
|
||||||
4. [How can I show errors or warnings in my statusline?](#faq-statusline)
|
4. [How can I show errors or warnings in my statusline?](#faq-statusline)
|
||||||
5. [How can I change the format for echo messages?](#faq-echo-format)
|
5. [How can I show errors or warnings in my lightline?](#faq-lightline)
|
||||||
6. [How can I execute some code when ALE stops linting?](#faq-autocmd)
|
6. [How can I change the format for echo messages?](#faq-echo-format)
|
||||||
7. [How can I navigate between errors quickly?](#faq-navigation)
|
7. [How can I execute some code when ALE stops linting?](#faq-autocmd)
|
||||||
8. [How can I run linters only when I save files?](#faq-lint-on-save)
|
8. [How can I navigate between errors quickly?](#faq-navigation)
|
||||||
9. [How can I use the quickfix list instead of the loclist?](#faq-quickfix)
|
9. [How can I run linters only when I save files?](#faq-lint-on-save)
|
||||||
10. [How can I check JSX files with both stylelint and eslint?](#faq-jsx-stylelint-eslint)
|
10. [How can I use the quickfix list instead of the loclist?](#faq-quickfix)
|
||||||
11. [Will this plugin eat all of my laptop battery power?](#faq-my-battery-is-sad)
|
11. [How can I check JSX files with both stylelint and eslint?](#faq-jsx-stylelint-eslint)
|
||||||
|
12. [Will this plugin eat all of my laptop battery power?](#faq-my-battery-is-sad)
|
||||||
|
|
||||||
<a name="supported-languages"></a>
|
<a name="supported-languages"></a>
|
||||||
|
|
||||||
@@ -51,86 +57,107 @@ tools will be run in combination, so they can be complementary.
|
|||||||
Keep the table rows sorted alphabetically by the language name,
|
Keep the table rows sorted alphabetically by the language name,
|
||||||
and the tools in the tools column sorted alphabetically by the tool
|
and the tools in the tools column sorted alphabetically by the tool
|
||||||
name. That seems to be the fairest way to arrange this table.
|
name. That seems to be the fairest way to arrange this table.
|
||||||
|
|
||||||
|
Remember to also update doc/ale.txt, which has a similar list with different
|
||||||
|
formatting.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
**Notes:**
|
||||||
|
|
||||||
|
* *^ No linters for text or Vim help filetypes are enabled by default.*
|
||||||
|
* *!! These linters check only files on disk. See `:help ale-lint-file-linters`*
|
||||||
|
|
||||||
| Language | Tools |
|
| Language | Tools |
|
||||||
| -------- | ----- |
|
| -------- | ----- |
|
||||||
| ASM | [gcc](https://gcc.gnu.org) |
|
| ASM | [gcc](https://gcc.gnu.org) |
|
||||||
| Ansible | [ansible-lint](https://github.com/willthames/ansible-lint) |
|
| Ansible | [ansible-lint](https://github.com/willthames/ansible-lint) |
|
||||||
| AsciiDoc | [proselint](http://proselint.com/)|
|
| AsciiDoc | [proselint](http://proselint.com/) |
|
||||||
| Awk | [gawk](https://www.gnu.org/software/gawk/)|
|
| Awk | [gawk](https://www.gnu.org/software/gawk/)|
|
||||||
| Bash | [-n flag](https://www.gnu.org/software/bash/manual/bash.html#index-set), [shellcheck](https://www.shellcheck.net/) |
|
| Bash | shell [-n flag](https://www.gnu.org/software/bash/manual/bash.html#index-set), [shellcheck](https://www.shellcheck.net/) |
|
||||||
| Bourne Shell | [-n flag](http://linux.die.net/man/1/sh), [shellcheck](https://www.shellcheck.net/) |
|
| Bourne Shell | shell [-n flag](http://linux.die.net/man/1/sh), [shellcheck](https://www.shellcheck.net/) |
|
||||||
| C | [cppcheck](http://cppcheck.sourceforge.net), [gcc](https://gcc.gnu.org/), [clang](http://clang.llvm.org/)|
|
| C | [cppcheck](http://cppcheck.sourceforge.net), [cpplint](https://github.com/google/styleguide/tree/gh-pages/cpplint), [gcc](https://gcc.gnu.org/), [clang](http://clang.llvm.org/), [clangtidy](http://clang.llvm.org/extra/clang-tidy/) !!, [clang-format](https://clang.llvm.org/docs/ClangFormat.html)|
|
||||||
| C++ (filetype cpp) | [clang](http://clang.llvm.org/), [clangcheck](http://clang.llvm.org/docs/ClangCheck.html), [clangtidy](http://clang.llvm.org/extra/clang-tidy/), [cppcheck](http://cppcheck.sourceforge.net), [cpplint](https://github.com/google/styleguide/tree/gh-pages/cpplint), [gcc](https://gcc.gnu.org/)|
|
| C++ (filetype cpp) | [clang](http://clang.llvm.org/), [clangcheck](http://clang.llvm.org/docs/ClangCheck.html) !!, [clangtidy](http://clang.llvm.org/extra/clang-tidy/) !!, [cppcheck](http://cppcheck.sourceforge.net), [cpplint](https://github.com/google/styleguide/tree/gh-pages/cpplint) !!, [gcc](https://gcc.gnu.org/), [clang-format](https://clang.llvm.org/docs/ClangFormat.html)|
|
||||||
| C# | [mcs](http://www.mono-project.com/docs/about-mono/languages/csharp/) |
|
| CUDA | [nvcc](http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html) |
|
||||||
|
| C# | [mcs](http://www.mono-project.com/docs/about-mono/languages/csharp/) see:`help ale-cs-mcs` for details, [mcsc](http://www.mono-project.com/docs/about-mono/languages/csharp/) !! see:`help ale-cs-mcsc` for details and configuration|
|
||||||
| Chef | [foodcritic](http://www.foodcritic.io/) |
|
| Chef | [foodcritic](http://www.foodcritic.io/) |
|
||||||
| CMake | [cmakelint](https://github.com/richq/cmake-lint) |
|
| CMake | [cmakelint](https://github.com/richq/cmake-lint) |
|
||||||
| CoffeeScript | [coffee](http://coffeescript.org/), [coffeelint](https://www.npmjs.com/package/coffeelint) |
|
| CoffeeScript | [coffee](http://coffeescript.org/), [coffeelint](https://www.npmjs.com/package/coffeelint) |
|
||||||
| Crystal | [crystal](https://crystal-lang.org/) |
|
| Crystal | [crystal](https://crystal-lang.org/) !! |
|
||||||
| CSS | [csslint](http://csslint.net/), [stylelint](https://github.com/stylelint/stylelint) |
|
| CSS | [csslint](http://csslint.net/), [stylelint](https://github.com/stylelint/stylelint), [prettier](https://github.com/prettier/prettier) |
|
||||||
| Cython (pyrex filetype) | [cython](http://cython.org/) |
|
| Cython (pyrex filetype) | [cython](http://cython.org/) |
|
||||||
| D | [dmd](https://dlang.org/dmd-linux.html) |
|
| D | [dmd](https://dlang.org/dmd-linux.html) |
|
||||||
|
| Dart | [dartanalyzer](https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_cli) |
|
||||||
| Dockerfile | [hadolint](https://github.com/lukasmartinelli/hadolint) |
|
| Dockerfile | [hadolint](https://github.com/lukasmartinelli/hadolint) |
|
||||||
| Elixir | [credo](https://github.com/rrrene/credo), [dogma](https://github.com/lpil/dogma) |
|
| Elixir | [credo](https://github.com/rrrene/credo), [dogma](https://github.com/lpil/dogma) !! |
|
||||||
| Elm | [elm-make](https://github.com/elm-lang/elm-make) |
|
| Elm | [elm-format](https://github.com/avh4/elm-format), [elm-make](https://github.com/elm-lang/elm-make) |
|
||||||
| Erb | [erb](https://github.com/jeremyevans/erubi) |
|
| Erb | [erb](https://github.com/jeremyevans/erubi), [erubis](https://github.com/kwatch/erubis) |
|
||||||
| Erlang | [erlc](http://erlang.org/doc/man/erlc.html) |
|
| Erlang | [erlc](http://erlang.org/doc/man/erlc.html), [SyntaxErl](https://github.com/ten0s/syntaxerl) |
|
||||||
| Fortran | [gcc](https://gcc.gnu.org/) |
|
| Fortran | [gcc](https://gcc.gnu.org/) |
|
||||||
| FusionScript | [fusion-lint](https://github.com/RyanSquared/fusionscript) |
|
| FusionScript | [fusion-lint](https://github.com/RyanSquared/fusionscript) |
|
||||||
| Go | [gofmt -e](https://golang.org/cmd/gofmt/), [go vet](https://golang.org/cmd/vet/), [golint](https://godoc.org/github.com/golang/lint), [gometalinter](https://github.com/alecthomas/gometalinter), [go build](https://golang.org/cmd/go/), [gosimple](https://github.com/dominikh/go-tools/tree/master/cmd/gosimple), [staticcheck](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck) |
|
| GLSL | [glslang](https://github.com/KhronosGroup/glslang) |
|
||||||
| Haml | [haml-lint](https://github.com/brigade/haml-lint)
|
| Go | [gofmt](https://golang.org/cmd/gofmt/), [go vet](https://golang.org/cmd/vet/), [golint](https://godoc.org/github.com/golang/lint), [gometalinter](https://github.com/alecthomas/gometalinter) !!, [go build](https://golang.org/cmd/go/) !!, [gosimple](https://github.com/dominikh/go-tools/tree/master/cmd/gosimple) !!, [staticcheck](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck) !! |
|
||||||
|
| GraphQL | [gqlint](https://github.com/happylinks/gqlint) |
|
||||||
|
| Haml | [haml-lint](https://github.com/brigade/haml-lint) |
|
||||||
| Handlebars | [ember-template-lint](https://github.com/rwjblue/ember-template-lint) |
|
| Handlebars | [ember-template-lint](https://github.com/rwjblue/ember-template-lint) |
|
||||||
| Haskell | [ghc](https://www.haskell.org/ghc/), [ghc-mod](https://github.com/DanielG/ghc-mod), [hlint](https://hackage.haskell.org/package/hlint), [hdevtools](https://hackage.haskell.org/package/hdevtools) |
|
| Haskell | [ghc](https://www.haskell.org/ghc/), [stack-ghc](https://haskellstack.org/), [stack-build](https://haskellstack.org/) !!, [ghc-mod](https://github.com/DanielG/ghc-mod), [stack-ghc-mod](https://github.com/DanielG/ghc-mod), [hlint](https://hackage.haskell.org/package/hlint), [hdevtools](https://hackage.haskell.org/package/hdevtools) |
|
||||||
| HTML | [HTMLHint](http://htmlhint.com/), [proselint](http://proselint.com/), [tidy](http://www.html-tidy.org/) |
|
| HTML | [HTMLHint](http://htmlhint.com/), [proselint](http://proselint.com/), [tidy](http://www.html-tidy.org/) |
|
||||||
|
| Idris | [idris](http://www.idris-lang.org/) |
|
||||||
| Java | [checkstyle](http://checkstyle.sourceforge.net), [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html) |
|
| Java | [checkstyle](http://checkstyle.sourceforge.net), [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html) |
|
||||||
| JavaScript | [eslint](http://eslint.org/), [jscs](http://jscs.info/), [jshint](http://jshint.com/), [flow](https://flowtype.org/), [standard](http://standardjs.com/), [prettier](https://github.com/prettier/prettier) (and `prettier-eslint`), [xo](https://github.com/sindresorhus/xo)
|
| JavaScript | [eslint](http://eslint.org/), [jscs](http://jscs.info/), [jshint](http://jshint.com/), [flow](https://flowtype.org/), [prettier](https://github.com/prettier/prettier), prettier-eslint >= 4.2.0, prettier-standard, [standard](http://standardjs.com/), [xo](https://github.com/sindresorhus/xo)
|
||||||
| JSON | [jsonlint](http://zaa.ch/jsonlint/) |
|
| JSON | [jsonlint](http://zaa.ch/jsonlint/), [prettier](https://github.com/prettier/prettier) |
|
||||||
| Kotlin | [kotlinc](https://kotlinlang.org), [ktlint](https://ktlint.github.io) see `:help ale-integration-kotlin` for configuration instructions
|
| Kotlin | [kotlinc](https://kotlinlang.org) !!, [ktlint](https://ktlint.github.io) !! see `:help ale-integration-kotlin` for configuration instructions |
|
||||||
| LaTeX | [chktex](http://www.nongnu.org/chktex/), [lacheck](https://www.ctan.org/pkg/lacheck), [proselint](http://proselint.com/) |
|
| LaTeX | [chktex](http://www.nongnu.org/chktex/), [lacheck](https://www.ctan.org/pkg/lacheck), [proselint](http://proselint.com/) |
|
||||||
|
| LLVM | [llc](https://llvm.org/docs/CommandGuide/llc.html) |
|
||||||
| Lua | [luacheck](https://github.com/mpeterv/luacheck) |
|
| Lua | [luacheck](https://github.com/mpeterv/luacheck) |
|
||||||
| Markdown | [mdl](https://github.com/mivok/markdownlint), [proselint](http://proselint.com/), [vale](https://github.com/ValeLint/vale) |
|
| Markdown | [mdl](https://github.com/mivok/markdownlint), [proselint](http://proselint.com/), [vale](https://github.com/ValeLint/vale), [remark-lint](https://github.com/wooorm/remark-lint) !! |
|
||||||
| MATLAB | [mlint](https://www.mathworks.com/help/matlab/ref/mlint.html) |
|
| MATLAB | [mlint](https://www.mathworks.com/help/matlab/ref/mlint.html) |
|
||||||
| Nim | [nim](https://nim-lang.org/docs/nimc.html) |
|
| Nim | [nim check](https://nim-lang.org/docs/nimc.html) !! |
|
||||||
| nix | [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate) |
|
| nix | [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate) |
|
||||||
| nroff | [proselint](http://proselint.com/)|
|
| nroff | [proselint](http://proselint.com/)|
|
||||||
| Objective-C | [clang](http://clang.llvm.org/) |
|
| Objective-C | [clang](http://clang.llvm.org/) |
|
||||||
| Objective-C++ | [clang](http://clang.llvm.org/) |
|
| Objective-C++ | [clang](http://clang.llvm.org/) |
|
||||||
| OCaml | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-integration-ocaml-merlin` for configuration instructions
|
| OCaml | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-ocaml-merlin` for configuration instructions |
|
||||||
| Perl | [perl -c](https://perl.org/), [perl-critic](https://metacpan.org/pod/Perl::Critic) |
|
| Perl | [perl -c](https://perl.org/), [perl-critic](https://metacpan.org/pod/Perl::Critic) |
|
||||||
| PHP | [hack](http://hacklang.org/), [php -l](https://secure.php.net/), [phpcs](https://github.com/squizlabs/PHP_CodeSniffer), [phpmd](https://phpmd.org) |
|
| PHP | [hack](http://hacklang.org/), [langserver](https://github.com/felixfbecker/php-language-server), [php -l](https://secure.php.net/), [phpcs](https://github.com/squizlabs/PHP_CodeSniffer), [phpmd](https://phpmd.org), [phpstan](https://github.com/phpstan/phpstan), [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer) |
|
||||||
| Pod | [proselint](http://proselint.com/)|
|
| Pod | [proselint](http://proselint.com/)|
|
||||||
| Pug | [pug-lint](https://github.com/pugjs/pug-lint) |
|
| Pug | [pug-lint](https://github.com/pugjs/pug-lint) |
|
||||||
| Puppet | [puppet](https://puppet.com), [puppet-lint](https://puppet-lint.com) |
|
| Puppet | [puppet](https://puppet.com), [puppet-lint](https://puppet-lint.com) |
|
||||||
| Python | [autopep8](https://github.com/hhatto/autopep8), [flake8](http://flake8.pycqa.org/en/latest/), [isort](https://github.com/timothycrosley/isort), [mypy](http://mypy-lang.org/), [pylint](https://www.pylint.org/), [yapf](https://github.com/google/yapf) |
|
| Python | [autopep8](https://github.com/hhatto/autopep8), [flake8](http://flake8.pycqa.org/en/latest/), [isort](https://github.com/timothycrosley/isort), [mypy](http://mypy-lang.org/), [pycodestyle](https://github.com/PyCQA/pycodestyle), [pylint](https://www.pylint.org/) !!, [yapf](https://github.com/google/yapf) |
|
||||||
| ReasonML | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-integration-reason-merlin` for configuration instructions
|
| R | [lintr](https://github.com/jimhester/lintr) |
|
||||||
| reStructuredText | [proselint](http://proselint.com/)|
|
| ReasonML | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-integration-reason-merlin` for configuration instructions |
|
||||||
|
| reStructuredText | [proselint](http://proselint.com/) |
|
||||||
| RPM spec | [rpmlint](https://github.com/rpm-software-management/rpmlint) (disabled by default; see `:help ale-integration-spec`) |
|
| RPM spec | [rpmlint](https://github.com/rpm-software-management/rpmlint) (disabled by default; see `:help ale-integration-spec`) |
|
||||||
| Ruby | [brakeman](http://brakemanscanner.org/), [reek](https://github.com/troessner/reek), [rubocop](https://github.com/bbatsov/rubocop), [ruby](https://www.ruby-lang.org) |
|
| Ruby | [brakeman](http://brakemanscanner.org/) !!, [rails_best_practices](https://github.com/flyerhzm/rails_best_practices) !!, [reek](https://github.com/troessner/reek), [rubocop](https://github.com/bbatsov/rubocop), [ruby](https://www.ruby-lang.org) |
|
||||||
| Rust | [rustc](https://www.rust-lang.org/), cargo (see `:help ale-integration-rust` for configuration instructions) |
|
| Rust | cargo !! (see `:help ale-integration-rust` for configuration instructions), [rls](https://github.com/rust-lang-nursery/rls), [rustc](https://www.rust-lang.org/) |
|
||||||
| SASS | [sass-lint](https://www.npmjs.com/package/sass-lint), [stylelint](https://github.com/stylelint/stylelint) |
|
| SASS | [sass-lint](https://www.npmjs.com/package/sass-lint), [stylelint](https://github.com/stylelint/stylelint) |
|
||||||
| SCSS | [sass-lint](https://www.npmjs.com/package/sass-lint), [scss-lint](https://github.com/brigade/scss-lint), [stylelint](https://github.com/stylelint/stylelint) |
|
| SCSS | [sass-lint](https://www.npmjs.com/package/sass-lint), [scss-lint](https://github.com/brigade/scss-lint), [stylelint](https://github.com/stylelint/stylelint), [prettier](https://github.com/prettier/prettier) |
|
||||||
| Scala | [scalac](http://scala-lang.org) |
|
| Scala | [scalac](http://scala-lang.org), [scalastyle](http://www.scalastyle.org) |
|
||||||
| Slim | [slim-lint](https://github.com/sds/slim-lint)
|
| Slim | [slim-lint](https://github.com/sds/slim-lint) |
|
||||||
| SML | [smlnj](http://www.smlnj.org/) |
|
| SML | [smlnj](http://www.smlnj.org/) |
|
||||||
|
| Solidity | [solium](https://github.com/duaraghav8/Solium) |
|
||||||
|
| Stylus | [stylelint](https://github.com/stylelint/stylelint) |
|
||||||
| SQL | [sqlint](https://github.com/purcell/sqlint) |
|
| SQL | [sqlint](https://github.com/purcell/sqlint) |
|
||||||
| Swift | [swiftlint](https://swift.org/) |
|
| Swift | [swiftlint](https://github.com/realm/SwiftLint), [swiftformat](https://github.com/nicklockwood/SwiftFormat) |
|
||||||
|
| Tcl | [nagelfar](http://nagelfar.sourceforge.net) !! |
|
||||||
| Texinfo | [proselint](http://proselint.com/)|
|
| Texinfo | [proselint](http://proselint.com/)|
|
||||||
| Text^ | [proselint](http://proselint.com/), [vale](https://github.com/ValeLint/vale) |
|
| Text^ | [proselint](http://proselint.com/), [vale](https://github.com/ValeLint/vale) |
|
||||||
| TypeScript | [eslint](http://eslint.org/), [tslint](https://github.com/palantir/tslint), tsserver, typecheck |
|
| Thrift | [thrift](http://thrift.apache.org/) |
|
||||||
|
| TypeScript | [eslint](http://eslint.org/), [tslint](https://github.com/palantir/tslint), tsserver, typecheck, [prettier](https://github.com/prettier/prettier) |
|
||||||
| Verilog | [iverilog](https://github.com/steveicarus/iverilog), [verilator](http://www.veripool.org/projects/verilator/wiki/Intro) |
|
| Verilog | [iverilog](https://github.com/steveicarus/iverilog), [verilator](http://www.veripool.org/projects/verilator/wiki/Intro) |
|
||||||
| Vim | [vint](https://github.com/Kuniwak/vint) |
|
| Vim | [vint](https://github.com/Kuniwak/vint) |
|
||||||
| Vim help^ | [proselint](http://proselint.com/)|
|
| Vim help^ | [proselint](http://proselint.com/)|
|
||||||
| XHTML | [proselint](http://proselint.com/)|
|
| XHTML | [proselint](http://proselint.com/)|
|
||||||
| XML | [xmllint](http://xmlsoft.org/xmllint.html/)|
|
| XML | [xmllint](http://xmlsoft.org/xmllint.html)|
|
||||||
| YAML | [yamllint](https://yamllint.readthedocs.io/) |
|
| YAML | [swaglint](https://github.com/byCedric/swaglint), [yamllint](https://yamllint.readthedocs.io/) |
|
||||||
|
|
||||||
* *^ No linters for text or Vim help filetypes are enabled by default.*
|
|
||||||
|
|
||||||
<a name="usage"></a>
|
<a name="usage"></a>
|
||||||
|
|
||||||
## 2. Usage
|
## 2. Usage
|
||||||
|
|
||||||
|
<a name="usage-linting"></a>
|
||||||
|
|
||||||
|
### 2.i Linting
|
||||||
|
|
||||||
Once this plugin is installed, while editing your files in supported
|
Once this plugin is installed, while editing your files in supported
|
||||||
languages and tools which have been correctly installed,
|
languages and tools which have been correctly installed,
|
||||||
this plugin will send the contents of your text buffers to a variety of
|
this plugin will send the contents of your text buffers to a variety of
|
||||||
@@ -143,8 +170,46 @@ documented in [the Vim help file](doc/ale.txt). For more information on the
|
|||||||
options ALE offers, consult `:help ale-options` for global options and `:help
|
options ALE offers, consult `:help ale-options` for global options and `:help
|
||||||
ale-linter-options` for options specified to particular linters.
|
ale-linter-options` for options specified to particular linters.
|
||||||
|
|
||||||
|
<a name="usage-fixing"></a>
|
||||||
|
|
||||||
|
### 2.ii Fixing
|
||||||
|
|
||||||
ALE can fix files with the `ALEFix` command. Functions need to be configured
|
ALE can fix files with the `ALEFix` command. Functions need to be configured
|
||||||
for different filetypes with the `g:ale_fixers` variable. See `:help ale-fix`.
|
for different filetypes with the `g:ale_fixers` variable. For example, the
|
||||||
|
following code can be used to fix JavaScript code with ESLint:
|
||||||
|
|
||||||
|
```vim
|
||||||
|
" Put this in vimrc or a plugin file of your own.
|
||||||
|
" After this is configured, :ALEFix will try and fix your JS code with ESLint.
|
||||||
|
let g:ale_fixers = {
|
||||||
|
\ 'javascript': ['eslint'],
|
||||||
|
\}
|
||||||
|
|
||||||
|
" Set this setting in vimrc if you want to fix files automatically on save.
|
||||||
|
" This is off by default.
|
||||||
|
let g:ale_fix_on_save = 1
|
||||||
|
```
|
||||||
|
|
||||||
|
The `:ALEFixSuggest` command will suggest some supported tools for fixing code,
|
||||||
|
but fixers can be also implemented with functions, including lambda functions
|
||||||
|
too. See `:help ale-fix` for detailed information.
|
||||||
|
|
||||||
|
<a name="usage-completion"></a>
|
||||||
|
|
||||||
|
### 2.iii Completion
|
||||||
|
|
||||||
|
ALE offers some support for completion via hijacking of omnicompletion while you
|
||||||
|
type. All of ALE's completion information must come from Language Server
|
||||||
|
Protocol linters, or similar protocols. At the moment, completion is only
|
||||||
|
supported for TypeScript code with `tsserver`, when `tsserver` is enabled. You
|
||||||
|
can enable completion like so:
|
||||||
|
|
||||||
|
```vim
|
||||||
|
" Enable completion where available.
|
||||||
|
let g:ale_completion_enabled = 1
|
||||||
|
```
|
||||||
|
|
||||||
|
See `:help ale-completion` for more information.
|
||||||
|
|
||||||
<a name="installation"></a>
|
<a name="installation"></a>
|
||||||
|
|
||||||
@@ -152,13 +217,59 @@ for different filetypes with the `g:ale_fixers` variable. See `:help ale-fix`.
|
|||||||
|
|
||||||
To install this plugin, you should use one of the following methods.
|
To install this plugin, you should use one of the following methods.
|
||||||
For Windows users, replace usage of the Unix `~/.vim` directory with
|
For Windows users, replace usage of the Unix `~/.vim` directory with
|
||||||
`%USERPROFILE%\_vim`, or another directory if you have configured
|
`%USERPROFILE%\vimfiles`, or another directory if you have configured
|
||||||
Vim differently. On Windows, your `~/.vimrc` file will be similarly
|
Vim differently. On Windows, your `~/.vimrc` file will be similarly
|
||||||
stored in `%USERPROFILE%\_vimrc`.
|
stored in `%USERPROFILE%\_vimrc`.
|
||||||
|
|
||||||
|
<a name="standard-installation"></a>
|
||||||
|
|
||||||
|
### 3.i. Installation with Vim package management
|
||||||
|
|
||||||
|
In Vim 8 and NeoVim, you can install plugins easily without needing to use
|
||||||
|
any other tools. Simply clone the plugin into your `pack` directory.
|
||||||
|
|
||||||
|
#### Vim 8 on Unix
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir -p ~/.vim/pack/git-plugins/start
|
||||||
|
git clone https://github.com/w0rp/ale.git ~/.vim/pack/git-plugins/start/ale
|
||||||
|
```
|
||||||
|
|
||||||
|
#### NeoVim on Unix
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir -p ~/.local/share/nvim/site/pack/git-plugins/start
|
||||||
|
git clone https://github.com/w0rp/ale.git ~/.local/share/nvim/site/pack/git-plugins/start/ale
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Vim 8 on Windows
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run these commands in the "Git for Windows" Bash terminal
|
||||||
|
mkdir -p ~/vimfiles/pack/git-plugins/start
|
||||||
|
git clone https://github.com/w0rp/ale.git ~/vimfiles/pack/git-plugins/start/ale
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Generating Vim help files
|
||||||
|
|
||||||
|
You can add the following line to your vimrc files to generate documentation
|
||||||
|
tags automatically, if you don't have something similar already, so you can use
|
||||||
|
the `:help` command to consult ALE's online documentation:
|
||||||
|
|
||||||
|
```vim
|
||||||
|
" Put these lines at the very end of your vimrc file.
|
||||||
|
|
||||||
|
" Load all plugins now.
|
||||||
|
" Plugins need to be added to runtimepath before helptags can be generated.
|
||||||
|
packloadall
|
||||||
|
" Load all of the helptags now, after plugins have been loaded.
|
||||||
|
" All messages and errors will be ignored.
|
||||||
|
silent! helptags ALL
|
||||||
|
```
|
||||||
|
|
||||||
<a name="installation-with-pathogen"></a>
|
<a name="installation-with-pathogen"></a>
|
||||||
|
|
||||||
### 3.i. Installation with Pathogen
|
### 3.ii. Installation with Pathogen
|
||||||
|
|
||||||
To install this module with [Pathogen](https://github.com/tpope/vim-pathogen),
|
To install this module with [Pathogen](https://github.com/tpope/vim-pathogen),
|
||||||
you should clone this repository to your bundle directory, and ensure
|
you should clone this repository to your bundle directory, and ensure
|
||||||
@@ -172,7 +283,7 @@ git clone https://github.com/w0rp/ale.git
|
|||||||
|
|
||||||
<a name="installation-with-vundle"></a>
|
<a name="installation-with-vundle"></a>
|
||||||
|
|
||||||
### 3.ii. Installation with Vundle
|
### 3.iii. Installation with Vundle
|
||||||
|
|
||||||
You can install this plugin using [Vundle](https://github.com/VundleVim/Vundle.vim)
|
You can install this plugin using [Vundle](https://github.com/VundleVim/Vundle.vim)
|
||||||
by using the path on GitHub for this repository.
|
by using the path on GitHub for this repository.
|
||||||
@@ -183,41 +294,6 @@ Plugin 'w0rp/ale'
|
|||||||
|
|
||||||
See the Vundle documentation for more information.
|
See the Vundle documentation for more information.
|
||||||
|
|
||||||
<a name="manual-installation"></a>
|
|
||||||
|
|
||||||
### 3.iii. Manual Installation
|
|
||||||
|
|
||||||
For installation without a package manager, you can clone this git repository
|
|
||||||
into a bundle directory as with pathogen, and add the repository to your
|
|
||||||
runtime path yourself. First clone the repository.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd ~/.vim/bundle
|
|
||||||
git clone https://github.com/w0rp/ale.git
|
|
||||||
```
|
|
||||||
|
|
||||||
Then, modify your `~/.vimrc` file to add this plugin to your runtime path.
|
|
||||||
|
|
||||||
```vim
|
|
||||||
set nocompatible
|
|
||||||
filetype off
|
|
||||||
|
|
||||||
let &runtimepath.=',~/.vim/bundle/ale'
|
|
||||||
|
|
||||||
filetype plugin on
|
|
||||||
```
|
|
||||||
|
|
||||||
You can add the following line to generate documentation tags automatically,
|
|
||||||
if you don't have something similar already, so you can use the `:help` command
|
|
||||||
to consult ALE's online documentation:
|
|
||||||
|
|
||||||
```vim
|
|
||||||
silent! helptags ALL
|
|
||||||
```
|
|
||||||
|
|
||||||
Because the author of this plugin is a weird nerd, this is his preferred
|
|
||||||
installation method.
|
|
||||||
|
|
||||||
<a name="contributing"></a>
|
<a name="contributing"></a>
|
||||||
|
|
||||||
## 4. Contributing
|
## 4. Contributing
|
||||||
@@ -334,9 +410,70 @@ set statusline=%{LinterStatus()}
|
|||||||
|
|
||||||
See `:help ale#statusline#Count()` for more information.
|
See `:help ale#statusline#Count()` for more information.
|
||||||
|
|
||||||
|
<a name="faq-lightline"></a>
|
||||||
|
|
||||||
|
### 5.v. How can I show errors or warnings in my lightline?
|
||||||
|
|
||||||
|
[lightline](https://github.com/itchyny/lightline.vim) does not have built-in
|
||||||
|
support for ALE, nevertheless it's easy to do it yourself:
|
||||||
|
|
||||||
|
```vim
|
||||||
|
" This is regular lightline configuration, we just added
|
||||||
|
" 'linter_warnings', 'linter_errors' and 'linter_ok' to
|
||||||
|
" the active right panel. Feel free to move it anywhere.
|
||||||
|
" `component_expand' and `component_type' are required.
|
||||||
|
"
|
||||||
|
" For more info on how this works, see lightline documentation.
|
||||||
|
let g:lightline = {
|
||||||
|
\ 'active': {
|
||||||
|
\ 'right': [ [ 'lineinfo' ],
|
||||||
|
\ [ 'percent' ],
|
||||||
|
\ [ 'linter_warnings', 'linter_errors', 'linter_ok' ],
|
||||||
|
\ [ 'fileformat', 'fileencoding', 'filetype' ] ]
|
||||||
|
\ },
|
||||||
|
\ 'component_expand': {
|
||||||
|
\ 'linter_warnings': 'LightlineLinterWarnings',
|
||||||
|
\ 'linter_errors': 'LightlineLinterErrors',
|
||||||
|
\ 'linter_ok': 'LightlineLinterOK'
|
||||||
|
\ },
|
||||||
|
\ 'component_type': {
|
||||||
|
\ 'linter_warnings': 'warning',
|
||||||
|
\ 'linter_errors': 'error',
|
||||||
|
\ 'linter_ok': 'ok'
|
||||||
|
\ },
|
||||||
|
\ }
|
||||||
|
|
||||||
|
autocmd User ALELint call lightline#update()
|
||||||
|
|
||||||
|
" ale + lightline
|
||||||
|
function! LightlineLinterWarnings() abort
|
||||||
|
let l:counts = ale#statusline#Count(bufnr(''))
|
||||||
|
let l:all_errors = l:counts.error + l:counts.style_error
|
||||||
|
let l:all_non_errors = l:counts.total - l:all_errors
|
||||||
|
return l:counts.total == 0 ? '' : printf('%d --', all_non_errors)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! LightlineLinterErrors() abort
|
||||||
|
let l:counts = ale#statusline#Count(bufnr(''))
|
||||||
|
let l:all_errors = l:counts.error + l:counts.style_error
|
||||||
|
let l:all_non_errors = l:counts.total - l:all_errors
|
||||||
|
return l:counts.total == 0 ? '' : printf('%d >>', all_errors)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! LightlineLinterOK() abort
|
||||||
|
let l:counts = ale#statusline#Count(bufnr(''))
|
||||||
|
let l:all_errors = l:counts.error + l:counts.style_error
|
||||||
|
let l:all_non_errors = l:counts.total - l:all_errors
|
||||||
|
return l:counts.total == 0 ? '✓' : ''
|
||||||
|
endfunction
|
||||||
|
```
|
||||||
|
|
||||||
|
See `:help ale#statusline#Count()` and [lightline documentation](https://github.com/itchyny/lightline.vim#advanced-configuration)
|
||||||
|
for more information.
|
||||||
|
|
||||||
<a name="faq-echo-format"></a>
|
<a name="faq-echo-format"></a>
|
||||||
|
|
||||||
### 5.v. How can I change the format for echo messages?
|
### 5.vi. How can I change the format for echo messages?
|
||||||
|
|
||||||
There are 3 global options that allow customizing the echoed message.
|
There are 3 global options that allow customizing the echoed message.
|
||||||
|
|
||||||
@@ -361,7 +498,7 @@ Will give you:
|
|||||||
|
|
||||||
<a name="faq-autocmd"></a>
|
<a name="faq-autocmd"></a>
|
||||||
|
|
||||||
### 5.vi. How can I execute some code when ALE stops linting?
|
### 5.vii. How can I execute some code when ALE stops linting?
|
||||||
|
|
||||||
ALE runs its own [autocmd](http://vimdoc.sourceforge.net/htmldoc/autocmd.html)
|
ALE runs its own [autocmd](http://vimdoc.sourceforge.net/htmldoc/autocmd.html)
|
||||||
event whenever has a linter has been successfully executed and processed. This
|
event whenever has a linter has been successfully executed and processed. This
|
||||||
@@ -376,7 +513,7 @@ augroup END
|
|||||||
|
|
||||||
<a name="faq-navigation"></a>
|
<a name="faq-navigation"></a>
|
||||||
|
|
||||||
### 5.vii. How can I navigate between errors quickly?
|
### 5.viii. How can I navigate between errors quickly?
|
||||||
|
|
||||||
ALE offers some commands with `<Plug>` keybinds for moving between warnings and
|
ALE offers some commands with `<Plug>` keybinds for moving between warnings and
|
||||||
errors quickly. You can map the keys Ctrl+j and Ctrl+k to moving between errors
|
errors quickly. You can map the keys Ctrl+j and Ctrl+k to moving between errors
|
||||||
@@ -392,7 +529,7 @@ For more information, consult the online documentation with
|
|||||||
|
|
||||||
<a name="faq-lint-on-save"></a>
|
<a name="faq-lint-on-save"></a>
|
||||||
|
|
||||||
### 5.viii. How can I run linters only when I save files?
|
### 5.ix. How can I run linters only when I save files?
|
||||||
|
|
||||||
ALE offers an option `g:ale_lint_on_save` for enabling running the linters
|
ALE offers an option `g:ale_lint_on_save` for enabling running the linters
|
||||||
when files are saved. This option is enabled by default. If you only
|
when files are saved. This option is enabled by default. If you only
|
||||||
@@ -412,7 +549,7 @@ files, you can set `g:ale_lint_on_save` to `0`.
|
|||||||
|
|
||||||
<a name="faq-quickfix"></a>
|
<a name="faq-quickfix"></a>
|
||||||
|
|
||||||
### 5.ix. How can I use the quickfix list instead of the loclist?
|
### 5.x. How can I use the quickfix list instead of the loclist?
|
||||||
|
|
||||||
The quickfix list can be enabled by turning the `g:ale_set_quickfix`
|
The quickfix list can be enabled by turning the `g:ale_set_quickfix`
|
||||||
option on. If you wish to also disable the loclist, you can disable
|
option on. If you wish to also disable the loclist, you can disable
|
||||||
@@ -439,7 +576,7 @@ let g:ale_keep_list_window_open = 1
|
|||||||
|
|
||||||
<a name="faq-jsx-stylelint-eslint"></a>
|
<a name="faq-jsx-stylelint-eslint"></a>
|
||||||
|
|
||||||
### 5.x. How can I check JSX files with both stylelint and eslint?
|
### 5.xi. How can I check JSX files with both stylelint and eslint?
|
||||||
|
|
||||||
If you configure ALE options correctly in your vimrc file, and install
|
If you configure ALE options correctly in your vimrc file, and install
|
||||||
the right tools, you can check JSX files with stylelint and eslint.
|
the right tools, you can check JSX files with stylelint and eslint.
|
||||||
@@ -472,7 +609,7 @@ no linter will be run twice for the same file.
|
|||||||
|
|
||||||
<a name="faq-my-battery-is-sad"></a>
|
<a name="faq-my-battery-is-sad"></a>
|
||||||
|
|
||||||
### 5.xi. Will this plugin eat all of my laptop battery power?
|
### 5.xii. Will this plugin eat all of my laptop battery power?
|
||||||
|
|
||||||
ALE takes advantage of the power of various tools to check your code. This of
|
ALE takes advantage of the power of various tools to check your code. This of
|
||||||
course means that CPU time will be used to continuously check your code. If you
|
course means that CPU time will be used to continuously check your code. If you
|
||||||
|
|||||||
@@ -15,26 +15,26 @@ function! ale_linters#ansible#ansible_lint#Handle(buffer, lines) abort
|
|||||||
" Matches patterns line the following:
|
" Matches patterns line the following:
|
||||||
"
|
"
|
||||||
" test.yml:35: [EANSIBLE0002] Trailing whitespace
|
" test.yml:35: [EANSIBLE0002] Trailing whitespace
|
||||||
let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):?(\d+)?: \[?([[:alnum:]]+)\]? (.*)$'
|
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?: \[?([[:alnum:]]+)\]? (.*)$'
|
||||||
let l:output = []
|
let l:output = []
|
||||||
|
|
||||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
let l:code = l:match[3]
|
let l:code = l:match[4]
|
||||||
|
|
||||||
if (l:code ==# 'EANSIBLE002')
|
if l:code is# 'EANSIBLE002'
|
||||||
\ && !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
|
\&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
|
||||||
" Skip warnings for trailing whitespace if the option is off.
|
" Skip warnings for trailing whitespace if the option is off.
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let l:item = {
|
if ale#path#IsBufferPath(a:buffer, l:match[1])
|
||||||
\ 'lnum': l:match[1] + 0,
|
call add(l:output, {
|
||||||
\ 'col': l:match[2] + 0,
|
\ 'lnum': l:match[2] + 0,
|
||||||
\ 'text': l:code . ': ' . l:match[4],
|
\ 'col': l:match[3] + 0,
|
||||||
\ 'type': l:code[:0] ==# 'E' ? 'E' : 'W',
|
\ 'text': l:code . ': ' . l:match[5],
|
||||||
\}
|
\ 'type': l:code[:0] is# 'E' ? 'E' : 'W',
|
||||||
|
\})
|
||||||
call add(l:output, l:item)
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return l:output
|
return l:output
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
" Author: Masahiro H https://github.com/mshr-h
|
" Author: Masahiro H https://github.com/mshr-h
|
||||||
" Description: clang linter for c files
|
" Description: clang linter for c files
|
||||||
|
|
||||||
" Set this option to change the Clang options for warnings for C.
|
call ale#Set('c_clang_executable', 'clang')
|
||||||
if !exists('g:ale_c_clang_options')
|
call ale#Set('c_clang_options', '-std=c11 -Wall')
|
||||||
" let g:ale_c_clang_options = '-Wall'
|
|
||||||
" let g:ale_c_clang_options = '-std=c99 -Wall'
|
function! ale_linters#c#clang#GetExecutable(buffer) abort
|
||||||
" c11 compatible
|
return ale#Var(a:buffer, 'c_clang_executable')
|
||||||
let g:ale_c_clang_options = '-std=c11 -Wall'
|
endfunction
|
||||||
endif
|
|
||||||
|
|
||||||
function! ale_linters#c#clang#GetCommand(buffer) abort
|
function! ale_linters#c#clang#GetCommand(buffer) abort
|
||||||
let l:paths = ale#c#FindLocalHeaderPaths(a:buffer)
|
let l:paths = ale#c#FindLocalHeaderPaths(a:buffer)
|
||||||
|
|
||||||
" -iquote with the directory the file is in makes #include work for
|
" -iquote with the directory the file is in makes #include work for
|
||||||
" headers in the same directory.
|
" headers in the same directory.
|
||||||
return 'clang -S -x c -fsyntax-only '
|
return ale#Escape(ale_linters#c#clang#GetExecutable(a:buffer))
|
||||||
|
\ . ' -S -x c -fsyntax-only '
|
||||||
\ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) . ' '
|
\ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) . ' '
|
||||||
\ . ale#c#IncludeOptions(l:paths)
|
\ . ale#c#IncludeOptions(l:paths)
|
||||||
\ . ale#Var(a:buffer, 'c_clang_options') . ' -'
|
\ . ale#Var(a:buffer, 'c_clang_options') . ' -'
|
||||||
@@ -23,7 +23,7 @@ endfunction
|
|||||||
call ale#linter#Define('c', {
|
call ale#linter#Define('c', {
|
||||||
\ 'name': 'clang',
|
\ 'name': 'clang',
|
||||||
\ 'output_stream': 'stderr',
|
\ 'output_stream': 'stderr',
|
||||||
\ 'executable': 'clang',
|
\ 'executable_callback': 'ale_linters#c#clang#GetExecutable',
|
||||||
\ 'command_callback': 'ale_linters#c#clang#GetCommand',
|
\ 'command_callback': 'ale_linters#c#clang#GetCommand',
|
||||||
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
||||||
\})
|
\})
|
||||||
|
|||||||
64
ale_linters/c/clangtidy.vim
Normal file
64
ale_linters/c/clangtidy.vim
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
" Author: vdeurzen <tim@kompiler.org>, w0rp <devw0rp@gmail.com>,
|
||||||
|
" gagbo <gagbobada@gmail.com>, Andrej Radovic <r.andrej@gmail.com>
|
||||||
|
" Description: clang-tidy linter for c files
|
||||||
|
|
||||||
|
call ale#Set('c_clangtidy_executable', 'clang-tidy')
|
||||||
|
" Set this option to check the checks clang-tidy will apply.
|
||||||
|
" The number of checks that can be applied to C files is limited in contrast to
|
||||||
|
" C++
|
||||||
|
"
|
||||||
|
" Consult the check list in clang-tidy's documentation:
|
||||||
|
" http://clang.llvm.org/extra/clang-tidy/checks/list.html
|
||||||
|
|
||||||
|
call ale#Set('c_clangtidy_checks', ['*'])
|
||||||
|
" Set this option to manually set some options for clang-tidy.
|
||||||
|
" This will disable compile_commands.json detection.
|
||||||
|
call ale#Set('c_clangtidy_options', '')
|
||||||
|
call ale#Set('c_build_dir', '')
|
||||||
|
|
||||||
|
function! ale_linters#c#clangtidy#GetExecutable(buffer) abort
|
||||||
|
return ale#Var(a:buffer, 'c_clangtidy_executable')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:GetBuildDirectory(buffer) abort
|
||||||
|
" Don't include build directory for header files, as compile_commands.json
|
||||||
|
" files don't consider headers to be translation units, and provide no
|
||||||
|
" commands for compiling header files.
|
||||||
|
if expand('#' . a:buffer) =~# '\v\.(h|hpp)$'
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:build_dir = ale#Var(a:buffer, 'c_build_dir')
|
||||||
|
|
||||||
|
" c_build_dir has the priority if defined
|
||||||
|
if !empty(l:build_dir)
|
||||||
|
return l:build_dir
|
||||||
|
endif
|
||||||
|
|
||||||
|
return ale#c#FindCompileCommands(a:buffer)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#c#clangtidy#GetCommand(buffer) abort
|
||||||
|
let l:checks = join(ale#Var(a:buffer, 'c_clangtidy_checks'), ',')
|
||||||
|
let l:build_dir = s:GetBuildDirectory(a:buffer)
|
||||||
|
|
||||||
|
" Get the extra options if we couldn't find a build directory.
|
||||||
|
let l:options = empty(l:build_dir)
|
||||||
|
\ ? ale#Var(a:buffer, 'c_clangtidy_options')
|
||||||
|
\ : ''
|
||||||
|
|
||||||
|
return ale#Escape(ale_linters#c#clangtidy#GetExecutable(a:buffer))
|
||||||
|
\ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '')
|
||||||
|
\ . ' %s'
|
||||||
|
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
|
||||||
|
\ . (!empty(l:options) ? ' -- ' . l:options : '')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('c', {
|
||||||
|
\ 'name': 'clangtidy',
|
||||||
|
\ 'output_stream': 'stdout',
|
||||||
|
\ 'executable_callback': 'ale_linters#c#clangtidy#GetExecutable',
|
||||||
|
\ 'command_callback': 'ale_linters#c#clangtidy#GetCommand',
|
||||||
|
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
||||||
|
\ 'lint_file': 1,
|
||||||
|
\})
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
" Author: Bart Libert <bart.libert@gmail.com>
|
" Author: Bart Libert <bart.libert@gmail.com>
|
||||||
" Description: cppcheck linter for c files
|
" Description: cppcheck linter for c files
|
||||||
|
|
||||||
" Set this option to change the cppcheck options
|
call ale#Set('c_cppcheck_executable', 'cppcheck')
|
||||||
let g:ale_c_cppcheck_options = get(g:, 'ale_c_cppcheck_options', '--enable=style')
|
call ale#Set('c_cppcheck_options', '--enable=style')
|
||||||
|
|
||||||
|
function! ale_linters#c#cppcheck#GetExecutable(buffer) abort
|
||||||
|
return ale#Var(a:buffer, 'c_cppcheck_executable')
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#c#cppcheck#GetCommand(buffer) abort
|
function! ale_linters#c#cppcheck#GetCommand(buffer) abort
|
||||||
" Search upwards from the file for compile_commands.json.
|
" Search upwards from the file for compile_commands.json.
|
||||||
@@ -19,7 +23,8 @@ function! ale_linters#c#cppcheck#GetCommand(buffer) abort
|
|||||||
\ : ''
|
\ : ''
|
||||||
|
|
||||||
return l:cd_command
|
return l:cd_command
|
||||||
\ . 'cppcheck -q --language=c '
|
\ . ale#Escape(ale_linters#c#cppcheck#GetExecutable(a:buffer))
|
||||||
|
\ . ' -q --language=c '
|
||||||
\ . l:compile_commands_option
|
\ . l:compile_commands_option
|
||||||
\ . ale#Var(a:buffer, 'c_cppcheck_options')
|
\ . ale#Var(a:buffer, 'c_cppcheck_options')
|
||||||
\ . ' %t'
|
\ . ' %t'
|
||||||
@@ -28,7 +33,7 @@ endfunction
|
|||||||
call ale#linter#Define('c', {
|
call ale#linter#Define('c', {
|
||||||
\ 'name': 'cppcheck',
|
\ 'name': 'cppcheck',
|
||||||
\ 'output_stream': 'both',
|
\ 'output_stream': 'both',
|
||||||
\ 'executable': 'cppcheck',
|
\ 'executable_callback': 'ale_linters#c#cppcheck#GetExecutable',
|
||||||
\ 'command_callback': 'ale_linters#c#cppcheck#GetCommand',
|
\ 'command_callback': 'ale_linters#c#cppcheck#GetCommand',
|
||||||
\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat',
|
\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
" Author: w0rp <devw0rp@gmail.com>
|
" Author: w0rp <devw0rp@gmail.com>
|
||||||
" Description: gcc linter for c files
|
" Description: gcc linter for c files
|
||||||
|
|
||||||
" Set this option to change the GCC options for warnings for C.
|
call ale#Set('c_gcc_executable', 'gcc')
|
||||||
if !exists('g:ale_c_gcc_options')
|
call ale#Set('c_gcc_options', '-std=c11 -Wall')
|
||||||
" let g:ale_c_gcc_options = '-Wall'
|
|
||||||
" let g:ale_c_gcc_options = '-std=c99 -Wall'
|
function! ale_linters#c#gcc#GetExecutable(buffer) abort
|
||||||
" c11 compatible
|
return ale#Var(a:buffer, 'c_gcc_executable')
|
||||||
let g:ale_c_gcc_options = '-std=c11 -Wall'
|
endfunction
|
||||||
endif
|
|
||||||
|
|
||||||
function! ale_linters#c#gcc#GetCommand(buffer) abort
|
function! ale_linters#c#gcc#GetCommand(buffer) abort
|
||||||
let l:paths = ale#c#FindLocalHeaderPaths(a:buffer)
|
let l:paths = ale#c#FindLocalHeaderPaths(a:buffer)
|
||||||
|
|
||||||
" -iquote with the directory the file is in makes #include work for
|
" -iquote with the directory the file is in makes #include work for
|
||||||
" headers in the same directory.
|
" headers in the same directory.
|
||||||
return 'gcc -S -x c -fsyntax-only '
|
return ale#Escape(ale_linters#c#gcc#GetExecutable(a:buffer))
|
||||||
|
\ . ' -S -x c -fsyntax-only '
|
||||||
\ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) . ' '
|
\ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) . ' '
|
||||||
\ . ale#c#IncludeOptions(l:paths)
|
\ . ale#c#IncludeOptions(l:paths)
|
||||||
\ . ale#Var(a:buffer, 'c_gcc_options') . ' -'
|
\ . ale#Var(a:buffer, 'c_gcc_options') . ' -'
|
||||||
@@ -23,7 +23,7 @@ endfunction
|
|||||||
call ale#linter#Define('c', {
|
call ale#linter#Define('c', {
|
||||||
\ 'name': 'gcc',
|
\ 'name': 'gcc',
|
||||||
\ 'output_stream': 'stderr',
|
\ 'output_stream': 'stderr',
|
||||||
\ 'executable': 'gcc',
|
\ 'executable_callback': 'ale_linters#c#gcc#GetExecutable',
|
||||||
\ 'command_callback': 'ale_linters#c#gcc#GetCommand',
|
\ 'command_callback': 'ale_linters#c#gcc#GetCommand',
|
||||||
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ function! ale_linters#coffee#coffeelint#Handle(buffer, lines) abort
|
|||||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
call add(l:output, {
|
call add(l:output, {
|
||||||
\ 'lnum': str2nr(l:match[1]),
|
\ 'lnum': str2nr(l:match[1]),
|
||||||
\ 'type': l:match[3] ==# 'error' ? 'E' : 'W',
|
\ 'type': l:match[3] is# 'error' ? 'E' : 'W',
|
||||||
\ 'text': l:match[4],
|
\ 'text': l:match[4],
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|||||||
@@ -1,17 +1,20 @@
|
|||||||
" Author: Tomota Nakamura <https://github.com/tomotanakamura>
|
" Author: Tomota Nakamura <https://github.com/tomotanakamura>
|
||||||
" Description: clang linter for cpp files
|
" Description: clang linter for cpp files
|
||||||
|
|
||||||
" Set this option to change the Clang options for warnings for CPP.
|
call ale#Set('cpp_clang_executable', 'clang++')
|
||||||
if !exists('g:ale_cpp_clang_options')
|
call ale#Set('cpp_clang_options', '-std=c++14 -Wall')
|
||||||
let g:ale_cpp_clang_options = '-std=c++14 -Wall'
|
|
||||||
endif
|
function! ale_linters#cpp#clang#GetExecutable(buffer) abort
|
||||||
|
return ale#Var(a:buffer, 'cpp_clang_executable')
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#cpp#clang#GetCommand(buffer) abort
|
function! ale_linters#cpp#clang#GetCommand(buffer) abort
|
||||||
let l:paths = ale#c#FindLocalHeaderPaths(a:buffer)
|
let l:paths = ale#c#FindLocalHeaderPaths(a:buffer)
|
||||||
|
|
||||||
" -iquote with the directory the file is in makes #include work for
|
" -iquote with the directory the file is in makes #include work for
|
||||||
" headers in the same directory.
|
" headers in the same directory.
|
||||||
return 'clang++ -S -x c++ -fsyntax-only '
|
return ale#Escape(ale_linters#cpp#clang#GetExecutable(a:buffer))
|
||||||
|
\ . ' -S -x c++ -fsyntax-only '
|
||||||
\ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) . ' '
|
\ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) . ' '
|
||||||
\ . ale#c#IncludeOptions(l:paths)
|
\ . ale#c#IncludeOptions(l:paths)
|
||||||
\ . ale#Var(a:buffer, 'cpp_clang_options') . ' -'
|
\ . ale#Var(a:buffer, 'cpp_clang_options') . ' -'
|
||||||
@@ -20,7 +23,7 @@ endfunction
|
|||||||
call ale#linter#Define('cpp', {
|
call ale#linter#Define('cpp', {
|
||||||
\ 'name': 'clang',
|
\ 'name': 'clang',
|
||||||
\ 'output_stream': 'stderr',
|
\ 'output_stream': 'stderr',
|
||||||
\ 'executable': 'clang++',
|
\ 'executable_callback': 'ale_linters#cpp#clang#GetExecutable',
|
||||||
\ 'command_callback': 'ale_linters#cpp#clang#GetCommand',
|
\ 'command_callback': 'ale_linters#cpp#clang#GetCommand',
|
||||||
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -1,36 +1,38 @@
|
|||||||
" Author: gagbo <gagbobada@gmail.com>
|
" Author: gagbo <gagbobada@gmail.com>
|
||||||
" Description: clang-check linter for cpp files
|
" Description: clang-check linter for cpp files
|
||||||
|
|
||||||
" Set this option to manually set some options for clang-check.
|
call ale#Set('cpp_clangcheck_executable', 'clang-check')
|
||||||
let g:ale_cpp_clangcheck_options = get(g:, 'ale_cpp_clangcheck_options', '')
|
call ale#Set('cpp_clangcheck_options', '')
|
||||||
|
call ale#Set('c_build_dir', '')
|
||||||
|
|
||||||
" Set this option to manually point to the build directory for clang-tidy.
|
function! ale_linters#cpp#clangcheck#GetExecutable(buffer) abort
|
||||||
" This will disable all the other clangtidy_options, since compilation
|
return ale#Var(a:buffer, 'cpp_clangcheck_executable')
|
||||||
" flags are contained in the json
|
endfunction
|
||||||
let g:ale_c_build_dir = get(g:, 'ale_c_build_dir', '')
|
|
||||||
|
|
||||||
function! ale_linters#cpp#clangcheck#GetCommand(buffer) abort
|
function! ale_linters#cpp#clangcheck#GetCommand(buffer) abort
|
||||||
let l:user_options = ale#Var(a:buffer, 'cpp_clangcheck_options')
|
let l:user_options = ale#Var(a:buffer, 'cpp_clangcheck_options')
|
||||||
let l:extra_options = !empty(l:user_options)
|
|
||||||
\ ? l:user_options
|
|
||||||
\ : ''
|
|
||||||
|
|
||||||
" Try to find compilation database to link automatically
|
" Try to find compilation database to link automatically
|
||||||
let l:user_build_dir = ale#Var(a:buffer, 'c_build_dir')
|
let l:build_dir = ale#Var(a:buffer, 'c_build_dir')
|
||||||
if empty(l:user_build_dir)
|
|
||||||
let l:user_build_dir = ale#c#FindCompileCommands(a:buffer)
|
|
||||||
endif
|
|
||||||
let l:build_options = !empty(l:user_build_dir)
|
|
||||||
\ ? ' -p ' . ale#Escape(l:user_build_dir)
|
|
||||||
\ : ''
|
|
||||||
|
|
||||||
return 'clang-check -analyze ' . '%s' . l:extra_options . l:build_options
|
if empty(l:build_dir)
|
||||||
|
let l:build_dir = ale#c#FindCompileCommands(a:buffer)
|
||||||
|
endif
|
||||||
|
|
||||||
|
" The extra arguments in the command are used to prevent .plist files from
|
||||||
|
" being generated. These are only added if no build directory can be
|
||||||
|
" detected.
|
||||||
|
return ale#Escape(ale_linters#cpp#clangcheck#GetExecutable(a:buffer))
|
||||||
|
\ . ' -analyze %s'
|
||||||
|
\ . (!empty(l:user_options) ? ' ' . l:user_options : '')
|
||||||
|
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
|
||||||
|
\ . (empty(l:build_dir) ? ' -extra-arg -Xanalyzer -extra-arg -analyzer-output=text' : '')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('cpp', {
|
call ale#linter#Define('cpp', {
|
||||||
\ 'name': 'clangcheck',
|
\ 'name': 'clangcheck',
|
||||||
\ 'output_stream': 'stderr',
|
\ 'output_stream': 'stderr',
|
||||||
\ 'executable': 'clang-check',
|
\ 'executable_callback': 'ale_linters#cpp#clangcheck#GetExecutable',
|
||||||
\ 'command_callback': 'ale_linters#cpp#clangcheck#GetCommand',
|
\ 'command_callback': 'ale_linters#cpp#clangcheck#GetCommand',
|
||||||
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
||||||
\ 'lint_file': 1,
|
\ 'lint_file': 1,
|
||||||
|
|||||||
@@ -2,51 +2,56 @@
|
|||||||
" gagbo <gagbobada@gmail.com>
|
" gagbo <gagbobada@gmail.com>
|
||||||
" Description: clang-tidy linter for cpp files
|
" Description: clang-tidy linter for cpp files
|
||||||
|
|
||||||
|
call ale#Set('cpp_clangtidy_executable', 'clang-tidy')
|
||||||
" Set this option to check the checks clang-tidy will apply.
|
" Set this option to check the checks clang-tidy will apply.
|
||||||
let g:ale_cpp_clangtidy_checks = get(g:, 'ale_cpp_clangtidy_checks', ['*'])
|
call ale#Set('cpp_clangtidy_checks', ['*'])
|
||||||
|
|
||||||
" Set this option to manually set some options for clang-tidy.
|
" Set this option to manually set some options for clang-tidy.
|
||||||
" This will disable compile_commands.json detection.
|
" This will disable compile_commands.json detection.
|
||||||
let g:ale_cpp_clangtidy_options = get(g:, 'ale_cpp_clangtidy_options', '')
|
call ale#Set('cpp_clangtidy_options', '')
|
||||||
|
call ale#Set('c_build_dir', '')
|
||||||
|
|
||||||
" Set this option to manually point to the build directory for clang-tidy.
|
function! ale_linters#cpp#clangtidy#GetExecutable(buffer) abort
|
||||||
" This will disable all the other clangtidy_options, since compilation
|
return ale#Var(a:buffer, 'cpp_clangtidy_executable')
|
||||||
" flags are contained in the json
|
endfunction
|
||||||
let g:ale_c_build_dir = get(g:, 'ale_c_build_dir', '')
|
|
||||||
|
|
||||||
|
function! s:GetBuildDirectory(buffer) abort
|
||||||
|
" Don't include build directory for header files, as compile_commands.json
|
||||||
|
" files don't consider headers to be translation units, and provide no
|
||||||
|
" commands for compiling header files.
|
||||||
|
if expand('#' . a:buffer) =~# '\v\.(h|hpp)$'
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
|
||||||
function! ale_linters#cpp#clangtidy#GetCommand(buffer) abort
|
let l:build_dir = ale#Var(a:buffer, 'c_build_dir')
|
||||||
let l:check_list = ale#Var(a:buffer, 'cpp_clangtidy_checks')
|
|
||||||
let l:check_option = !empty(l:check_list)
|
|
||||||
\ ? '-checks=' . ale#Escape(join(l:check_list, ',')) . ' '
|
|
||||||
\ : ''
|
|
||||||
let l:user_options = ale#Var(a:buffer, 'cpp_clangtidy_options')
|
|
||||||
let l:user_build_dir = ale#Var(a:buffer, 'c_build_dir')
|
|
||||||
|
|
||||||
" c_build_dir has the priority if defined
|
" c_build_dir has the priority if defined
|
||||||
if empty(l:user_build_dir)
|
if !empty(l:build_dir)
|
||||||
let l:user_build_dir = ale#c#FindCompileCommands(a:buffer)
|
return l:build_dir
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" We check again if user_builddir stayed empty after the
|
return ale#c#FindCompileCommands(a:buffer)
|
||||||
" c_build_dir_names check
|
endfunction
|
||||||
" If we found the compilation database we override the value of
|
|
||||||
" l:extra_options
|
|
||||||
if empty(l:user_build_dir)
|
|
||||||
let l:extra_options = !empty(l:user_options)
|
|
||||||
\ ? ' -- ' . l:user_options
|
|
||||||
\ : ''
|
|
||||||
else
|
|
||||||
let l:extra_options = ' -p ' . ale#Escape(l:user_build_dir)
|
|
||||||
endif
|
|
||||||
|
|
||||||
return 'clang-tidy ' . l:check_option . '%s' . l:extra_options
|
function! ale_linters#cpp#clangtidy#GetCommand(buffer) abort
|
||||||
|
let l:checks = join(ale#Var(a:buffer, 'cpp_clangtidy_checks'), ',')
|
||||||
|
let l:build_dir = s:GetBuildDirectory(a:buffer)
|
||||||
|
|
||||||
|
" Get the extra options if we couldn't find a build directory.
|
||||||
|
let l:options = empty(l:build_dir)
|
||||||
|
\ ? ale#Var(a:buffer, 'cpp_clangtidy_options')
|
||||||
|
\ : ''
|
||||||
|
|
||||||
|
return ale#Escape(ale_linters#cpp#clangtidy#GetExecutable(a:buffer))
|
||||||
|
\ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '')
|
||||||
|
\ . ' %s'
|
||||||
|
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
|
||||||
|
\ . (!empty(l:options) ? ' -- ' . l:options : '')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('cpp', {
|
call ale#linter#Define('cpp', {
|
||||||
\ 'name': 'clangtidy',
|
\ 'name': 'clangtidy',
|
||||||
\ 'output_stream': 'stdout',
|
\ 'output_stream': 'stdout',
|
||||||
\ 'executable': 'clang-tidy',
|
\ 'executable_callback': 'ale_linters#cpp#clangtidy#GetExecutable',
|
||||||
\ 'command_callback': 'ale_linters#cpp#clangtidy#GetCommand',
|
\ 'command_callback': 'ale_linters#cpp#clangtidy#GetCommand',
|
||||||
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
||||||
\ 'lint_file': 1,
|
\ 'lint_file': 1,
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
" Author: Bart Libert <bart.libert@gmail.com>
|
" Author: Bart Libert <bart.libert@gmail.com>
|
||||||
" Description: cppcheck linter for cpp files
|
" Description: cppcheck linter for cpp files
|
||||||
|
|
||||||
" Set this option to change the cppcheck options
|
call ale#Set('cpp_cppcheck_executable', 'cppcheck')
|
||||||
let g:ale_cpp_cppcheck_options = get(g:, 'ale_cpp_cppcheck_options', '--enable=style')
|
call ale#Set('cpp_cppcheck_options', '--enable=style')
|
||||||
|
|
||||||
|
function! ale_linters#cpp#cppcheck#GetExecutable(buffer) abort
|
||||||
|
return ale#Var(a:buffer, 'cpp_cppcheck_executable')
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort
|
function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort
|
||||||
" Search upwards from the file for compile_commands.json.
|
" Search upwards from the file for compile_commands.json.
|
||||||
@@ -19,7 +23,8 @@ function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort
|
|||||||
\ : ''
|
\ : ''
|
||||||
|
|
||||||
return l:cd_command
|
return l:cd_command
|
||||||
\ . 'cppcheck -q --language=c++ '
|
\ . ale#Escape(ale_linters#cpp#cppcheck#GetExecutable(a:buffer))
|
||||||
|
\ . ' -q --language=c++ '
|
||||||
\ . l:compile_commands_option
|
\ . l:compile_commands_option
|
||||||
\ . ale#Var(a:buffer, 'cpp_cppcheck_options')
|
\ . ale#Var(a:buffer, 'cpp_cppcheck_options')
|
||||||
\ . ' %t'
|
\ . ' %t'
|
||||||
@@ -28,7 +33,7 @@ endfunction
|
|||||||
call ale#linter#Define('cpp', {
|
call ale#linter#Define('cpp', {
|
||||||
\ 'name': 'cppcheck',
|
\ 'name': 'cppcheck',
|
||||||
\ 'output_stream': 'both',
|
\ 'output_stream': 'both',
|
||||||
\ 'executable': 'cppcheck',
|
\ 'executable_callback': 'ale_linters#cpp#cppcheck#GetExecutable',
|
||||||
\ 'command_callback': 'ale_linters#cpp#cppcheck#GetCommand',
|
\ 'command_callback': 'ale_linters#cpp#cppcheck#GetCommand',
|
||||||
\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat',
|
\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -1,15 +1,26 @@
|
|||||||
" Author: Dawid Kurek https://github.com/dawikur
|
" Author: Dawid Kurek https://github.com/dawikur
|
||||||
" Description: cpplint for cpp files
|
" Description: cpplint for cpp files
|
||||||
|
|
||||||
if !exists('g:ale_cpp_cpplint_options')
|
call ale#Set('cpp_cpplint_executable', 'cpplint')
|
||||||
let g:ale_cpp_cpplint_options = ''
|
call ale#Set('cpp_cpplint_options', '')
|
||||||
endif
|
|
||||||
|
function! ale_linters#cpp#cpplint#GetExecutable(buffer) abort
|
||||||
|
return ale#Var(a:buffer, 'cpp_cpplint_executable')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#cpp#cpplint#GetCommand(buffer) abort
|
||||||
|
let l:options = ale#Var(a:buffer, 'cpp_cpplint_options')
|
||||||
|
|
||||||
|
return ale#Escape(ale_linters#cpp#cpplint#GetExecutable(a:buffer))
|
||||||
|
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||||
|
\ . ' %s'
|
||||||
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('cpp', {
|
call ale#linter#Define('cpp', {
|
||||||
\ 'name': 'cpplint',
|
\ 'name': 'cpplint',
|
||||||
\ 'output_stream': 'stderr',
|
\ 'output_stream': 'stderr',
|
||||||
\ 'executable': 'cpplint',
|
\ 'executable_callback': 'ale_linters#cpp#cpplint#GetExecutable',
|
||||||
\ 'command': 'cpplint %s',
|
\ 'command_callback': 'ale_linters#cpp#cpplint#GetCommand',
|
||||||
\ 'callback': 'ale#handlers#cpplint#HandleCppLintFormat',
|
\ 'callback': 'ale#handlers#cpplint#HandleCppLintFormat',
|
||||||
\ 'lint_file': 1,
|
\ 'lint_file': 1,
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -1,27 +1,20 @@
|
|||||||
" Author: geam <mdelage@student.42.fr>
|
" Author: geam <mdelage@student.42.fr>
|
||||||
" Description: gcc linter for cpp files
|
" Description: gcc linter for cpp files
|
||||||
|
"
|
||||||
|
call ale#Set('cpp_gcc_executable', 'gcc')
|
||||||
|
call ale#Set('cpp_gcc_options', '-std=c++14 -Wall')
|
||||||
|
|
||||||
" Set this option to change the GCC options for warnings for C.
|
function! ale_linters#cpp#gcc#GetExecutable(buffer) abort
|
||||||
if !exists('g:ale_cpp_gcc_options')
|
return ale#Var(a:buffer, 'cpp_gcc_executable')
|
||||||
let s:version = ale#handlers#gcc#ParseGCCVersion(systemlist('gcc --version'))
|
endfunction
|
||||||
|
|
||||||
if !empty(s:version) && ale#semver#GreaterOrEqual(s:version, [4, 9, 0])
|
|
||||||
" Use c++14 support in 4.9 and above.
|
|
||||||
let g:ale_cpp_gcc_options = '-std=c++14 -Wall'
|
|
||||||
else
|
|
||||||
" Use c++1y in older versions.
|
|
||||||
let g:ale_cpp_gcc_options = '-std=c++1y -Wall'
|
|
||||||
endif
|
|
||||||
|
|
||||||
unlet! s:version
|
|
||||||
endif
|
|
||||||
|
|
||||||
function! ale_linters#cpp#gcc#GetCommand(buffer) abort
|
function! ale_linters#cpp#gcc#GetCommand(buffer) abort
|
||||||
let l:paths = ale#c#FindLocalHeaderPaths(a:buffer)
|
let l:paths = ale#c#FindLocalHeaderPaths(a:buffer)
|
||||||
|
|
||||||
" -iquote with the directory the file is in makes #include work for
|
" -iquote with the directory the file is in makes #include work for
|
||||||
" headers in the same directory.
|
" headers in the same directory.
|
||||||
return 'gcc -S -x c++ -fsyntax-only '
|
return ale#Escape(ale_linters#cpp#gcc#GetExecutable(a:buffer))
|
||||||
|
\ . ' -S -x c++ -fsyntax-only '
|
||||||
\ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) . ' '
|
\ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) . ' '
|
||||||
\ . ale#c#IncludeOptions(l:paths)
|
\ . ale#c#IncludeOptions(l:paths)
|
||||||
\ . ale#Var(a:buffer, 'cpp_gcc_options') . ' -'
|
\ . ale#Var(a:buffer, 'cpp_gcc_options') . ' -'
|
||||||
@@ -30,7 +23,7 @@ endfunction
|
|||||||
call ale#linter#Define('cpp', {
|
call ale#linter#Define('cpp', {
|
||||||
\ 'name': 'g++',
|
\ 'name': 'g++',
|
||||||
\ 'output_stream': 'stderr',
|
\ 'output_stream': 'stderr',
|
||||||
\ 'executable': 'g++',
|
\ 'executable_callback': 'ale_linters#cpp#gcc#GetExecutable',
|
||||||
\ 'command_callback': 'ale_linters#cpp#gcc#GetCommand',
|
\ 'command_callback': 'ale_linters#cpp#gcc#GetCommand',
|
||||||
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -4,31 +4,21 @@
|
|||||||
function! ale_linters#crystal#crystal#Handle(buffer, lines) abort
|
function! ale_linters#crystal#crystal#Handle(buffer, lines) abort
|
||||||
let l:output = []
|
let l:output = []
|
||||||
|
|
||||||
let l:lines = join(a:lines, '')
|
for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
|
||||||
|
call add(l:output, {
|
||||||
if !empty(l:lines)
|
\ 'lnum': l:error.line + 0,
|
||||||
let l:errors = json_decode(l:lines)
|
\ 'col': l:error.column + 0,
|
||||||
|
\ 'text': l:error.message,
|
||||||
for l:error in l:errors
|
\})
|
||||||
call add(l:output, {
|
endfor
|
||||||
\ 'bufnr': a:buffer,
|
|
||||||
\ 'lnum': l:error.line + 0,
|
|
||||||
\ 'col': l:error.column + 0,
|
|
||||||
\ 'text': l:error.message,
|
|
||||||
\ 'type': 'E',
|
|
||||||
\})
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
|
|
||||||
return l:output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#crystal#crystal#GetCommand(buffer) abort
|
function! ale_linters#crystal#crystal#GetCommand(buffer) abort
|
||||||
let l:crystal_cmd = 'crystal build -f json --no-codegen --no-color -o '
|
return 'crystal build -f json --no-codegen --no-color -o '
|
||||||
let l:crystal_cmd .= ale#Escape(g:ale#util#nul_file)
|
\ . ale#Escape(g:ale#util#nul_file)
|
||||||
let l:crystal_cmd .= ' %s'
|
\ . ' %s'
|
||||||
|
|
||||||
return l:crystal_cmd
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('crystal', {
|
call ale#linter#Define('crystal', {
|
||||||
|
|||||||
87
ale_linters/cs/mcsc.vim
Normal file
87
ale_linters/cs/mcsc.vim
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
" general mcs options which are likely to stay constant across
|
||||||
|
" source trees like -pkg:dotnet
|
||||||
|
let g:ale_cs_mcsc_options = get(g:, 'ale_cs_mcsc_options', '')
|
||||||
|
|
||||||
|
" path string pointing the linter to the base path of the
|
||||||
|
" source tree to check
|
||||||
|
let g:ale_cs_mcsc_source = get(g:, 'ale_cs_mcsc_source','.')
|
||||||
|
|
||||||
|
" list of search paths for additional assemblies to consider
|
||||||
|
let g:ale_cs_mcsc_assembly_path = get(g:, 'ale_cs_mcsc_assembly_path',[])
|
||||||
|
|
||||||
|
" list of assemblies to consider
|
||||||
|
let g:ale_cs_mcsc_assemblies = get(g:, 'ale_cs_mcsc_assemblies',[])
|
||||||
|
function! ale_linters#cs#mcsc#GetCommand(buffer) abort
|
||||||
|
|
||||||
|
" if list of assembly search paths is not empty convert it to
|
||||||
|
" appropriate -lib: parameter of mcs
|
||||||
|
let l:path = ale#Var(a:buffer, 'cs_mcsc_assembly_path')
|
||||||
|
|
||||||
|
if !empty(l:path)
|
||||||
|
let l:path = '-lib:"' . join(l:path, '","') .'"'
|
||||||
|
else
|
||||||
|
let l:path =''
|
||||||
|
endif
|
||||||
|
|
||||||
|
" if list of assemblies to link is not empty convert it to the
|
||||||
|
" appropriate -r: parameter of mcs
|
||||||
|
let l:assemblies = ale#Var(a:buffer, 'cs_mcsc_assemblies')
|
||||||
|
|
||||||
|
if !empty(l:assemblies)
|
||||||
|
let l:assemblies = '-r:"' . join(l:assemblies, '","') . '"'
|
||||||
|
else
|
||||||
|
let l:assemblies =''
|
||||||
|
endif
|
||||||
|
|
||||||
|
" register temporary module target file with ale
|
||||||
|
let l:out = tempname()
|
||||||
|
call ale#engine#ManageFile(a:buffer, l:out)
|
||||||
|
|
||||||
|
" assemble linter command string to be executed by ale
|
||||||
|
" implicitly set -unsafe mcs flag set compilation
|
||||||
|
" target to module (-t:module), direct mcs output to
|
||||||
|
" temporary file (-out)
|
||||||
|
"
|
||||||
|
return 'cd "' . ale#Var(a:buffer, 'cs_mcsc_source') . '";'
|
||||||
|
\ . 'mcs -unsafe'
|
||||||
|
\ . ' ' . ale#Var(a:buffer, 'cs_mcsc_options')
|
||||||
|
\ . ' ' . l:path
|
||||||
|
\ . ' ' . l:assemblies
|
||||||
|
\ . ' -out:' . l:out
|
||||||
|
\ . ' -t:module'
|
||||||
|
\ . ' -recurse:"*.cs"'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#cs#mcsc#Handle(buffer, lines) abort
|
||||||
|
" Look for lines like the following.
|
||||||
|
"
|
||||||
|
" Tests.cs(12,29): error CSXXXX: ; expected
|
||||||
|
"
|
||||||
|
" NOTE: pattern also captures file name as linter compiles all
|
||||||
|
" files within the source tree rooted at the specified source
|
||||||
|
" path and not just the file loaded in the buffer
|
||||||
|
let l:pattern = '^\(.\+\.cs\)(\(\d\+\),\(\d\+\)): \(.\+\): \(.\+\)'
|
||||||
|
let l:output = []
|
||||||
|
let l:source = ale#Var(a:buffer, 'cs_mcsc_source')
|
||||||
|
|
||||||
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
|
call add(l:output, {
|
||||||
|
\ 'filename': fnamemodify(l:source . '/' . l:match[1], ':p'),
|
||||||
|
\ 'lnum': l:match[2] + 0,
|
||||||
|
\ 'col': l:match[3] + 0,
|
||||||
|
\ 'text': l:match[4] . ': ' . l:match[5],
|
||||||
|
\ 'type': l:match[4] =~# '^error' ? 'E' : 'W',
|
||||||
|
\})
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return l:output
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('cs',{
|
||||||
|
\ 'name': 'mcsc',
|
||||||
|
\ 'output_stream': 'stderr',
|
||||||
|
\ 'executable': 'mcs',
|
||||||
|
\ 'command_callback': 'ale_linters#cs#mcsc#GetCommand',
|
||||||
|
\ 'callback': 'ale_linters#cs#mcsc#Handle',
|
||||||
|
\ 'lint_file': 1
|
||||||
|
\})
|
||||||
56
ale_linters/cuda/nvcc.vim
Normal file
56
ale_linters/cuda/nvcc.vim
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
" Author: blahgeek <i@blahgeek.com>
|
||||||
|
" Description: NVCC linter for cuda files
|
||||||
|
|
||||||
|
call ale#Set('cuda_nvcc_executable', 'nvcc')
|
||||||
|
call ale#Set('cuda_nvcc_options', '-std=c++11')
|
||||||
|
|
||||||
|
function! ale_linters#cuda#nvcc#GetExecutable(buffer) abort
|
||||||
|
return ale#Var(a:buffer, 'cuda_nvcc_executable')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#cuda#nvcc#GetCommand(buffer) abort
|
||||||
|
" Unused: use ale#util#nul_file
|
||||||
|
" let l:output_file = tempname() . '.ii'
|
||||||
|
" call ale#engine#ManageFile(a:buffer, l:output_file)
|
||||||
|
|
||||||
|
return ale#Escape(ale_linters#cuda#nvcc#GetExecutable(a:buffer))
|
||||||
|
\ . ' -cuda '
|
||||||
|
\ . ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer))
|
||||||
|
\ . ale#Var(a:buffer, 'cuda_nvcc_options') . ' %s'
|
||||||
|
\ . ' -o ' . g:ale#util#nul_file
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#cuda#nvcc#HandleNVCCFormat(buffer, lines) abort
|
||||||
|
" Look for lines like the following.
|
||||||
|
"
|
||||||
|
" test.cu(8): error: argument of type "void *" is incompatible with parameter of type "int *"
|
||||||
|
let l:pattern = '\v^([^:\(\)]+):?\(?(\d+)\)?:(\d+)?:?\s*\w*\s*(error|warning): (.+)$'
|
||||||
|
let l:output = []
|
||||||
|
|
||||||
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
|
|
||||||
|
let l:item = {
|
||||||
|
\ 'lnum': str2nr(l:match[2]),
|
||||||
|
\ 'type': l:match[4] =~# 'error' ? 'E' : 'W',
|
||||||
|
\ 'text': l:match[5],
|
||||||
|
\ 'filename': fnamemodify(l:match[1], ':p'),
|
||||||
|
\}
|
||||||
|
|
||||||
|
if !empty(l:match[3])
|
||||||
|
let l:item.col = str2nr(l:match[3])
|
||||||
|
endif
|
||||||
|
|
||||||
|
call add(l:output, l:item)
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return l:output
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('cuda', {
|
||||||
|
\ 'name': 'nvcc',
|
||||||
|
\ 'output_stream': 'stderr',
|
||||||
|
\ 'executable_callback': 'ale_linters#cuda#nvcc#GetExecutable',
|
||||||
|
\ 'command_callback': 'ale_linters#cuda#nvcc#GetCommand',
|
||||||
|
\ 'callback': 'ale_linters#cuda#nvcc#HandleNVCCFormat',
|
||||||
|
\ 'lint_file': 1,
|
||||||
|
\})
|
||||||
@@ -60,7 +60,7 @@ function! ale_linters#d#dmd#Handle(buffer, lines) abort
|
|||||||
call add(l:output, {
|
call add(l:output, {
|
||||||
\ 'lnum': l:match[1],
|
\ 'lnum': l:match[1],
|
||||||
\ 'col': l:match[2],
|
\ 'col': l:match[2],
|
||||||
\ 'type': l:match[3] ==# 'Warning' ? 'W' : 'E',
|
\ 'type': l:match[3] is# 'Warning' ? 'W' : 'E',
|
||||||
\ 'text': l:match[4],
|
\ 'text': l:match[4],
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|||||||
40
ale_linters/dart/dartanalyzer.vim
Normal file
40
ale_linters/dart/dartanalyzer.vim
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
" Author: w0rp <devw0rp@gmail.com>
|
||||||
|
" Description: Check Dart files with dartanalyzer
|
||||||
|
|
||||||
|
call ale#Set('dart_dartanalyzer_executable', 'dartanalyzer')
|
||||||
|
|
||||||
|
function! ale_linters#dart#dartanalyzer#GetExecutable(buffer) abort
|
||||||
|
return ale#Var(a:buffer, 'dart_dartanalyzer_executable')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#dart#dartanalyzer#GetCommand(buffer) abort
|
||||||
|
let l:executable = ale_linters#dart#dartanalyzer#GetExecutable(a:buffer)
|
||||||
|
let l:path = ale#path#FindNearestFile(a:buffer, '.packages')
|
||||||
|
|
||||||
|
return ale#Escape(l:executable)
|
||||||
|
\ . (!empty(l:path) ? ' --packages ' . ale#Escape(l:path) : '')
|
||||||
|
\ . ' %t'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#dart#dartanalyzer#Handle(buffer, lines) abort
|
||||||
|
let l:pattern = '\v^ ([a-z]+) . (.+) at (.+):(\d+):(\d+) . (.+)$'
|
||||||
|
let l:output = []
|
||||||
|
|
||||||
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
|
call add(l:output, {
|
||||||
|
\ 'type': l:match[1] is# 'error' ? 'E' : 'W',
|
||||||
|
\ 'text': l:match[6] . ': ' . l:match[2],
|
||||||
|
\ 'lnum': str2nr(l:match[4]),
|
||||||
|
\ 'col': str2nr(l:match[5]),
|
||||||
|
\})
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return l:output
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('dart', {
|
||||||
|
\ 'name': 'dartanalyzer',
|
||||||
|
\ 'executable_callback': 'ale_linters#dart#dartanalyzer#GetExecutable',
|
||||||
|
\ 'command_callback': 'ale_linters#dart#dartanalyzer#GetCommand',
|
||||||
|
\ 'callback': 'ale_linters#dart#dartanalyzer#Handle',
|
||||||
|
\})
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
" Author: hauleth - https://github.com/hauleth
|
" Author: hauleth - https://github.com/hauleth
|
||||||
|
|
||||||
|
" always, yes, never
|
||||||
|
call ale#Set('dockerfile_hadolint_use_docker', 'never')
|
||||||
|
call ale#Set('dockerfile_hadolint_docker_image', 'lukasmartinelli/hadolint')
|
||||||
|
|
||||||
function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort
|
function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort
|
||||||
" Matches patterns line the following:
|
" Matches patterns line the following:
|
||||||
"
|
"
|
||||||
@@ -10,7 +14,7 @@ function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort
|
|||||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
let l:lnum = 0
|
let l:lnum = 0
|
||||||
|
|
||||||
if l:match[1] !=# ''
|
if l:match[1] isnot# ''
|
||||||
let l:lnum = l:match[1] + 0
|
let l:lnum = l:match[1] + 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -29,9 +33,45 @@ function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort
|
|||||||
return l:output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" This is a little different than the typical 'executable' callback. We want
|
||||||
|
" to afford the user the chance to say always use docker, never use docker,
|
||||||
|
" and use docker if the hadolint executable is not present on the system.
|
||||||
|
"
|
||||||
|
" In the case of neither docker nor hadolint executables being present, it
|
||||||
|
" really doesn't matter which we return -- either will have the effect of
|
||||||
|
" 'nope, can't use this linter!'.
|
||||||
|
|
||||||
|
function! ale_linters#dockerfile#hadolint#GetExecutable(buffer) abort
|
||||||
|
let l:use_docker = ale#Var(a:buffer, 'dockerfile_hadolint_use_docker')
|
||||||
|
|
||||||
|
" check for mandatory directives
|
||||||
|
if l:use_docker is# 'never'
|
||||||
|
return 'hadolint'
|
||||||
|
elseif l:use_docker is# 'always'
|
||||||
|
return 'docker'
|
||||||
|
endif
|
||||||
|
|
||||||
|
" if we reach here, we want to use 'hadolint' if present...
|
||||||
|
if executable('hadolint')
|
||||||
|
return 'hadolint'
|
||||||
|
endif
|
||||||
|
|
||||||
|
"... and 'docker' as a fallback.
|
||||||
|
return 'docker'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#dockerfile#hadolint#GetCommand(buffer) abort
|
||||||
|
let l:command = ale_linters#dockerfile#hadolint#GetExecutable(a:buffer)
|
||||||
|
if l:command is# 'docker'
|
||||||
|
return 'docker run --rm -i ' . ale#Var(a:buffer, 'dockerfile_hadolint_docker_image')
|
||||||
|
endif
|
||||||
|
return 'hadolint -'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
call ale#linter#Define('dockerfile', {
|
call ale#linter#Define('dockerfile', {
|
||||||
\ 'name': 'hadolint',
|
\ 'name': 'hadolint',
|
||||||
\ 'executable': 'hadolint',
|
\ 'executable_callback': 'ale_linters#dockerfile#hadolint#GetExecutable',
|
||||||
\ 'command': 'hadolint -',
|
\ 'command_callback': 'ale_linters#dockerfile#hadolint#GetCommand',
|
||||||
\ 'callback': 'ale_linters#dockerfile#hadolint#Handle',
|
\ 'callback': 'ale_linters#dockerfile#hadolint#Handle',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ function! ale_linters#elixir#credo#Handle(buffer, lines) abort
|
|||||||
let l:type = l:match[3]
|
let l:type = l:match[3]
|
||||||
let l:text = l:match[4]
|
let l:text = l:match[4]
|
||||||
|
|
||||||
if l:type ==# 'C'
|
if l:type is# 'C'
|
||||||
let l:type = 'E'
|
let l:type = 'E'
|
||||||
elseif l:type ==# 'R'
|
elseif l:type is# 'R'
|
||||||
let l:type = 'W'
|
let l:type = 'W'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ function! ale_linters#elixir#dogma#Handle(buffer, lines) abort
|
|||||||
let l:type = l:match[3]
|
let l:type = l:match[3]
|
||||||
let l:text = l:match[4]
|
let l:text = l:match[4]
|
||||||
|
|
||||||
if l:type ==# 'C'
|
if l:type is# 'C'
|
||||||
let l:type = 'E'
|
let l:type = 'E'
|
||||||
elseif l:type ==# 'R'
|
elseif l:type is# 'R'
|
||||||
let l:type = 'W'
|
let l:type = 'W'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +1,46 @@
|
|||||||
" Author: buffalocoder - https://github.com/buffalocoder
|
" Author: buffalocoder - https://github.com/buffalocoder, soywod - https://github.com/soywod
|
||||||
" Description: Elm linting in Ale. Closely follows the Syntastic checker in https://github.com/ElmCast/elm-vim.
|
" Description: Elm linting in Ale. Closely follows the Syntastic checker in https://github.com/ElmCast/elm-vim.
|
||||||
|
|
||||||
|
call ale#Set('elm_make_executable', 'elm-make')
|
||||||
|
call ale#Set('elm_make_use_global', 0)
|
||||||
|
|
||||||
|
function! ale_linters#elm#make#GetExecutable(buffer) abort
|
||||||
|
return ale#node#FindExecutable(a:buffer, 'elm_make', [
|
||||||
|
\ 'node_modules/.bin/elm-make',
|
||||||
|
\])
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#elm#make#Handle(buffer, lines) abort
|
function! ale_linters#elm#make#Handle(buffer, lines) abort
|
||||||
let l:output = []
|
let l:output = []
|
||||||
let l:is_windows = has('win32')
|
let l:is_windows = has('win32')
|
||||||
let l:temp_dir = l:is_windows ? $TMP : $TMPDIR
|
let l:temp_dir = l:is_windows ? $TMP : $TMPDIR
|
||||||
let l:unparsed_lines = []
|
let l:unparsed_lines = []
|
||||||
for l:line in a:lines
|
for l:line in a:lines
|
||||||
if l:line[0] ==# '['
|
if l:line[0] is# '['
|
||||||
let l:errors = json_decode(l:line)
|
let l:errors = json_decode(l:line)
|
||||||
|
|
||||||
for l:error in l:errors
|
for l:error in l:errors
|
||||||
" Check if file is from the temp directory.
|
" Check if file is from the temp directory.
|
||||||
" Filters out any errors not related to the buffer.
|
" Filters out any errors not related to the buffer.
|
||||||
if l:is_windows
|
if l:is_windows
|
||||||
let l:file_is_buffer = l:error.file[0:len(l:temp_dir) - 1] ==? l:temp_dir
|
let l:file_is_buffer = l:error.file[0:len(l:temp_dir) - 1] is? l:temp_dir
|
||||||
else
|
else
|
||||||
let l:file_is_buffer = l:error.file[0:len(l:temp_dir) - 1] ==# l:temp_dir
|
let l:file_is_buffer = l:error.file[0:len(l:temp_dir) - 1] is# l:temp_dir
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if l:file_is_buffer
|
if l:file_is_buffer
|
||||||
call add(l:output, {
|
call add(l:output, {
|
||||||
\ 'lnum': l:error.region.start.line,
|
\ 'lnum': l:error.region.start.line,
|
||||||
\ 'col': l:error.region.start.column,
|
\ 'col': l:error.region.start.column,
|
||||||
\ 'type': (l:error.type ==? 'error') ? 'E' : 'W',
|
\ 'end_lnum': l:error.region.end.line,
|
||||||
|
\ 'end_col': l:error.region.end.column,
|
||||||
|
\ 'type': (l:error.type is? 'error') ? 'E' : 'W',
|
||||||
\ 'text': l:error.overview,
|
\ 'text': l:error.overview,
|
||||||
\ 'detail': l:error.overview . "\n\n" . l:error.details
|
\ 'detail': l:error.overview . "\n\n" . l:error.details
|
||||||
\})
|
\})
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
elseif l:line !=# 'Successfully generated /dev/null'
|
elseif l:line isnot# 'Successfully generated /dev/null'
|
||||||
call add(l:unparsed_lines, l:line)
|
call add(l:unparsed_lines, l:line)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@@ -50,6 +61,7 @@ endfunction
|
|||||||
" If it doesn't, then this will fail when imports are needed.
|
" If it doesn't, then this will fail when imports are needed.
|
||||||
function! ale_linters#elm#make#GetCommand(buffer) abort
|
function! ale_linters#elm#make#GetCommand(buffer) abort
|
||||||
let l:elm_package = ale#path#FindNearestFile(a:buffer, 'elm-package.json')
|
let l:elm_package = ale#path#FindNearestFile(a:buffer, 'elm-package.json')
|
||||||
|
let l:elm_exe = ale_linters#elm#make#GetExecutable(a:buffer)
|
||||||
if empty(l:elm_package)
|
if empty(l:elm_package)
|
||||||
let l:dir_set_cmd = ''
|
let l:dir_set_cmd = ''
|
||||||
else
|
else
|
||||||
@@ -59,16 +71,18 @@ function! ale_linters#elm#make#GetCommand(buffer) abort
|
|||||||
|
|
||||||
" The elm-make compiler, at the time of this writing, uses '/dev/null' as
|
" The elm-make compiler, at the time of this writing, uses '/dev/null' as
|
||||||
" a sort of flag to tell the compiler not to generate an output file,
|
" a sort of flag to tell the compiler not to generate an output file,
|
||||||
" which is why this is hard coded here.
|
" which is why this is hard coded here. It does not use NUL on Windows.
|
||||||
" Source: https://github.com/elm-lang/elm-make/blob/master/src/Flags.hs
|
" Source: https://github.com/elm-lang/elm-make/blob/master/src/Flags.hs
|
||||||
let l:elm_cmd = 'elm-make --report=json --output='.ale#Escape('/dev/null')
|
let l:elm_cmd = ale#Escape(l:elm_exe)
|
||||||
|
\ . ' --report=json'
|
||||||
|
\ . ' --output=/dev/null'
|
||||||
|
|
||||||
return l:dir_set_cmd . ' ' . l:elm_cmd . ' %t'
|
return l:dir_set_cmd . ' ' . l:elm_cmd . ' %t'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('elm', {
|
call ale#linter#Define('elm', {
|
||||||
\ 'name': 'make',
|
\ 'name': 'make',
|
||||||
\ 'executable': 'elm-make',
|
\ 'executable_callback': 'ale_linters#elm#make#GetExecutable',
|
||||||
\ 'output_stream': 'both',
|
\ 'output_stream': 'both',
|
||||||
\ 'command_callback': 'ale_linters#elm#make#GetCommand',
|
\ 'command_callback': 'ale_linters#elm#make#GetCommand',
|
||||||
\ 'callback': 'ale_linters#elm#make#Handle'
|
\ 'callback': 'ale_linters#elm#make#Handle'
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ function! ale_linters#erlang#erlc#Handle(buffer, lines) abort
|
|||||||
" error.erl:4: variable 'B' is unbound
|
" error.erl:4: variable 'B' is unbound
|
||||||
" error.erl:3: Warning: function main/0 is unused
|
" error.erl:3: Warning: function main/0 is unused
|
||||||
" error.erl:4: Warning: variable 'A' is unused
|
" error.erl:4: Warning: variable 'A' is unused
|
||||||
let l:pattern = '\v^([^:]+):(\d+): (Warning: )?(.+)$'
|
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+): (Warning: )?(.+)$'
|
||||||
|
|
||||||
" parse_transforms are a special case. The error message does not indicate a location:
|
" parse_transforms are a special case. The error message does not indicate a location:
|
||||||
" error.erl: undefined parse transform 'some_parse_transform'
|
" error.erl: undefined parse transform 'some_parse_transform'
|
||||||
@@ -27,7 +27,7 @@ function! ale_linters#erlang#erlc#Handle(buffer, lines) abort
|
|||||||
let l:pattern_no_module_definition = '\v(no module definition)$'
|
let l:pattern_no_module_definition = '\v(no module definition)$'
|
||||||
let l:pattern_unused = '\v(.* is unused)$'
|
let l:pattern_unused = '\v(.* is unused)$'
|
||||||
|
|
||||||
let l:is_hrl = fnamemodify(bufname(a:buffer), ':e') ==# 'hrl'
|
let l:is_hrl = fnamemodify(bufname(a:buffer), ':e') is# 'hrl'
|
||||||
|
|
||||||
for l:line in a:lines
|
for l:line in a:lines
|
||||||
let l:match = matchlist(l:line, l:pattern)
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|||||||
53
ale_linters/erlang/syntaxerl.vim
Normal file
53
ale_linters/erlang/syntaxerl.vim
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
" Author: Dmitri Vereshchagin <dmitri.vereshchagin@gmail.com>
|
||||||
|
" Description: SyntaxErl linter for Erlang files
|
||||||
|
|
||||||
|
call ale#Set('erlang_syntaxerl_executable', 'syntaxerl')
|
||||||
|
|
||||||
|
|
||||||
|
function! ale_linters#erlang#syntaxerl#GetExecutable(buffer) abort
|
||||||
|
return ale#Var(a:buffer, 'erlang_syntaxerl_executable')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! ale_linters#erlang#syntaxerl#FeatureCheck(buffer) abort
|
||||||
|
return s:GetEscapedExecutable(a:buffer) . ' -h'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! ale_linters#erlang#syntaxerl#GetCommand(buffer, output) abort
|
||||||
|
let l:use_b_option = match(a:output, '\C\V-b, --base\>') > -1
|
||||||
|
|
||||||
|
return s:GetEscapedExecutable(a:buffer) . (l:use_b_option ? ' -b %s %t' : ' %t')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! ale_linters#erlang#syntaxerl#Handle(buffer, lines) abort
|
||||||
|
let l:pattern = '\v\C:(\d+):( warning:)? (.+)'
|
||||||
|
let l:loclist = []
|
||||||
|
|
||||||
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
|
call add(l:loclist, {
|
||||||
|
\ 'lnum': l:match[1] + 0,
|
||||||
|
\ 'text': l:match[3],
|
||||||
|
\ 'type': empty(l:match[2]) ? 'E' : 'W',
|
||||||
|
\})
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return l:loclist
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! s:GetEscapedExecutable(buffer) abort
|
||||||
|
return ale#Escape(ale_linters#erlang#syntaxerl#GetExecutable(a:buffer))
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
call ale#linter#Define('erlang', {
|
||||||
|
\ 'name': 'syntaxerl',
|
||||||
|
\ 'executable_callback': 'ale_linters#erlang#syntaxerl#GetExecutable',
|
||||||
|
\ 'command_chain': [
|
||||||
|
\ {'callback': 'ale_linters#erlang#syntaxerl#FeatureCheck'},
|
||||||
|
\ {'callback': 'ale_linters#erlang#syntaxerl#GetCommand'},
|
||||||
|
\ ],
|
||||||
|
\ 'callback': 'ale_linters#erlang#syntaxerl#Handle',
|
||||||
|
\})
|
||||||
11
ale_linters/eruby/erubis.vim
Normal file
11
ale_linters/eruby/erubis.vim
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
" Author: Jake Zimmerman <jake@zimmerman.io>
|
||||||
|
" Description: eruby checker using `erubis`, instead of `erb`
|
||||||
|
|
||||||
|
call ale#linter#Define('eruby', {
|
||||||
|
\ 'name': 'erubis',
|
||||||
|
\ 'executable': 'erubis',
|
||||||
|
\ 'output_stream': 'stderr',
|
||||||
|
\ 'command': 'erubis -x %t | ruby -c',
|
||||||
|
\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
|
||||||
|
\})
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ function! ale_linters#fortran#gcc#Handle(buffer, lines) abort
|
|||||||
|
|
||||||
" Now we have the text, we can set it and add the error.
|
" Now we have the text, we can set it and add the error.
|
||||||
let l:last_loclist_obj.text = l:match[2]
|
let l:last_loclist_obj.text = l:match[2]
|
||||||
let l:last_loclist_obj.type = l:match[1] ==# 'Warning' ? 'W' : 'E'
|
let l:last_loclist_obj.type = l:match[1] is# 'Warning' ? 'W' : 'E'
|
||||||
call add(l:output, l:last_loclist_obj)
|
call add(l:output, l:last_loclist_obj)
|
||||||
else
|
else
|
||||||
let l:last_loclist_obj = {
|
let l:last_loclist_obj = {
|
||||||
|
|||||||
46
ale_linters/glsl/glslang.vim
Normal file
46
ale_linters/glsl/glslang.vim
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
" Author: Sven-Hendrik Haase <svenstaro@gmail.com>
|
||||||
|
" Description: glslang-based linter for glsl files
|
||||||
|
"
|
||||||
|
" TODO: Once https://github.com/KhronosGroup/glslang/pull/1047 is accepted,
|
||||||
|
" we can use stdin.
|
||||||
|
|
||||||
|
let g:ale_glsl_glslang_executable =
|
||||||
|
\ get(g:, 'ale_glsl_glslang_executable', 'glslangValidator')
|
||||||
|
|
||||||
|
let g:ale_glsl_glslang_options = get(g:, 'ale_glsl_glslang_options', '')
|
||||||
|
|
||||||
|
function! ale_linters#glsl#glslang#GetExecutable(buffer) abort
|
||||||
|
return ale#Var(a:buffer, 'glsl_glslang_executable')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#glsl#glslang#GetCommand(buffer) abort
|
||||||
|
return ale_linters#glsl#glslang#GetExecutable(a:buffer)
|
||||||
|
\ . ' ' . ale#Var(a:buffer, 'glsl_glslang_options')
|
||||||
|
\ . ' ' . '-C %t'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#glsl#glslang#Handle(buffer, lines) abort
|
||||||
|
" Matches patterns like the following:
|
||||||
|
"
|
||||||
|
" ERROR: 0:5: 'foo' : undeclared identifier
|
||||||
|
let l:pattern = '^\(.\+\): \(\d\+\):\(\d\+\): \(.\+\)'
|
||||||
|
let l:output = []
|
||||||
|
|
||||||
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
|
call add(l:output, {
|
||||||
|
\ 'lnum': str2nr(l:match[3]),
|
||||||
|
\ 'col': str2nr(l:match[2]),
|
||||||
|
\ 'text': l:match[4],
|
||||||
|
\ 'type': l:match[1] is# 'ERROR' ? 'E' : 'W',
|
||||||
|
\})
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return l:output
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('glsl', {
|
||||||
|
\ 'name': 'glslang',
|
||||||
|
\ 'executable_callback': 'ale_linters#glsl#glslang#GetExecutable',
|
||||||
|
\ 'command_callback': 'ale_linters#glsl#glslang#GetCommand',
|
||||||
|
\ 'callback': 'ale_linters#glsl#glslang#Handle',
|
||||||
|
\})
|
||||||
@@ -1,16 +1,22 @@
|
|||||||
" Author: Ben Reedy <https://github.com/breed808>
|
" Author: Ben Reedy <https://github.com/breed808>
|
||||||
" Description: Adds support for the gometalinter suite for Go files
|
" Description: Adds support for the gometalinter suite for Go files
|
||||||
|
|
||||||
if !exists('g:ale_go_gometalinter_options')
|
call ale#Set('go_gometalinter_options', '')
|
||||||
let g:ale_go_gometalinter_options = ''
|
call ale#Set('go_gometalinter_executable', 'gometalinter')
|
||||||
endif
|
|
||||||
|
function! ale_linters#go#gometalinter#GetExecutable(buffer) abort
|
||||||
|
return ale#Var(a:buffer, 'go_gometalinter_executable')
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#go#gometalinter#GetCommand(buffer) abort
|
function! ale_linters#go#gometalinter#GetCommand(buffer) abort
|
||||||
let l:filename = expand('#' . a:buffer . ':p')
|
let l:executable = ale_linters#go#gometalinter#GetExecutable(a:buffer)
|
||||||
|
let l:filename = expand('#' . a:buffer)
|
||||||
|
let l:options = ale#Var(a:buffer, 'go_gometalinter_options')
|
||||||
|
|
||||||
return 'gometalinter --include=''^' . l:filename . '.*$'' '
|
return ale#Escape(l:executable)
|
||||||
\ . ale#Var(a:buffer, 'go_gometalinter_options')
|
\ . ' --include=' . ale#Escape('^' . ale#util#EscapePCRE(l:filename))
|
||||||
\ . ' ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
|
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||||
|
\ . ' ' . ale#Escape(fnamemodify(l:filename, ':h'))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#go#gometalinter#GetMatches(lines) abort
|
function! ale_linters#go#gometalinter#GetMatches(lines) abort
|
||||||
@@ -26,7 +32,7 @@ function! ale_linters#go#gometalinter#Handler(buffer, lines) abort
|
|||||||
call add(l:output, {
|
call add(l:output, {
|
||||||
\ 'lnum': l:match[2] + 0,
|
\ 'lnum': l:match[2] + 0,
|
||||||
\ 'col': l:match[3] + 0,
|
\ 'col': l:match[3] + 0,
|
||||||
\ 'type': tolower(l:match[4]) ==# 'warning' ? 'W' : 'E',
|
\ 'type': tolower(l:match[4]) is# 'warning' ? 'W' : 'E',
|
||||||
\ 'text': l:match[5],
|
\ 'text': l:match[5],
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
@@ -36,7 +42,7 @@ endfunction
|
|||||||
|
|
||||||
call ale#linter#Define('go', {
|
call ale#linter#Define('go', {
|
||||||
\ 'name': 'gometalinter',
|
\ 'name': 'gometalinter',
|
||||||
\ 'executable': 'gometalinter',
|
\ 'executable_callback': 'ale_linters#go#gometalinter#GetExecutable',
|
||||||
\ 'command_callback': 'ale_linters#go#gometalinter#GetCommand',
|
\ 'command_callback': 'ale_linters#go#gometalinter#GetCommand',
|
||||||
\ 'callback': 'ale_linters#go#gometalinter#Handler',
|
\ 'callback': 'ale_linters#go#gometalinter#Handler',
|
||||||
\ 'lint_file': 1,
|
\ 'lint_file': 1,
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
call ale#linter#Define('go', {
|
call ale#linter#Define('go', {
|
||||||
\ 'name': 'gosimple',
|
\ 'name': 'gosimple',
|
||||||
\ 'executable': 'gosimple',
|
\ 'executable': 'gosimple',
|
||||||
\ 'command': 'gosimple %t',
|
\ 'command': 'gosimple %s',
|
||||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||||
|
\ 'output_stream': 'both',
|
||||||
|
\ 'lint_file': 1,
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
call ale#linter#Define('go', {
|
call ale#linter#Define('go', {
|
||||||
\ 'name': 'staticcheck',
|
\ 'name': 'staticcheck',
|
||||||
\ 'executable': 'staticcheck',
|
\ 'executable': 'staticcheck',
|
||||||
\ 'command': 'staticcheck %t',
|
\ 'command': 'staticcheck %s',
|
||||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||||
|
\ 'output_stream': 'both',
|
||||||
|
\ 'lint_file': 1,
|
||||||
\})
|
\})
|
||||||
|
|||||||
9
ale_linters/graphql/gqlint.vim
Normal file
9
ale_linters/graphql/gqlint.vim
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
" Author: Michiel Westerbeek <happylinks@gmail.com>
|
||||||
|
" Description: Linter for GraphQL Schemas
|
||||||
|
|
||||||
|
call ale#linter#Define('graphql', {
|
||||||
|
\ 'name': 'gqlint',
|
||||||
|
\ 'executable': 'gqlint',
|
||||||
|
\ 'command': 'gqlint --reporter=simple %t',
|
||||||
|
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||||
|
\})
|
||||||
@@ -16,16 +16,10 @@ function! ale_linters#handlebars#embertemplatelint#GetCommand(buffer) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#handlebars#embertemplatelint#Handle(buffer, lines) abort
|
function! ale_linters#handlebars#embertemplatelint#Handle(buffer, lines) abort
|
||||||
if len(a:lines) == 0
|
|
||||||
return []
|
|
||||||
endif
|
|
||||||
|
|
||||||
let l:output = []
|
let l:output = []
|
||||||
|
let l:json = ale#util#FuzzyJSONDecode(a:lines, {})
|
||||||
|
|
||||||
let l:input_json = json_decode(join(a:lines, ''))
|
for l:error in get(values(l:json), 0, [])
|
||||||
let l:file_errors = values(l:input_json)[0]
|
|
||||||
|
|
||||||
for l:error in l:file_errors
|
|
||||||
if has_key(l:error, 'fatal')
|
if has_key(l:error, 'fatal')
|
||||||
call add(l:output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'bufnr': a:buffer,
|
||||||
|
|||||||
@@ -4,13 +4,13 @@
|
|||||||
call ale#linter#Define('haskell', {
|
call ale#linter#Define('haskell', {
|
||||||
\ 'name': 'ghc-mod',
|
\ 'name': 'ghc-mod',
|
||||||
\ 'executable': 'ghc-mod',
|
\ 'executable': 'ghc-mod',
|
||||||
\ 'command': 'ghc-mod check %t',
|
\ 'command': 'ghc-mod --map-file %s=%t check %s',
|
||||||
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
|
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
|
||||||
\})
|
\})
|
||||||
|
|
||||||
call ale#linter#Define('haskell', {
|
call ale#linter#Define('haskell', {
|
||||||
\ 'name': 'stack-ghc-mod',
|
\ 'name': 'stack-ghc-mod',
|
||||||
\ 'executable': 'stack',
|
\ 'executable': 'stack',
|
||||||
\ 'command': 'stack exec ghc-mod check %t',
|
\ 'command': 'stack exec ghc-mod -- --map-file %s=%t check %s',
|
||||||
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
|
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -8,11 +8,3 @@ call ale#linter#Define('haskell', {
|
|||||||
\ 'command': 'ghc -fno-code -v0 %t',
|
\ 'command': 'ghc -fno-code -v0 %t',
|
||||||
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
|
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
|
||||||
\})
|
\})
|
||||||
|
|
||||||
call ale#linter#Define('haskell', {
|
|
||||||
\ 'name': 'stack-ghc',
|
|
||||||
\ 'output_stream': 'stderr',
|
|
||||||
\ 'executable': 'stack',
|
|
||||||
\ 'command': 'stack ghc -- -fno-code -v0 %t',
|
|
||||||
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
|
|
||||||
\})
|
|
||||||
|
|||||||
@@ -1,9 +1,22 @@
|
|||||||
" Author: rob-b
|
" Author: rob-b, Takano Akio <tak@anoak.io>
|
||||||
" Description: hdevtools for Haskell files
|
" Description: hdevtools for Haskell files
|
||||||
|
|
||||||
|
call ale#Set('haskell_hdevtools_executable', 'hdevtools')
|
||||||
|
call ale#Set('haskell_hdevtools_options', '-g -Wall')
|
||||||
|
|
||||||
|
function! ale_linters#haskell#hdevtools#GetExecutable(buffer) abort
|
||||||
|
return ale#Var(a:buffer, 'haskell_hdevtools_executable')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#haskell#hdevtools#GetCommand(buffer) abort
|
||||||
|
return ale#Escape(ale_linters#haskell#hdevtools#GetExecutable(a:buffer))
|
||||||
|
\ . ' check ' . ale#Var(a:buffer, 'haskell_hdevtools_options')
|
||||||
|
\ . ' -p %s %t'
|
||||||
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('haskell', {
|
call ale#linter#Define('haskell', {
|
||||||
\ 'name': 'hdevtools',
|
\ 'name': 'hdevtools',
|
||||||
\ 'executable': 'hdevtools',
|
\ 'executable_callback': 'ale_linters#haskell#hdevtools#GetExecutable',
|
||||||
\ 'command': 'hdevtools check -g -Wall -p %s %t',
|
\ 'command_callback': 'ale_linters#haskell#hdevtools#GetCommand',
|
||||||
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
|
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -2,17 +2,24 @@
|
|||||||
" Description: hlint for Haskell files
|
" Description: hlint for Haskell files
|
||||||
|
|
||||||
function! ale_linters#haskell#hlint#Handle(buffer, lines) abort
|
function! ale_linters#haskell#hlint#Handle(buffer, lines) abort
|
||||||
let l:errors = json_decode(join(a:lines, ''))
|
|
||||||
|
|
||||||
let l:output = []
|
let l:output = []
|
||||||
|
|
||||||
for l:error in l:errors
|
for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
|
||||||
|
if l:error.severity is# 'Error'
|
||||||
|
let l:type = 'E'
|
||||||
|
elseif l:error.severity is# 'Suggestion'
|
||||||
|
let l:type = 'I'
|
||||||
|
else
|
||||||
|
let l:type = 'W'
|
||||||
|
endif
|
||||||
|
|
||||||
call add(l:output, {
|
call add(l:output, {
|
||||||
\ 'bufnr': a:buffer,
|
\ 'lnum': str2nr(l:error.startLine),
|
||||||
\ 'lnum': l:error.startLine + 0,
|
\ 'col': str2nr(l:error.startColumn),
|
||||||
\ 'col': l:error.startColumn + 0,
|
\ 'end_lnum': str2nr(l:error.endLine),
|
||||||
|
\ 'end_col': str2nr(l:error.endColumn),
|
||||||
\ 'text': l:error.severity . ': ' . l:error.hint . '. Found: ' . l:error.from . ' Why not: ' . l:error.to,
|
\ 'text': l:error.severity . ': ' . l:error.hint . '. Found: ' . l:error.from . ' Why not: ' . l:error.to,
|
||||||
\ 'type': l:error.severity ==# 'Error' ? 'E' : 'W',
|
\ 'type': l:type,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
|||||||
22
ale_linters/haskell/stack_build.vim
Normal file
22
ale_linters/haskell/stack_build.vim
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
" Author: Jake Zimmerman <jake@zimmerman.io>
|
||||||
|
" Description: Like stack-ghc, but for entire projects
|
||||||
|
"
|
||||||
|
" Note: Ideally, this would *only* typecheck. Right now, it also does codegen.
|
||||||
|
" See <https://github.com/commercialhaskell/stack/issues/977>.
|
||||||
|
|
||||||
|
call ale#Set('haskell_stack_build_options', '--fast')
|
||||||
|
|
||||||
|
function! ale_linters#haskell#stack_build#GetCommand(buffer) abort
|
||||||
|
let l:flags = ale#Var(a:buffer, 'haskell_stack_build_options')
|
||||||
|
|
||||||
|
return 'stack build ' . l:flags
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('haskell', {
|
||||||
|
\ 'name': 'stack-build',
|
||||||
|
\ 'output_stream': 'stderr',
|
||||||
|
\ 'executable': 'stack',
|
||||||
|
\ 'command_callback': 'ale_linters#haskell#stack_build#GetCommand',
|
||||||
|
\ 'lint_file': 1,
|
||||||
|
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
|
||||||
|
\})
|
||||||
10
ale_linters/haskell/stack_ghc.vim
Normal file
10
ale_linters/haskell/stack_ghc.vim
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
" Author: w0rp <devw0rp@gmail.com>
|
||||||
|
" Description: ghc for Haskell files, using Stack
|
||||||
|
|
||||||
|
call ale#linter#Define('haskell', {
|
||||||
|
\ 'name': 'stack-ghc',
|
||||||
|
\ 'output_stream': 'stderr',
|
||||||
|
\ 'executable': 'stack',
|
||||||
|
\ 'command': 'stack ghc -- -fno-code -v0 %t',
|
||||||
|
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
|
||||||
|
\})
|
||||||
@@ -46,7 +46,7 @@ function! ale_linters#html#tidy#Handle(buffer, lines) abort
|
|||||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
let l:line = l:match[1] + 0
|
let l:line = l:match[1] + 0
|
||||||
let l:col = l:match[2] + 0
|
let l:col = l:match[2] + 0
|
||||||
let l:type = l:match[3] ==# 'Error' ? 'E' : 'W'
|
let l:type = l:match[3] is# 'Error' ? 'E' : 'W'
|
||||||
let l:text = l:match[4]
|
let l:text = l:match[4]
|
||||||
|
|
||||||
call add(l:output, {
|
call add(l:output, {
|
||||||
|
|||||||
87
ale_linters/idris/idris.vim
Normal file
87
ale_linters/idris/idris.vim
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
" Author: Scott Bonds <scott@ggr.com>
|
||||||
|
" Description: default Idris compiler
|
||||||
|
|
||||||
|
call ale#Set('idris_idris_executable', 'idris')
|
||||||
|
call ale#Set('idris_idris_options', '--total --warnpartial --warnreach --warnipkg')
|
||||||
|
|
||||||
|
function! ale_linters#idris#idris#GetExecutable(buffer) abort
|
||||||
|
return ale#Var(a:buffer, 'idris_idris_executable')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#idris#idris#GetCommand(buffer) abort
|
||||||
|
let l:options = ale#Var(a:buffer, 'idris_idris_options')
|
||||||
|
|
||||||
|
return ale#Escape(ale_linters#idris#idris#GetExecutable(a:buffer))
|
||||||
|
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||||
|
\ . ' --check %s'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#idris#idris#Handle(buffer, lines) abort
|
||||||
|
" This was copied almost verbatim from ale#handlers#haskell#HandleGHCFormat
|
||||||
|
|
||||||
|
" Look for lines like the following:
|
||||||
|
" foo.idr:2:6:When checking right hand side of main with expected type
|
||||||
|
" bar.idr:11:11-13:
|
||||||
|
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+)(-\d+)?:(.*)?$'
|
||||||
|
let l:output = []
|
||||||
|
|
||||||
|
let l:corrected_lines = []
|
||||||
|
|
||||||
|
for l:line in a:lines
|
||||||
|
if len(matchlist(l:line, l:pattern)) > 0
|
||||||
|
call add(l:corrected_lines, l:line)
|
||||||
|
elseif len(l:corrected_lines) > 0
|
||||||
|
if l:line is# ''
|
||||||
|
let l:corrected_lines[-1] .= ' ' " turn a blank line into a space
|
||||||
|
else
|
||||||
|
let l:corrected_lines[-1] .= l:line
|
||||||
|
endif
|
||||||
|
let l:corrected_lines[-1] = substitute(l:corrected_lines[-1], '\s\+', ' ', 'g')
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
|
||||||
|
for l:line in l:corrected_lines
|
||||||
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
|
if len(l:match) == 0
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !ale#path#IsBufferPath(a:buffer, l:match[1])
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:errors = matchlist(l:match[5], '\v([wW]arning|[eE]rror) - ?(.*)')
|
||||||
|
|
||||||
|
if len(l:errors) > 0
|
||||||
|
let l:ghc_type = l:errors[1]
|
||||||
|
let l:text = l:errors[2]
|
||||||
|
else
|
||||||
|
let l:ghc_type = ''
|
||||||
|
let l:text = l:match[5][:0] is# ' ' ? l:match[5][1:] : l:match[5]
|
||||||
|
endif
|
||||||
|
|
||||||
|
if l:ghc_type is? 'Warning'
|
||||||
|
let l:type = 'W'
|
||||||
|
else
|
||||||
|
let l:type = 'E'
|
||||||
|
endif
|
||||||
|
|
||||||
|
call add(l:output, {
|
||||||
|
\ 'lnum': l:match[2] + 0,
|
||||||
|
\ 'col': l:match[3] + 0,
|
||||||
|
\ 'text': l:text,
|
||||||
|
\ 'type': l:type,
|
||||||
|
\})
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return l:output
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('idris', {
|
||||||
|
\ 'name': 'idris',
|
||||||
|
\ 'executable_callback': 'ale_linters#idris#idris#GetExecutable',
|
||||||
|
\ 'command_callback': 'ale_linters#idris#idris#GetCommand',
|
||||||
|
\ 'callback': 'ale_linters#idris#idris#Handle',
|
||||||
|
\})
|
||||||
|
|
||||||
@@ -14,6 +14,11 @@ function! ale_linters#java#javac#GetImportPaths(buffer) abort
|
|||||||
\ . 'mvn dependency:build-classpath'
|
\ . 'mvn dependency:build-classpath'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let l:classpath_command = ale#gradle#BuildClasspathCommand(a:buffer)
|
||||||
|
if !empty(l:classpath_command)
|
||||||
|
return l:classpath_command
|
||||||
|
endif
|
||||||
|
|
||||||
return ''
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -44,7 +49,10 @@ function! ale_linters#java#javac#GetCommand(buffer, import_paths) abort
|
|||||||
" Create .class files in a temporary directory, which we will delete later.
|
" Create .class files in a temporary directory, which we will delete later.
|
||||||
let l:class_file_directory = ale#engine#CreateDirectory(a:buffer)
|
let l:class_file_directory = ale#engine#CreateDirectory(a:buffer)
|
||||||
|
|
||||||
return 'javac -Xlint'
|
" Always run javac from the directory the file is in, so we can resolve
|
||||||
|
" relative paths correctly.
|
||||||
|
return ale#path#BufferCdString(a:buffer)
|
||||||
|
\ . 'javac -Xlint'
|
||||||
\ . ' ' . l:cp_option
|
\ . ' ' . l:cp_option
|
||||||
\ . ' ' . l:sp_option
|
\ . ' ' . l:sp_option
|
||||||
\ . ' -d ' . ale#Escape(l:class_file_directory)
|
\ . ' -d ' . ale#Escape(l:class_file_directory)
|
||||||
@@ -58,24 +66,26 @@ function! ale_linters#java#javac#Handle(buffer, lines) abort
|
|||||||
" Main.java:13: warning: [deprecation] donaught() in Testclass has been deprecated
|
" Main.java:13: warning: [deprecation] donaught() in Testclass has been deprecated
|
||||||
" Main.java:16: error: ';' expected
|
" Main.java:16: error: ';' expected
|
||||||
|
|
||||||
let l:pattern = '\v^.*:(\d+): (.+):(.+)$'
|
let l:directory = expand('#' . a:buffer . ':p:h')
|
||||||
|
let l:pattern = '\v^(.*):(\d+): (.+):(.+)$'
|
||||||
let l:col_pattern = '\v^(\s*\^)$'
|
let l:col_pattern = '\v^(\s*\^)$'
|
||||||
let l:symbol_pattern = '\v^ +symbol: *(class|method) +([^ ]+)'
|
let l:symbol_pattern = '\v^ +symbol: *(class|method) +([^ ]+)'
|
||||||
let l:output = []
|
let l:output = []
|
||||||
|
|
||||||
for l:match in ale#util#GetMatches(a:lines, [l:pattern, l:col_pattern, l:symbol_pattern])
|
for l:match in ale#util#GetMatches(a:lines, [l:pattern, l:col_pattern, l:symbol_pattern])
|
||||||
if empty(l:match[2]) && empty(l:match[3])
|
if empty(l:match[2]) && empty(l:match[3])
|
||||||
let l:output[-1].col = len(l:match[1])
|
let l:output[-1].col = len(l:match[1])
|
||||||
elseif empty(l:match[3])
|
elseif empty(l:match[3])
|
||||||
" Add symbols to 'cannot find symbol' errors.
|
" Add symbols to 'cannot find symbol' errors.
|
||||||
if l:output[-1].text ==# 'error: cannot find symbol'
|
if l:output[-1].text is# 'error: cannot find symbol'
|
||||||
let l:output[-1].text .= ': ' . l:match[2]
|
let l:output[-1].text .= ': ' . l:match[2]
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
call add(l:output, {
|
call add(l:output, {
|
||||||
\ 'lnum': l:match[1] + 0,
|
\ 'filename': ale#path#GetAbsPath(l:directory, l:match[1]),
|
||||||
\ 'text': l:match[2] . ':' . l:match[3],
|
\ 'lnum': l:match[2] + 0,
|
||||||
\ 'type': l:match[2] ==# 'error' ? 'E' : 'W',
|
\ 'text': l:match[3] . ':' . l:match[4],
|
||||||
|
\ 'type': l:match[3] is# 'error' ? 'E' : 'W',
|
||||||
\})
|
\})
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|||||||
@@ -10,7 +10,12 @@ function! ale_linters#javascript#flow#GetExecutable(buffer) abort
|
|||||||
\])
|
\])
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#javascript#flow#GetCommand(buffer) abort
|
function! ale_linters#javascript#flow#VersionCheck(buffer) abort
|
||||||
|
return ale#Escape(ale_linters#javascript#flow#GetExecutable(a:buffer))
|
||||||
|
\ . ' --version'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#javascript#flow#GetCommand(buffer, version_lines) abort
|
||||||
let l:flow_config = ale#path#FindNearestFile(a:buffer, '.flowconfig')
|
let l:flow_config = ale#path#FindNearestFile(a:buffer, '.flowconfig')
|
||||||
|
|
||||||
if empty(l:flow_config)
|
if empty(l:flow_config)
|
||||||
@@ -18,14 +23,43 @@ function! ale_linters#javascript#flow#GetCommand(buffer) abort
|
|||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let l:use_respect_pragma = 1
|
||||||
|
|
||||||
|
" If we can parse the version number, then only use --respect-pragma
|
||||||
|
" if the version is >= 0.36.0, which added the argument.
|
||||||
|
for l:match in ale#util#GetMatches(a:version_lines, '\v\d+\.\d+\.\d+$')
|
||||||
|
let l:use_respect_pragma = ale#semver#GreaterOrEqual(
|
||||||
|
\ ale#semver#Parse(l:match[0]),
|
||||||
|
\ [0, 36, 0]
|
||||||
|
\)
|
||||||
|
endfor
|
||||||
|
|
||||||
return ale#Escape(ale_linters#javascript#flow#GetExecutable(a:buffer))
|
return ale#Escape(ale_linters#javascript#flow#GetExecutable(a:buffer))
|
||||||
\ . ' check-contents --respect-pragma --json --from ale %s'
|
\ . ' check-contents'
|
||||||
|
\ . (l:use_respect_pragma ? ' --respect-pragma': '')
|
||||||
|
\ . ' --json --from ale %s'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Filter lines of flow output until we find the first line where the JSON
|
||||||
|
" output starts.
|
||||||
|
function! s:GetJSONLines(lines) abort
|
||||||
|
let l:start_index = 0
|
||||||
|
|
||||||
|
for l:line in a:lines
|
||||||
|
if l:line[:0] is# '{'
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:start_index += 1
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return a:lines[l:start_index :]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#javascript#flow#Handle(buffer, lines) abort
|
function! ale_linters#javascript#flow#Handle(buffer, lines) abort
|
||||||
let l:str = join(a:lines, '')
|
let l:str = join(s:GetJSONLines(a:lines), '')
|
||||||
|
|
||||||
if l:str ==# ''
|
if empty(l:str)
|
||||||
return []
|
return []
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -43,13 +77,13 @@ function! ale_linters#javascript#flow#Handle(buffer, lines) abort
|
|||||||
" In certain cases, `l:message.loc.source` points to a different path
|
" In certain cases, `l:message.loc.source` points to a different path
|
||||||
" than the buffer one, thus we skip this loc information too.
|
" than the buffer one, thus we skip this loc information too.
|
||||||
if has_key(l:message, 'loc')
|
if has_key(l:message, 'loc')
|
||||||
\&& l:line ==# 0
|
\&& l:line is# 0
|
||||||
\&& ale#path#IsBufferPath(a:buffer, l:message.loc.source)
|
\&& ale#path#IsBufferPath(a:buffer, l:message.loc.source)
|
||||||
let l:line = l:message.loc.start.line + 0
|
let l:line = l:message.loc.start.line + 0
|
||||||
let l:col = l:message.loc.start.column + 0
|
let l:col = l:message.loc.start.column + 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if l:text ==# ''
|
if l:text is# ''
|
||||||
let l:text = l:message.descr . ':'
|
let l:text = l:message.descr . ':'
|
||||||
else
|
else
|
||||||
let l:text = l:text . ' ' . l:message.descr
|
let l:text = l:text . ' ' . l:message.descr
|
||||||
@@ -64,7 +98,7 @@ function! ale_linters#javascript#flow#Handle(buffer, lines) abort
|
|||||||
\ 'lnum': l:line,
|
\ 'lnum': l:line,
|
||||||
\ 'col': l:col,
|
\ 'col': l:col,
|
||||||
\ 'text': l:text,
|
\ 'text': l:text,
|
||||||
\ 'type': l:error.level ==# 'error' ? 'E' : 'W',
|
\ 'type': l:error.level is# 'error' ? 'E' : 'W',
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
@@ -74,6 +108,10 @@ endfunction
|
|||||||
call ale#linter#Define('javascript', {
|
call ale#linter#Define('javascript', {
|
||||||
\ 'name': 'flow',
|
\ 'name': 'flow',
|
||||||
\ 'executable_callback': 'ale_linters#javascript#flow#GetExecutable',
|
\ 'executable_callback': 'ale_linters#javascript#flow#GetExecutable',
|
||||||
\ 'command_callback': 'ale_linters#javascript#flow#GetCommand',
|
\ 'command_chain': [
|
||||||
|
\ {'callback': 'ale_linters#javascript#flow#VersionCheck'},
|
||||||
|
\ {'callback': 'ale_linters#javascript#flow#GetCommand'},
|
||||||
|
\ ],
|
||||||
\ 'callback': 'ale_linters#javascript#flow#Handle',
|
\ 'callback': 'ale_linters#javascript#flow#Handle',
|
||||||
|
\ 'add_newline': !has('win32'),
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -1,9 +1,63 @@
|
|||||||
" Author: Chris Kyrouac - https://github.com/fijshion
|
" Author: Chris Kyrouac - https://github.com/fijshion
|
||||||
" Description: jscs for JavaScript files
|
" Description: jscs for JavaScript files
|
||||||
|
|
||||||
|
call ale#Set('javascript_jscs_executable', 'jscs')
|
||||||
|
call ale#Set('javascript_jscs_use_global', 0)
|
||||||
|
|
||||||
|
function! ale_linters#javascript#jscs#GetExecutable(buffer) abort
|
||||||
|
return ale#node#FindExecutable(a:buffer, 'javascript_jscs', [
|
||||||
|
\ 'node_modules/.bin/jscs',
|
||||||
|
\])
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#javascript#jscs#GetCommand(buffer) abort
|
||||||
|
" Search for a local JShint config locaation, and default to a global one.
|
||||||
|
let l:jscs_config = ale#path#ResolveLocalPath(
|
||||||
|
\ a:buffer,
|
||||||
|
\ '.jscsrc',
|
||||||
|
\ get(g:, 'ale_jscs_config_loc', '')
|
||||||
|
\)
|
||||||
|
|
||||||
|
let l:command = ale#Escape(ale_linters#javascript#jscs#GetExecutable(a:buffer))
|
||||||
|
let l:command .= ' --reporter inline --no-colors'
|
||||||
|
|
||||||
|
if !empty(l:jscs_config)
|
||||||
|
let l:command .= ' --config ' . ale#Escape(l:jscs_config)
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:command .= ' -'
|
||||||
|
|
||||||
|
return l:command
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#javascript#jscs#Handle(buffer, lines) abort
|
||||||
|
" Matches patterns looking like the following
|
||||||
|
"
|
||||||
|
" foobar.js: line 2, col 1, Expected indentation of 1 characters
|
||||||
|
"
|
||||||
|
let l:pattern = '^.*:\s\+line \(\d\+\),\s\+col\s\+\(\d\+\),\s\+\(.*\)$'
|
||||||
|
let l:output = []
|
||||||
|
let l:m = ale#util#GetMatches(a:lines, [l:pattern])
|
||||||
|
|
||||||
|
for l:match in l:m
|
||||||
|
let l:text = l:match[3]
|
||||||
|
|
||||||
|
let l:obj = {
|
||||||
|
\ 'lnum': l:match[1] + 0,
|
||||||
|
\ 'col': l:match[2] + 0,
|
||||||
|
\ 'text': l:match[3]
|
||||||
|
\}
|
||||||
|
|
||||||
|
call add(l:output, l:obj)
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return l:output
|
||||||
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('javascript', {
|
call ale#linter#Define('javascript', {
|
||||||
\ 'name': 'jscs',
|
\ 'name': 'jscs',
|
||||||
\ 'executable': 'jscs',
|
\ 'executable_callback': 'ale_linters#javascript#jscs#GetExecutable',
|
||||||
\ 'command': 'jscs -r unix -n -',
|
\ 'command_callback': 'ale_linters#javascript#jscs#GetCommand',
|
||||||
\ 'callback': 'ale#handlers#unix#HandleAsError',
|
\ 'callback': 'ale_linters#javascript#jscs#Handle',
|
||||||
\})
|
\})
|
||||||
|
|
||||||
|
|||||||
@@ -7,13 +7,17 @@ call ale#Set('javascript_standard_options', '')
|
|||||||
|
|
||||||
function! ale_linters#javascript#standard#GetExecutable(buffer) abort
|
function! ale_linters#javascript#standard#GetExecutable(buffer) abort
|
||||||
return ale#node#FindExecutable(a:buffer, 'javascript_standard', [
|
return ale#node#FindExecutable(a:buffer, 'javascript_standard', [
|
||||||
|
\ 'node_modules/standard/bin/cmd.js',
|
||||||
\ 'node_modules/.bin/standard',
|
\ 'node_modules/.bin/standard',
|
||||||
\])
|
\])
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#javascript#standard#GetCommand(buffer) abort
|
function! ale_linters#javascript#standard#GetCommand(buffer) abort
|
||||||
return ale#Escape(ale_linters#javascript#standard#GetExecutable(a:buffer))
|
let l:executable = ale_linters#javascript#standard#GetExecutable(a:buffer)
|
||||||
\ . ' ' . ale#Var(a:buffer, 'javascript_standard_options')
|
let l:options = ale#Var(a:buffer, 'javascript_standard_options')
|
||||||
|
|
||||||
|
return ale#node#Executable(a:buffer, l:executable)
|
||||||
|
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||||
\ . ' --stdin %s'
|
\ . ' --stdin %s'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
@@ -12,17 +12,21 @@ let g:ale_kotlin_kotlinc_module_filename = get(g:, 'ale_kotlin_kotlinc_module_fi
|
|||||||
let s:classpath_sep = has('unix') ? ':' : ';'
|
let s:classpath_sep = has('unix') ? ':' : ';'
|
||||||
|
|
||||||
function! ale_linters#kotlin#kotlinc#GetImportPaths(buffer) abort
|
function! ale_linters#kotlin#kotlinc#GetImportPaths(buffer) abort
|
||||||
" exec maven only if classpath is not set
|
" exec maven/gradle only if classpath is not set
|
||||||
if ale#Var(a:buffer, 'kotlin_kotlinc_classpath') !=# ''
|
if ale#Var(a:buffer, 'kotlin_kotlinc_classpath') isnot# ''
|
||||||
return ''
|
return ''
|
||||||
else
|
else
|
||||||
let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml')
|
let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml')
|
||||||
|
|
||||||
if !empty(l:pom_path) && executable('mvn')
|
if !empty(l:pom_path) && executable('mvn')
|
||||||
return ale#path#CdString(fnamemodify(l:pom_path, ':h'))
|
return ale#path#CdString(fnamemodify(l:pom_path, ':h'))
|
||||||
\ . 'mvn dependency:build-classpath'
|
\ . 'mvn dependency:build-classpath'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let l:classpath_command = ale#gradle#BuildClasspathCommand(a:buffer)
|
||||||
|
if !empty(l:classpath_command)
|
||||||
|
return l:classpath_command
|
||||||
|
endif
|
||||||
|
|
||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@@ -66,19 +70,27 @@ function! ale_linters#kotlin#kotlinc#GetCommand(buffer, import_paths) abort
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" We only get here if not using module or the module file not readable
|
" We only get here if not using module or the module file not readable
|
||||||
if ale#Var(a:buffer, 'kotlin_kotlinc_classpath') !=# ''
|
if ale#Var(a:buffer, 'kotlin_kotlinc_classpath') isnot# ''
|
||||||
let l:kotlinc_opts .= ' -cp ' . ale#Var(a:buffer, 'kotlin_kotlinc_classpath')
|
let l:kotlinc_opts .= ' -cp ' . ale#Var(a:buffer, 'kotlin_kotlinc_classpath')
|
||||||
else
|
else
|
||||||
" get classpath from maven
|
" get classpath from maven/gradle
|
||||||
let l:kotlinc_opts .= s:BuildClassPathOption(a:buffer, a:import_paths)
|
let l:kotlinc_opts .= s:BuildClassPathOption(a:buffer, a:import_paths)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let l:fname = ''
|
let l:fname = ''
|
||||||
if ale#Var(a:buffer, 'kotlin_kotlinc_sourcepath') !=# ''
|
if ale#Var(a:buffer, 'kotlin_kotlinc_sourcepath') isnot# ''
|
||||||
let l:fname .= expand(ale#Var(a:buffer, 'kotlin_kotlinc_sourcepath'), 1) . ' '
|
let l:fname .= expand(ale#Var(a:buffer, 'kotlin_kotlinc_sourcepath'), 1) . ' '
|
||||||
else
|
else
|
||||||
" Find the src directory for files in this project.
|
" Find the src directory for files in this project.
|
||||||
let l:src_dir = ale#path#FindNearestDirectory(a:buffer, 'src/main/java')
|
|
||||||
|
let l:project_root = ale#gradle#FindProjectRoot(a:buffer)
|
||||||
|
if !empty(l:project_root)
|
||||||
|
let l:src_dir = l:project_root
|
||||||
|
else
|
||||||
|
let l:src_dir = ale#path#FindNearestDirectory(a:buffer, 'src/main/java')
|
||||||
|
\ . ' ' . ale#path#FindNearestDirectory(a:buffer, 'src/main/kotlin')
|
||||||
|
endif
|
||||||
|
|
||||||
let l:fname .= expand(l:src_dir, 1) . ' '
|
let l:fname .= expand(l:src_dir, 1) . ' '
|
||||||
endif
|
endif
|
||||||
let l:fname .= ale#Escape(expand('#' . a:buffer . ':p'))
|
let l:fname .= ale#Escape(expand('#' . a:buffer . ':p'))
|
||||||
@@ -109,10 +121,10 @@ function! ale_linters#kotlin#kotlinc#Handle(buffer, lines) abort
|
|||||||
let l:curbuf_abspath = expand('#' . a:buffer . ':p')
|
let l:curbuf_abspath = expand('#' . a:buffer . ':p')
|
||||||
|
|
||||||
" Skip if file is not loaded
|
" Skip if file is not loaded
|
||||||
if l:buf_abspath !=# l:curbuf_abspath
|
if l:buf_abspath isnot# l:curbuf_abspath
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
let l:type_marker_str = l:type ==# 'warning' ? 'W' : 'E'
|
let l:type_marker_str = l:type is# 'warning' ? 'W' : 'E'
|
||||||
|
|
||||||
call add(l:output, {
|
call add(l:output, {
|
||||||
\ 'lnum': l:line,
|
\ 'lnum': l:line,
|
||||||
@@ -133,7 +145,7 @@ function! ale_linters#kotlin#kotlinc#Handle(buffer, lines) abort
|
|||||||
let l:type = l:match[1]
|
let l:type = l:match[1]
|
||||||
let l:text = l:match[2]
|
let l:text = l:match[2]
|
||||||
|
|
||||||
let l:type_marker_str = l:type ==# 'warning' || l:type ==# 'info' ? 'W' : 'E'
|
let l:type_marker_str = l:type is# 'warning' || l:type is# 'info' ? 'W' : 'E'
|
||||||
|
|
||||||
call add(l:output, {
|
call add(l:output, {
|
||||||
\ 'lnum': 1,
|
\ 'lnum': 1,
|
||||||
@@ -155,3 +167,4 @@ call ale#linter#Define('kotlin', {
|
|||||||
\ 'callback': 'ale_linters#kotlin#kotlinc#Handle',
|
\ 'callback': 'ale_linters#kotlin#kotlinc#Handle',
|
||||||
\ 'lint_file': 1,
|
\ 'lint_file': 1,
|
||||||
\})
|
\})
|
||||||
|
|
||||||
|
|||||||
35
ale_linters/llvm/llc.vim
Normal file
35
ale_linters/llvm/llc.vim
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
" Author: rhysd <https://rhysd.github.io>
|
||||||
|
" Description: Support for checking LLVM IR with llc
|
||||||
|
|
||||||
|
call ale#Set('llvm_llc_executable', 'llc')
|
||||||
|
|
||||||
|
function! ale_linters#llvm#llc#GetExecutable(buffer) abort
|
||||||
|
return ale#Var(a:buffer, 'llvm_llc_executable')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#llvm#llc#GetCommand(buffer) abort
|
||||||
|
return ale#Escape(ale_linters#llvm#llc#GetExecutable(a:buffer))
|
||||||
|
\ . ' -filetype=null -o='
|
||||||
|
\ . ale#Escape(g:ale#util#nul_file)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#llvm#llc#HandleErrors(buffer, lines) abort
|
||||||
|
" Handle '{path}: {file}:{line}:{col}: error: {message}' format
|
||||||
|
let l:pattern = '\v^[a-zA-Z]?:?[^:]+: [^:]+:(\d+):(\d+): (.+)$'
|
||||||
|
let l:matches = ale#util#GetMatches(a:lines, l:pattern)
|
||||||
|
|
||||||
|
return map(l:matches, "{
|
||||||
|
\ 'lnum': str2nr(v:val[1]),
|
||||||
|
\ 'col': str2nr(v:val[2]),
|
||||||
|
\ 'text': v:val[3],
|
||||||
|
\ 'type': 'E',
|
||||||
|
\}")
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('llvm', {
|
||||||
|
\ 'name': 'llc',
|
||||||
|
\ 'executable_callback': 'ale_linters#llvm#llc#GetExecutable',
|
||||||
|
\ 'output_stream': 'stderr',
|
||||||
|
\ 'command_callback': 'ale_linters#llvm#llc#GetCommand',
|
||||||
|
\ 'callback': 'ale_linters#llvm#llc#HandleErrors',
|
||||||
|
\})
|
||||||
@@ -22,14 +22,20 @@ function! ale_linters#lua#luacheck#Handle(buffer, lines) abort
|
|||||||
"
|
"
|
||||||
" artal.lua:159:17: (W111) shadowing definition of loop variable 'i' on line 106
|
" artal.lua:159:17: (W111) shadowing definition of loop variable 'i' on line 106
|
||||||
" artal.lua:182:7: (W213) unused loop variable 'i'
|
" artal.lua:182:7: (W213) unused loop variable 'i'
|
||||||
let l:pattern = '^.*:\(\d\+\):\(\d\+\): (\([WE]\)\d\+) \(.\+\)$'
|
let l:pattern = '^.*:\(\d\+\):\(\d\+\): (\([WE]\)\(\d\+\)) \(.\+\)$'
|
||||||
let l:output = []
|
let l:output = []
|
||||||
|
|
||||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
|
if !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
|
||||||
|
\ && l:match[3] is# 'W'
|
||||||
|
\ && index(range(611, 614), str2nr(l:match[4])) >= 0
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
|
||||||
call add(l:output, {
|
call add(l:output, {
|
||||||
\ 'lnum': l:match[1] + 0,
|
\ 'lnum': l:match[1] + 0,
|
||||||
\ 'col': l:match[2] + 0,
|
\ 'col': l:match[2] + 0,
|
||||||
\ 'text': l:match[4],
|
\ 'text': l:match[3] . l:match[4] . ': ' . l:match[5],
|
||||||
\ 'type': l:match[3],
|
\ 'type': l:match[3],
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|||||||
28
ale_linters/markdown/remark_lint.vim
Normal file
28
ale_linters/markdown/remark_lint.vim
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
" Author rhysd https://rhysd.github.io/
|
||||||
|
" Description: remark-lint for Markdown files
|
||||||
|
|
||||||
|
function! ale_linters#markdown#remark_lint#Handle(buffer, lines) abort
|
||||||
|
" matches: ' 1:4 warning Incorrect list-item indent: add 1 space list-item-indent remark-lint'
|
||||||
|
let l:pattern = '^ \+\(\d\+\):\(\d\+\) \(warning\|error\) \(.\+\)$'
|
||||||
|
let l:output = []
|
||||||
|
|
||||||
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
|
call add(l:output, {
|
||||||
|
\ 'lnum': l:match[1] + 0,
|
||||||
|
\ 'col': l:match[2] + 0,
|
||||||
|
\ 'type': l:match[3] is# 'error' ? 'E' : 'W',
|
||||||
|
\ 'text': l:match[4],
|
||||||
|
\})
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return l:output
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('markdown', {
|
||||||
|
\ 'name': 'remark-lint',
|
||||||
|
\ 'executable': 'remark',
|
||||||
|
\ 'command': 'remark --no-stdout --no-color %s',
|
||||||
|
\ 'callback': 'ale_linters#markdown#remark_lint#Handle',
|
||||||
|
\ 'lint_file': 1,
|
||||||
|
\ 'output_stream': 'stderr',
|
||||||
|
\})
|
||||||
@@ -30,7 +30,7 @@ function! ale_linters#matlab#mlint#Handle(buffer, lines) abort
|
|||||||
|
|
||||||
" Suppress erroneous waring about filename
|
" Suppress erroneous waring about filename
|
||||||
" TODO: Enable this error when copying filename is supported
|
" TODO: Enable this error when copying filename is supported
|
||||||
if l:code ==# 'FNDEF'
|
if l:code is# 'FNDEF'
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ function! ale_linters#nim#nimcheck#Handle(buffer, lines) abort
|
|||||||
" module names.
|
" module names.
|
||||||
|
|
||||||
let l:temp_buffer_filename = fnamemodify(l:match[1], ':p:t')
|
let l:temp_buffer_filename = fnamemodify(l:match[1], ':p:t')
|
||||||
if l:buffer_filename !=# '' && l:temp_buffer_filename !=# l:buffer_filename
|
if l:buffer_filename isnot# '' && l:temp_buffer_filename isnot# l:buffer_filename
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ function! ale_linters#nim#nimcheck#Handle(buffer, lines) abort
|
|||||||
|
|
||||||
if len(l:textmatch) > 0
|
if len(l:textmatch) > 0
|
||||||
let l:errortype = l:textmatch[1]
|
let l:errortype = l:textmatch[1]
|
||||||
if l:errortype ==# 'Error'
|
if l:errortype is# 'Error'
|
||||||
let l:type = 'E'
|
let l:type = 'E'
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ function! ale_linters#perl#perl#Handle(buffer, lines) abort
|
|||||||
|
|
||||||
if ale#path#IsBufferPath(a:buffer, l:match[2])
|
if ale#path#IsBufferPath(a:buffer, l:match[2])
|
||||||
\ && (
|
\ && (
|
||||||
\ l:text !=# 'BEGIN failed--compilation aborted'
|
\ l:text isnot# 'BEGIN failed--compilation aborted'
|
||||||
\ || empty(l:output)
|
\ || empty(l:output)
|
||||||
\ || match(l:output[-1].text, s:begin_failed_skip_pattern) < 0
|
\ || match(l:output[-1].text, s:begin_failed_skip_pattern) < 0
|
||||||
\ )
|
\ )
|
||||||
|
|||||||
@@ -1,17 +1,54 @@
|
|||||||
" Author: Vincent Lequertier <https://github.com/SkySymbol>
|
" Author: Vincent Lequertier <https://github.com/SkySymbol>, Chris Weyl <cweyl@alumni.drew.edu>
|
||||||
" Description: This file adds support for checking perl with perl critic
|
" Description: This file adds support for checking perl with perl critic
|
||||||
|
|
||||||
if !exists('g:ale_perl_perlcritic_showrules')
|
let g:ale_perl_perlcritic_executable =
|
||||||
let g:ale_perl_perlcritic_showrules = 0
|
\ get(g:, 'ale_perl_perlcritic_executable', 'perlcritic')
|
||||||
endif
|
|
||||||
|
let g:ale_perl_perlcritic_profile =
|
||||||
|
\ get(g:, 'ale_perl_perlcritic_profile', '.perlcriticrc')
|
||||||
|
|
||||||
|
let g:ale_perl_perlcritic_options =
|
||||||
|
\ get(g:, 'ale_perl_perlcritic_options', '')
|
||||||
|
|
||||||
|
let g:ale_perl_perlcritic_showrules =
|
||||||
|
\ get(g:, 'ale_perl_perlcritic_showrules', 0)
|
||||||
|
|
||||||
|
function! ale_linters#perl#perlcritic#GetExecutable(buffer) abort
|
||||||
|
return ale#Var(a:buffer, 'perl_perlcritic_executable')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#perl#perlcritic#GetProfile(buffer) abort
|
||||||
|
|
||||||
|
" first see if we've been overridden
|
||||||
|
let l:profile = ale#Var(a:buffer, 'perl_perlcritic_profile')
|
||||||
|
if l:profile is? ''
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
|
||||||
|
" otherwise, iterate upwards to find it
|
||||||
|
return ale#path#FindNearestFile(a:buffer, l:profile)
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#perl#perlcritic#GetCommand(buffer) abort
|
function! ale_linters#perl#perlcritic#GetCommand(buffer) abort
|
||||||
let l:critic_verbosity = '%l:%c %m\n'
|
let l:critic_verbosity = '%l:%c %m\n'
|
||||||
if g:ale_perl_perlcritic_showrules
|
if ale#Var(a:buffer, 'perl_perlcritic_showrules')
|
||||||
let l:critic_verbosity = '%l:%c %m [%p]\n'
|
let l:critic_verbosity = '%l:%c %m [%p]\n'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return "perlcritic --verbose '". l:critic_verbosity . "' --nocolor"
|
let l:profile = ale_linters#perl#perlcritic#GetProfile(a:buffer)
|
||||||
|
let l:options = ale#Var(a:buffer, 'perl_perlcritic_options')
|
||||||
|
|
||||||
|
let l:command = ale#Escape(ale_linters#perl#perlcritic#GetExecutable(a:buffer))
|
||||||
|
\ . " --verbose '". l:critic_verbosity . "' --nocolor"
|
||||||
|
|
||||||
|
if l:profile isnot? ''
|
||||||
|
let l:command .= ' --profile ' . ale#Escape(l:profile)
|
||||||
|
endif
|
||||||
|
if l:options isnot? ''
|
||||||
|
let l:command .= ' ' . l:options
|
||||||
|
endif
|
||||||
|
|
||||||
|
return l:command
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
@@ -32,8 +69,8 @@ endfunction
|
|||||||
|
|
||||||
call ale#linter#Define('perl', {
|
call ale#linter#Define('perl', {
|
||||||
\ 'name': 'perlcritic',
|
\ 'name': 'perlcritic',
|
||||||
\ 'executable': 'perlcritic',
|
|
||||||
\ 'output_stream': 'stdout',
|
\ 'output_stream': 'stdout',
|
||||||
|
\ 'executable_callback': 'ale_linters#perl#perlcritic#GetExecutable',
|
||||||
\ 'command_callback': 'ale_linters#perl#perlcritic#GetCommand',
|
\ 'command_callback': 'ale_linters#perl#perlcritic#GetCommand',
|
||||||
\ 'callback': 'ale_linters#perl#perlcritic#Handle',
|
\ 'callback': 'ale_linters#perl#perlcritic#Handle',
|
||||||
\})
|
\})
|
||||||
|
|||||||
34
ale_linters/php/langserver.vim
Normal file
34
ale_linters/php/langserver.vim
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
" Author: Eric Stern <eric@ericstern.com>
|
||||||
|
" Description: PHP Language server integration for ALE
|
||||||
|
|
||||||
|
call ale#Set('php_langserver_executable', 'php-language-server.php')
|
||||||
|
call ale#Set('php_langserver_use_global', 0)
|
||||||
|
|
||||||
|
function! ale_linters#php#langserver#GetExecutable(buffer) abort
|
||||||
|
return ale#node#FindExecutable(a:buffer, 'php_langserver', [
|
||||||
|
\ 'vendor/bin/php-language-server.php',
|
||||||
|
\])
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#php#langserver#GetCommand(buffer) abort
|
||||||
|
return 'php ' . ale#Escape(ale_linters#php#langserver#GetExecutable(a:buffer))
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#php#langserver#GetLanguage(buffer) abort
|
||||||
|
return 'php'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#php#langserver#GetProjectRoot(buffer) abort
|
||||||
|
let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git')
|
||||||
|
|
||||||
|
return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : ''
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('php', {
|
||||||
|
\ 'name': 'langserver',
|
||||||
|
\ 'lsp': 'stdio',
|
||||||
|
\ 'executable_callback': 'ale_linters#php#langserver#GetExecutable',
|
||||||
|
\ 'command_callback': 'ale_linters#php#langserver#GetCommand',
|
||||||
|
\ 'language_callback': 'ale_linters#php#langserver#GetLanguage',
|
||||||
|
\ 'project_root_callback': 'ale_linters#php#langserver#GetProjectRoot',
|
||||||
|
\})
|
||||||
@@ -30,6 +30,6 @@ call ale#linter#Define('php', {
|
|||||||
\ 'name': 'php',
|
\ 'name': 'php',
|
||||||
\ 'executable': 'php',
|
\ 'executable': 'php',
|
||||||
\ 'output_stream': 'stdout',
|
\ 'output_stream': 'stdout',
|
||||||
\ 'command': 'php -l -d error_reporting=E_ALL -d display_errors=1 --',
|
\ 'command': 'php -l -d error_reporting=E_ALL -d display_errors=1 -d log_errors=0 --',
|
||||||
\ 'callback': 'ale_linters#php#php#Handle',
|
\ 'callback': 'ale_linters#php#php#Handle',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ function! ale_linters#php#phpcs#Handle(buffer, lines) abort
|
|||||||
\ 'lnum': l:match[1] + 0,
|
\ 'lnum': l:match[1] + 0,
|
||||||
\ 'col': l:match[2] + 0,
|
\ 'col': l:match[2] + 0,
|
||||||
\ 'text': l:text,
|
\ 'text': l:text,
|
||||||
\ 'type': l:type ==# 'error' ? 'E' : 'W',
|
\ 'type': l:type is# 'error' ? 'E' : 'W',
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ function! ale_linters#php#phpmd#Handle(buffer, lines) abort
|
|||||||
" Matches against lines like the following:
|
" Matches against lines like the following:
|
||||||
"
|
"
|
||||||
" /path/to/some-filename.php:18 message
|
" /path/to/some-filename.php:18 message
|
||||||
let l:pattern = '^.*:\(\d\+\)\t\(.\+\)$'
|
let l:pattern = '^.*:\(\d\+\)\s\+\(.\+\)$'
|
||||||
let l:output = []
|
let l:output = []
|
||||||
|
|
||||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
|
|||||||
53
ale_linters/php/phpstan.vim
Normal file
53
ale_linters/php/phpstan.vim
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
" Author: medains <https://github.com/medains>, ardis <https://github.com/ardisdreelath>
|
||||||
|
" Description: phpstan for PHP files
|
||||||
|
|
||||||
|
" Set to change the ruleset
|
||||||
|
let g:ale_php_phpstan_executable = get(g:, 'ale_php_phpstan_executable', 'phpstan')
|
||||||
|
let g:ale_php_phpstan_level = get(g:, 'ale_php_phpstan_level', '4')
|
||||||
|
let g:ale_php_phpstan_configuration = get(g:, 'ale_php_phpstan_configuration', '')
|
||||||
|
|
||||||
|
function! ale_linters#php#phpstan#GetExecutable(buffer) abort
|
||||||
|
return ale#Var(a:buffer, 'php_phpstan_executable')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#php#phpstan#GetCommand(buffer) abort
|
||||||
|
let l:executable = ale_linters#php#phpstan#GetExecutable(a:buffer)
|
||||||
|
|
||||||
|
let l:configuration = ale#Var(a:buffer, 'php_phpstan_configuration')
|
||||||
|
let l:configuration_option = !empty(l:configuration)
|
||||||
|
\ ? ' -c ' . l:configuration
|
||||||
|
\ : ''
|
||||||
|
|
||||||
|
return ale#Escape(l:executable)
|
||||||
|
\ . ' analyze -l'
|
||||||
|
\ . ale#Var(a:buffer, 'php_phpstan_level')
|
||||||
|
\ . ' --errorFormat raw'
|
||||||
|
\ . l:configuration_option
|
||||||
|
\ . ' %s'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#php#phpstan#Handle(buffer, lines) abort
|
||||||
|
" Matches against lines like the following:
|
||||||
|
"
|
||||||
|
" filename.php:15:message
|
||||||
|
" C:\folder\filename.php:15:message
|
||||||
|
let l:pattern = '^\([a-zA-Z]:\)\?[^:]\+:\(\d\+\):\(.*\)$'
|
||||||
|
let l:output = []
|
||||||
|
|
||||||
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
|
call add(l:output, {
|
||||||
|
\ 'lnum': l:match[2] + 0,
|
||||||
|
\ 'text': l:match[3],
|
||||||
|
\ 'type': 'W',
|
||||||
|
\})
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return l:output
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('php', {
|
||||||
|
\ 'name': 'phpstan',
|
||||||
|
\ 'executable_callback': 'ale_linters#php#phpstan#GetExecutable',
|
||||||
|
\ 'command_callback': 'ale_linters#php#phpstan#GetCommand',
|
||||||
|
\ 'callback': 'ale_linters#php#phpstan#Handle',
|
||||||
|
\})
|
||||||
@@ -1,10 +1,48 @@
|
|||||||
" Author: w0rp - <devw0rp@gmail.com>
|
" Author: w0rp - <devw0rp@gmail.com>
|
||||||
" Description: pug-lint for checking Pug/Jade files.
|
" Description: pug-lint for checking Pug/Jade files.
|
||||||
|
|
||||||
|
call ale#Set('pug_puglint_options', '')
|
||||||
|
call ale#Set('pug_puglint_executable', 'pug-lint')
|
||||||
|
call ale#Set('pug_puglint_use_global', 0)
|
||||||
|
|
||||||
|
function! ale_linters#pug#puglint#GetExecutable(buffer) abort
|
||||||
|
return ale#node#FindExecutable(a:buffer, 'pug_puglint', [
|
||||||
|
\ 'node_modules/.bin/pug-lint',
|
||||||
|
\])
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:FindConfig(buffer) abort
|
||||||
|
for l:filename in [
|
||||||
|
\ '.pug-lintrc',
|
||||||
|
\ '.pug-lintrc.js',
|
||||||
|
\ '.pug-lintrc.json',
|
||||||
|
\ 'package.json',
|
||||||
|
\]
|
||||||
|
let l:config = ale#path#FindNearestFile(a:buffer, l:filename)
|
||||||
|
|
||||||
|
if !empty(l:config)
|
||||||
|
return l:config
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return ''
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#pug#puglint#GetCommand(buffer) abort
|
||||||
|
let l:executable = ale_linters#pug#puglint#GetExecutable(a:buffer)
|
||||||
|
let l:options = ale#Var(a:buffer, 'pug_puglint_options')
|
||||||
|
let l:config = s:FindConfig(a:buffer)
|
||||||
|
|
||||||
|
return ale#Escape(l:executable)
|
||||||
|
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||||
|
\ . (!empty(l:config) ? ' -c ' . ale#Escape(l:config) : '')
|
||||||
|
\ . ' -r inline %t'
|
||||||
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('pug', {
|
call ale#linter#Define('pug', {
|
||||||
\ 'name': 'puglint',
|
\ 'name': 'puglint',
|
||||||
\ 'executable': 'pug-lint',
|
\ 'executable_callback': 'ale_linters#pug#puglint#GetExecutable',
|
||||||
\ 'output_stream': 'stderr',
|
\ 'output_stream': 'stderr',
|
||||||
\ 'command': 'pug-lint -r inline %t',
|
\ 'command_callback': 'ale_linters#pug#puglint#GetCommand',
|
||||||
\ 'callback': 'ale#handlers#unix#HandleAsError',
|
\ 'callback': 'ale#handlers#unix#HandleAsError',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -19,16 +19,8 @@ function! s:UsingModule(buffer) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#python#flake8#GetExecutable(buffer) abort
|
function! ale_linters#python#flake8#GetExecutable(buffer) abort
|
||||||
if !s:UsingModule(a:buffer) && !ale#Var(a:buffer, 'python_flake8_use_global')
|
if !s:UsingModule(a:buffer)
|
||||||
let l:virtualenv = ale#python#FindVirtualenv(a:buffer)
|
return ale#python#FindExecutable(a:buffer, 'python_flake8', ['flake8'])
|
||||||
|
|
||||||
if !empty(l:virtualenv)
|
|
||||||
let l:ve_flake8 = l:virtualenv . '/bin/flake8'
|
|
||||||
|
|
||||||
if executable(l:ve_flake8)
|
|
||||||
return l:ve_flake8
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return ale#Var(a:buffer, 'python_flake8_executable')
|
return ale#Var(a:buffer, 'python_flake8_executable')
|
||||||
@@ -91,6 +83,7 @@ function! ale_linters#python#flake8#GetCommand(buffer, version_output) abort
|
|||||||
|
|
||||||
return ale#Escape(ale_linters#python#flake8#GetExecutable(a:buffer))
|
return ale#Escape(ale_linters#python#flake8#GetExecutable(a:buffer))
|
||||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||||
|
\ . ' --format=default'
|
||||||
\ . l:display_name_args . ' -'
|
\ . l:display_name_args . ' -'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -123,7 +116,7 @@ function! ale_linters#python#flake8#Handle(buffer, lines) abort
|
|||||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
let l:code = l:match[3]
|
let l:code = l:match[3]
|
||||||
|
|
||||||
if (l:code ==# 'W291' || l:code ==# 'W293')
|
if (l:code is# 'W291' || l:code is# 'W293')
|
||||||
\ && !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
|
\ && !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
|
||||||
" Skip warnings for trailing whitespace if the option is off.
|
" Skip warnings for trailing whitespace if the option is off.
|
||||||
continue
|
continue
|
||||||
@@ -136,12 +129,12 @@ function! ale_linters#python#flake8#Handle(buffer, lines) abort
|
|||||||
\ 'type': 'W',
|
\ 'type': 'W',
|
||||||
\}
|
\}
|
||||||
|
|
||||||
if l:code[:0] ==# 'F' || l:code ==# 'E999'
|
if l:code[:0] is# 'F' || l:code is# 'E999'
|
||||||
let l:item.type = 'E'
|
let l:item.type = 'E'
|
||||||
elseif l:code[:0] ==# 'E'
|
elseif l:code[:0] is# 'E'
|
||||||
let l:item.type = 'E'
|
let l:item.type = 'E'
|
||||||
let l:item.sub_type = 'style'
|
let l:item.sub_type = 'style'
|
||||||
elseif l:code[:0] ==# 'W'
|
elseif l:code[:0] is# 'W'
|
||||||
let l:item.sub_type = 'style'
|
let l:item.sub_type = 'style'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -7,17 +7,25 @@ let g:ale_python_mypy_options = get(g:, 'ale_python_mypy_options', '')
|
|||||||
let g:ale_python_mypy_use_global = get(g:, 'ale_python_mypy_use_global', 0)
|
let g:ale_python_mypy_use_global = get(g:, 'ale_python_mypy_use_global', 0)
|
||||||
|
|
||||||
function! ale_linters#python#mypy#GetExecutable(buffer) abort
|
function! ale_linters#python#mypy#GetExecutable(buffer) abort
|
||||||
return ale#python#FindExecutable(a:buffer, 'python_mypy', ['/bin/mypy'])
|
return ale#python#FindExecutable(a:buffer, 'python_mypy', ['mypy'])
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" The directory to change to before running mypy
|
||||||
|
function! s:GetDir(buffer) abort
|
||||||
|
let l:project_root = ale#python#FindProjectRoot(a:buffer)
|
||||||
|
|
||||||
|
return !empty(l:project_root)
|
||||||
|
\ ? l:project_root
|
||||||
|
\ : expand('#' . a:buffer . ':p:h')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#python#mypy#GetCommand(buffer) abort
|
function! ale_linters#python#mypy#GetCommand(buffer) abort
|
||||||
let l:project_root = ale#python#FindProjectRoot(a:buffer)
|
let l:dir = s:GetDir(a:buffer)
|
||||||
let l:cd_command = !empty(l:project_root)
|
|
||||||
\ ? ale#path#CdString(l:project_root)
|
|
||||||
\ : ''
|
|
||||||
let l:executable = ale_linters#python#mypy#GetExecutable(a:buffer)
|
let l:executable = ale_linters#python#mypy#GetExecutable(a:buffer)
|
||||||
|
|
||||||
return l:cd_command
|
" We have to always switch to an explicit directory for a command so
|
||||||
|
" we can know with certainty the base path for the 'filename' keys below.
|
||||||
|
return ale#path#CdString(l:dir)
|
||||||
\ . ale#Escape(l:executable)
|
\ . ale#Escape(l:executable)
|
||||||
\ . ' --show-column-numbers '
|
\ . ' --show-column-numbers '
|
||||||
\ . ale#Var(a:buffer, 'python_mypy_options')
|
\ . ale#Var(a:buffer, 'python_mypy_options')
|
||||||
@@ -25,6 +33,7 @@ function! ale_linters#python#mypy#GetCommand(buffer) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#python#mypy#Handle(buffer, lines) abort
|
function! ale_linters#python#mypy#Handle(buffer, lines) abort
|
||||||
|
let l:dir = s:GetDir(a:buffer)
|
||||||
" Look for lines like the following:
|
" Look for lines like the following:
|
||||||
"
|
"
|
||||||
" file.py:4: error: No library stub file for module 'django.db'
|
" file.py:4: error: No library stub file for module 'django.db'
|
||||||
@@ -34,17 +43,13 @@ function! ale_linters#python#mypy#Handle(buffer, lines) abort
|
|||||||
" file.py:4: note: (Stub files are from https://github.com/python/typeshed)
|
" file.py:4: note: (Stub files are from https://github.com/python/typeshed)
|
||||||
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?: (error|warning): (.+)$'
|
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?: (error|warning): (.+)$'
|
||||||
let l:output = []
|
let l:output = []
|
||||||
let l:buffer_filename = expand('#' . a:buffer . ':p')
|
|
||||||
|
|
||||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
if l:buffer_filename[-len(l:match[1]):] !=# l:match[1]
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
|
|
||||||
call add(l:output, {
|
call add(l:output, {
|
||||||
|
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
|
||||||
\ 'lnum': l:match[2] + 0,
|
\ 'lnum': l:match[2] + 0,
|
||||||
\ 'col': l:match[3] + 0,
|
\ 'col': l:match[3] + 0,
|
||||||
\ 'type': l:match[4] =~# 'error' ? 'E' : 'W',
|
\ 'type': l:match[4] is# 'error' ? 'E' : 'W',
|
||||||
\ 'text': l:match[5],
|
\ 'text': l:match[5],
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|||||||
42
ale_linters/python/pycodestyle.vim
Normal file
42
ale_linters/python/pycodestyle.vim
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
" Author: Michael Thiesen <micthiesen@gmail.com>
|
||||||
|
" Description: pycodestyle linting for python files
|
||||||
|
|
||||||
|
call ale#Set('python_pycodestyle_executable', 'pycodestyle')
|
||||||
|
call ale#Set('python_pycodestyle_options', '')
|
||||||
|
call ale#Set('python_pycodestyle_use_global', 0)
|
||||||
|
|
||||||
|
function! ale_linters#python#pycodestyle#GetExecutable(buffer) abort
|
||||||
|
return ale#python#FindExecutable(a:buffer, 'python_pycodestyle', ['pycodestyle'])
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#python#pycodestyle#GetCommand(buffer) abort
|
||||||
|
return ale#Escape(ale_linters#python#pycodestyle#GetExecutable(a:buffer))
|
||||||
|
\ . ' '
|
||||||
|
\ . ale#Var(a:buffer, 'python_pycodestyle_options')
|
||||||
|
\ . ' -'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#python#pycodestyle#Handle(buffer, lines) abort
|
||||||
|
let l:pattern = '\v^(\S*):(\d*):(\d*): ((([EW])\d+) .*)$'
|
||||||
|
let l:output = []
|
||||||
|
|
||||||
|
" lines are formatted as follows:
|
||||||
|
" file.py:21:26: W291 trailing whitespace
|
||||||
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
|
call add(l:output, {
|
||||||
|
\ 'lnum': l:match[2] + 0,
|
||||||
|
\ 'col': l:match[3] + 0,
|
||||||
|
\ 'type': l:match[6],
|
||||||
|
\ 'text': l:match[4],
|
||||||
|
\})
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return l:output
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('python', {
|
||||||
|
\ 'name': 'pycodestyle',
|
||||||
|
\ 'executable_callback': 'ale_linters#python#pycodestyle#GetExecutable',
|
||||||
|
\ 'command_callback': 'ale_linters#python#pycodestyle#GetCommand',
|
||||||
|
\ 'callback': 'ale_linters#python#pycodestyle#Handle',
|
||||||
|
\})
|
||||||
@@ -10,19 +10,7 @@ let g:ale_python_pylint_options =
|
|||||||
let g:ale_python_pylint_use_global = get(g:, 'ale_python_pylint_use_global', 0)
|
let g:ale_python_pylint_use_global = get(g:, 'ale_python_pylint_use_global', 0)
|
||||||
|
|
||||||
function! ale_linters#python#pylint#GetExecutable(buffer) abort
|
function! ale_linters#python#pylint#GetExecutable(buffer) abort
|
||||||
if !ale#Var(a:buffer, 'python_pylint_use_global')
|
return ale#python#FindExecutable(a:buffer, 'python_pylint', ['pylint'])
|
||||||
let l:virtualenv = ale#python#FindVirtualenv(a:buffer)
|
|
||||||
|
|
||||||
if !empty(l:virtualenv)
|
|
||||||
let l:ve_pylint = l:virtualenv . '/bin/pylint'
|
|
||||||
|
|
||||||
if executable(l:ve_pylint)
|
|
||||||
return l:ve_pylint
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
return ale#Var(a:buffer, 'python_pylint_executable')
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#python#pylint#GetCommand(buffer) abort
|
function! ale_linters#python#pylint#GetCommand(buffer) abort
|
||||||
@@ -43,13 +31,13 @@ function! ale_linters#python#pylint#Handle(buffer, lines) abort
|
|||||||
"let l:failed = append(0, l:match)
|
"let l:failed = append(0, l:match)
|
||||||
let l:code = l:match[3]
|
let l:code = l:match[3]
|
||||||
|
|
||||||
if (l:code ==# 'C0303')
|
if (l:code is# 'C0303')
|
||||||
\ && !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
|
\ && !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
|
||||||
" Skip warnings for trailing whitespace if the option is off.
|
" Skip warnings for trailing whitespace if the option is off.
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if l:code ==# 'I0011'
|
if l:code is# 'I0011'
|
||||||
" Skip 'Locally disabling' message
|
" Skip 'Locally disabling' message
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
@@ -58,7 +46,7 @@ function! ale_linters#python#pylint#Handle(buffer, lines) abort
|
|||||||
\ 'lnum': l:match[1] + 0,
|
\ 'lnum': l:match[1] + 0,
|
||||||
\ 'col': l:match[2] + 1,
|
\ 'col': l:match[2] + 1,
|
||||||
\ 'text': l:code . ': ' . l:match[5] . ' (' . l:match[4] . ')',
|
\ 'text': l:code . ': ' . l:match[5] . ' (' . l:match[4] . ')',
|
||||||
\ 'type': l:code[:0] ==# 'E' ? 'E' : 'W',
|
\ 'type': l:code[:0] is# 'E' ? 'E' : 'W',
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
|||||||
20
ale_linters/r/lintr.vim
Normal file
20
ale_linters/r/lintr.vim
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
" Author: Michel Lang <michellang@gmail.com>, w0rp <devw0rp@gmail.com>
|
||||||
|
" Description: This file adds support for checking R code with lintr.
|
||||||
|
|
||||||
|
let g:ale_r_lintr_options =
|
||||||
|
\ get(g:, 'ale_r_lintr_options', 'lintr::with_defaults()')
|
||||||
|
" A reasonable alternative default:
|
||||||
|
" \ get(g:, 'ale_r_lintr_options', 'lintr::with_defaults(object_usage_linter = NULL)')
|
||||||
|
|
||||||
|
function! ale_linters#r#lintr#GetCommand(buffer) abort
|
||||||
|
return ale#path#BufferCdString(a:buffer)
|
||||||
|
\ . 'Rscript -e ' . ale#Escape('lintr::lint(commandArgs(TRUE)[1], eval(parse(text = commandArgs(TRUE)[2])))') . ' %t' . ' ' . ale#Escape(ale#Var(a:buffer, 'r_lintr_options'))
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('r', {
|
||||||
|
\ 'name': 'lintr',
|
||||||
|
\ 'executable': 'Rscript',
|
||||||
|
\ 'command_callback': 'ale_linters#r#lintr#GetCommand',
|
||||||
|
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
||||||
|
\ 'output_stream': 'both',
|
||||||
|
\})
|
||||||
@@ -5,26 +5,21 @@ let g:ale_ruby_brakeman_options =
|
|||||||
\ get(g:, 'ale_ruby_brakeman_options', '')
|
\ get(g:, 'ale_ruby_brakeman_options', '')
|
||||||
|
|
||||||
function! ale_linters#ruby#brakeman#Handle(buffer, lines) abort
|
function! ale_linters#ruby#brakeman#Handle(buffer, lines) abort
|
||||||
let l:result = json_decode(join(a:lines, ''))
|
|
||||||
|
|
||||||
let l:output = []
|
let l:output = []
|
||||||
|
let l:json = ale#util#FuzzyJSONDecode(a:lines, {})
|
||||||
|
let l:sep = has('win32') ? '\' : '/'
|
||||||
|
" Brakeman always outputs paths relative to the Rails app root
|
||||||
|
let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
|
||||||
|
|
||||||
for l:warning in l:result.warnings
|
for l:warning in get(l:json, 'warnings', [])
|
||||||
" Brakeman always outputs paths relative to the Rails app root
|
|
||||||
let l:rails_root = s:FindRailsRoot(a:buffer)
|
|
||||||
let l:warning_file = l:rails_root . '/' . l:warning.file
|
|
||||||
|
|
||||||
if !ale#path#IsBufferPath(a:buffer, l:warning_file)
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
|
|
||||||
let l:text = l:warning.warning_type . ' ' . l:warning.message . ' (' . l:warning.confidence . ')'
|
let l:text = l:warning.warning_type . ' ' . l:warning.message . ' (' . l:warning.confidence . ')'
|
||||||
let l:line = l:warning.line != v:null ? l:warning.line : 1
|
let l:line = l:warning.line != v:null ? l:warning.line : 1
|
||||||
|
|
||||||
call add(l:output, {
|
call add(l:output, {
|
||||||
\ 'lnum': l:line,
|
\ 'filename': l:rails_root . l:sep . l:warning.file,
|
||||||
\ 'type': 'W',
|
\ 'lnum': l:line,
|
||||||
\ 'text': l:text,
|
\ 'type': 'W',
|
||||||
|
\ 'text': l:text,
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
@@ -32,9 +27,9 @@ function! ale_linters#ruby#brakeman#Handle(buffer, lines) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#ruby#brakeman#GetCommand(buffer) abort
|
function! ale_linters#ruby#brakeman#GetCommand(buffer) abort
|
||||||
let l:rails_root = s:FindRailsRoot(a:buffer)
|
let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
|
||||||
|
|
||||||
if l:rails_root ==? ''
|
if l:rails_root is? ''
|
||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -43,26 +38,6 @@ function! ale_linters#ruby#brakeman#GetCommand(buffer) abort
|
|||||||
\ . ' -p ' . ale#Escape(l:rails_root)
|
\ . ' -p ' . ale#Escape(l:rails_root)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:FindRailsRoot(buffer) abort
|
|
||||||
" Find the nearest dir contining "app", "db", and "config", and assume it is
|
|
||||||
" the root of a Rails app.
|
|
||||||
for l:name in ['app', 'config', 'db']
|
|
||||||
let l:dir = fnamemodify(
|
|
||||||
\ ale#path#FindNearestDirectory(a:buffer, l:name),
|
|
||||||
\ ':h:h'
|
|
||||||
\)
|
|
||||||
|
|
||||||
if l:dir !=# '.'
|
|
||||||
\&& isdirectory(l:dir . '/app')
|
|
||||||
\&& isdirectory(l:dir . '/config')
|
|
||||||
\&& isdirectory(l:dir . '/db')
|
|
||||||
return l:dir
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
return ''
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
call ale#linter#Define('ruby', {
|
call ale#linter#Define('ruby', {
|
||||||
\ 'name': 'brakeman',
|
\ 'name': 'brakeman',
|
||||||
\ 'executable': 'brakeman',
|
\ 'executable': 'brakeman',
|
||||||
|
|||||||
53
ale_linters/ruby/rails_best_practices.vim
Normal file
53
ale_linters/ruby/rails_best_practices.vim
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
" Author: Eddie Lebow https://github.com/elebow
|
||||||
|
" Description: rails_best_practices, a code metric tool for rails projects
|
||||||
|
|
||||||
|
let g:ale_ruby_rails_best_practices_options =
|
||||||
|
\ get(g:, 'ale_ruby_rails_best_practices_options', '')
|
||||||
|
|
||||||
|
function! ale_linters#ruby#rails_best_practices#Handle(buffer, lines) abort
|
||||||
|
let l:output = []
|
||||||
|
|
||||||
|
for l:warning in ale#util#FuzzyJSONDecode(a:lines, [])
|
||||||
|
if !ale#path#IsBufferPath(a:buffer, l:warning.filename)
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
|
||||||
|
call add(l:output, {
|
||||||
|
\ 'lnum': l:warning.line_number + 0,
|
||||||
|
\ 'type': 'W',
|
||||||
|
\ 'text': l:warning.message,
|
||||||
|
\})
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return l:output
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#ruby#rails_best_practices#GetCommand(buffer) abort
|
||||||
|
let l:executable = ale#handlers#rails_best_practices#GetExecutable(a:buffer)
|
||||||
|
let l:exec_args = l:executable =~? 'bundle$'
|
||||||
|
\ ? ' exec rails_best_practices'
|
||||||
|
\ : ''
|
||||||
|
|
||||||
|
let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
|
||||||
|
|
||||||
|
if l:rails_root is? ''
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:output_file = ale#Has('win32') ? '%t ' : '/dev/stdout '
|
||||||
|
let l:cat_file = ale#Has('win32') ? '; type %t' : ''
|
||||||
|
|
||||||
|
return ale#Escape(l:executable) . l:exec_args
|
||||||
|
\ . ' --silent -f json --output-file ' . l:output_file
|
||||||
|
\ . ale#Var(a:buffer, 'ruby_rails_best_practices_options')
|
||||||
|
\ . ale#Escape(l:rails_root)
|
||||||
|
\ . l:cat_file
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('ruby', {
|
||||||
|
\ 'name': 'rails_best_practices',
|
||||||
|
\ 'executable_callback': 'ale#handlers#rails_best_practices#GetExecutable',
|
||||||
|
\ 'command_callback': 'ale_linters#ruby#rails_best_practices#GetCommand',
|
||||||
|
\ 'callback': 'ale_linters#ruby#rails_best_practices#Handle',
|
||||||
|
\ 'lint_file': 1,
|
||||||
|
\})
|
||||||
@@ -1,22 +1,13 @@
|
|||||||
" Author: Eddie Lebow https://github.com/elebow
|
" Author: Eddie Lebow https://github.com/elebow
|
||||||
" Description: Reek, a code smell detector for Ruby files
|
" Description: Reek, a code smell detector for Ruby files
|
||||||
|
|
||||||
let g:ale_ruby_reek_show_context =
|
call ale#Set('ruby_reek_show_context', 0)
|
||||||
\ get(g:, 'ale_ruby_reek_show_context', 0)
|
call ale#Set('ruby_reek_show_wiki_link', 0)
|
||||||
|
|
||||||
let g:ale_ruby_reek_show_wiki_link =
|
|
||||||
\ get(g:, 'ale_ruby_reek_show_wiki_link', 0)
|
|
||||||
|
|
||||||
function! ale_linters#ruby#reek#Handle(buffer, lines) abort
|
function! ale_linters#ruby#reek#Handle(buffer, lines) abort
|
||||||
if len(a:lines) == 0
|
|
||||||
return []
|
|
||||||
endif
|
|
||||||
|
|
||||||
let l:errors = json_decode(a:lines[0])
|
|
||||||
|
|
||||||
let l:output = []
|
let l:output = []
|
||||||
|
|
||||||
for l:error in l:errors
|
for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
|
||||||
for l:location in l:error.lines
|
for l:location in l:error.lines
|
||||||
call add(l:output, {
|
call add(l:output, {
|
||||||
\ 'lnum': l:location,
|
\ 'lnum': l:location,
|
||||||
|
|||||||
@@ -1,58 +1,60 @@
|
|||||||
" Author: ynonp - https://github.com/ynonp
|
" Author: ynonp - https://github.com/ynonp, Eddie Lebow https://github.com/elebow
|
||||||
" Description: rubocop for Ruby files
|
" Description: RuboCop, a code style analyzer for Ruby files
|
||||||
|
|
||||||
" Set this option to change Rubocop options.
|
|
||||||
if !exists('g:ale_ruby_rubocop_options')
|
|
||||||
" let g:ale_ruby_rubocop_options = '--lint'
|
|
||||||
let g:ale_ruby_rubocop_options = ''
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists('g:ale_ruby_rubocop_executable')
|
|
||||||
let g:ale_ruby_rubocop_executable = 'rubocop'
|
|
||||||
endif
|
|
||||||
|
|
||||||
function! ale_linters#ruby#rubocop#GetExecutable(buffer) abort
|
|
||||||
return ale#Var(a:buffer, 'ruby_rubocop_executable')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! ale_linters#ruby#rubocop#GetCommand(buffer) abort
|
function! ale_linters#ruby#rubocop#GetCommand(buffer) abort
|
||||||
let l:executable = ale#Var(a:buffer, 'ruby_rubocop_executable')
|
let l:executable = ale#handlers#rubocop#GetExecutable(a:buffer)
|
||||||
let l:exec_args = l:executable =~? 'bundle$'
|
let l:exec_args = l:executable =~? 'bundle$'
|
||||||
\ ? ' exec rubocop'
|
\ ? ' exec rubocop'
|
||||||
\ : ''
|
\ : ''
|
||||||
|
|
||||||
return ale#Escape(l:executable) . l:exec_args
|
return ale#Escape(l:executable) . l:exec_args
|
||||||
\ . ' --format emacs --force-exclusion '
|
\ . ' --format json --force-exclusion '
|
||||||
\ . ale#Var(a:buffer, 'ruby_rubocop_options')
|
\ . ale#Var(a:buffer, 'ruby_rubocop_options')
|
||||||
\ . ' --stdin ' . bufname(a:buffer)
|
\ . ' --stdin ' . ale#Escape(expand('#' . a:buffer . ':p'))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#ruby#rubocop#Handle(buffer, lines) abort
|
function! ale_linters#ruby#rubocop#Handle(buffer, lines) abort
|
||||||
" Matches patterns line the following:
|
try
|
||||||
"
|
let l:errors = json_decode(a:lines[0])
|
||||||
" <path>:83:29: C: Prefer single-quoted strings when you don't
|
catch
|
||||||
" need string interpolation or special symbols.
|
return []
|
||||||
let l:pattern = '\v:(\d+):(\d+): (.): (.+)'
|
endtry
|
||||||
|
|
||||||
|
if !has_key(l:errors, 'summary')
|
||||||
|
\|| l:errors['summary']['offense_count'] == 0
|
||||||
|
\|| empty(l:errors['files'])
|
||||||
|
return []
|
||||||
|
endif
|
||||||
|
|
||||||
let l:output = []
|
let l:output = []
|
||||||
|
|
||||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
for l:error in l:errors['files'][0]['offenses']
|
||||||
let l:text = l:match[4]
|
let l:start_col = l:error['location']['column'] + 0
|
||||||
let l:type = l:match[3]
|
|
||||||
|
|
||||||
call add(l:output, {
|
call add(l:output, {
|
||||||
\ 'lnum': l:match[1] + 0,
|
\ 'lnum': l:error['location']['line'] + 0,
|
||||||
\ 'col': l:match[2] + 0,
|
\ 'col': l:start_col,
|
||||||
\ 'text': l:text,
|
\ 'end_col': l:start_col + l:error['location']['length'] - 1,
|
||||||
\ 'type': index(['F', 'E'], l:type) != -1 ? 'E' : 'W',
|
\ 'text': printf('%s [%s]', l:error['message'], l:error['cop_name']),
|
||||||
|
\ 'type': ale_linters#ruby#rubocop#GetType(l:error['severity']),
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return l:output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#ruby#rubocop#GetType(severity) abort
|
||||||
|
if a:severity is? 'convention'
|
||||||
|
\|| a:severity is? 'warning'
|
||||||
|
\|| a:severity is? 'refactor'
|
||||||
|
return 'W'
|
||||||
|
endif
|
||||||
|
|
||||||
|
return 'E'
|
||||||
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('ruby', {
|
call ale#linter#Define('ruby', {
|
||||||
\ 'name': 'rubocop',
|
\ 'name': 'rubocop',
|
||||||
\ 'executable_callback': 'ale_linters#ruby#rubocop#GetExecutable',
|
\ 'executable_callback': 'ale#handlers#rubocop#GetExecutable',
|
||||||
\ 'command_callback': 'ale_linters#ruby#rubocop#GetCommand',
|
\ 'command_callback': 'ale_linters#ruby#rubocop#GetCommand',
|
||||||
\ 'callback': 'ale_linters#ruby#rubocop#Handle',
|
\ 'callback': 'ale_linters#ruby#rubocop#Handle',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
let g:ale_rust_cargo_use_check = get(g:, 'ale_rust_cargo_use_check', 0)
|
let g:ale_rust_cargo_use_check = get(g:, 'ale_rust_cargo_use_check', 0)
|
||||||
|
|
||||||
function! ale_linters#rust#cargo#GetCargoExecutable(bufnr) abort
|
function! ale_linters#rust#cargo#GetCargoExecutable(bufnr) abort
|
||||||
if ale#path#FindNearestFile(a:bufnr, 'Cargo.toml') !=# ''
|
if ale#path#FindNearestFile(a:bufnr, 'Cargo.toml') isnot# ''
|
||||||
return 'cargo'
|
return 'cargo'
|
||||||
else
|
else
|
||||||
" if there is no Cargo.toml file, we don't use cargo even if it exists,
|
" if there is no Cargo.toml file, we don't use cargo even if it exists,
|
||||||
@@ -26,6 +26,6 @@ call ale#linter#Define('rust', {
|
|||||||
\ 'executable_callback': 'ale_linters#rust#cargo#GetCargoExecutable',
|
\ 'executable_callback': 'ale_linters#rust#cargo#GetCargoExecutable',
|
||||||
\ 'command_callback': 'ale_linters#rust#cargo#GetCommand',
|
\ 'command_callback': 'ale_linters#rust#cargo#GetCommand',
|
||||||
\ 'callback': 'ale#handlers#rust#HandleRustErrors',
|
\ 'callback': 'ale#handlers#rust#HandleRustErrors',
|
||||||
\ 'output_stream': 'stdout',
|
\ 'output_stream': 'both',
|
||||||
\ 'lint_file': 1,
|
\ 'lint_file': 1,
|
||||||
\})
|
\})
|
||||||
|
|||||||
33
ale_linters/rust/rls.vim
Normal file
33
ale_linters/rust/rls.vim
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
" Author: w0rp <devw0rp@gmail.com>
|
||||||
|
" Description: A language server for Rust
|
||||||
|
|
||||||
|
call ale#Set('rust_rls_executable', 'rls')
|
||||||
|
|
||||||
|
function! ale_linters#rust#rls#GetExecutable(buffer) abort
|
||||||
|
return ale#Var(a:buffer, 'rust_rls_executable')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#rust#rls#GetCommand(buffer) abort
|
||||||
|
let l:executable = ale_linters#rust#rls#GetExecutable(a:buffer)
|
||||||
|
|
||||||
|
return ale#Escape(l:executable) . ' +nightly'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#rust#rls#GetLanguage(buffer) abort
|
||||||
|
return 'rust'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#rust#rls#GetProjectRoot(buffer) abort
|
||||||
|
let l:cargo_file = ale#path#FindNearestFile(a:buffer, 'Cargo.toml')
|
||||||
|
|
||||||
|
return !empty(l:cargo_file) ? fnamemodify(l:cargo_file, ':h') : ''
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('rust', {
|
||||||
|
\ 'name': 'rls',
|
||||||
|
\ 'lsp': 'stdio',
|
||||||
|
\ 'executable_callback': 'ale_linters#rust#rls#GetExecutable',
|
||||||
|
\ 'command_callback': 'ale_linters#rust#rls#GetCommand',
|
||||||
|
\ 'language_callback': 'ale_linters#rust#rls#GetLanguage',
|
||||||
|
\ 'project_root_callback': 'ale_linters#rust#rls#GetProjectRoot',
|
||||||
|
\})
|
||||||
@@ -7,7 +7,7 @@ function! ale_linters#rust#rustc#RustcCommand(buffer_number) abort
|
|||||||
" <project root>/target/release/deps/
|
" <project root>/target/release/deps/
|
||||||
let l:cargo_file = ale#path#FindNearestFile(a:buffer_number, 'Cargo.toml')
|
let l:cargo_file = ale#path#FindNearestFile(a:buffer_number, 'Cargo.toml')
|
||||||
|
|
||||||
if l:cargo_file !=# ''
|
if l:cargo_file isnot# ''
|
||||||
let l:project_root = fnamemodify(l:cargo_file, ':h')
|
let l:project_root = fnamemodify(l:cargo_file, ':h')
|
||||||
let l:dependencies = '-L ' . l:project_root . '/target/debug/deps -L ' .
|
let l:dependencies = '-L ' . l:project_root . '/target/debug/deps -L ' .
|
||||||
\ l:project_root . '/target/release/deps'
|
\ l:project_root . '/target/release/deps'
|
||||||
|
|||||||
@@ -1,6 +1,26 @@
|
|||||||
" Author: Zoltan Kalmar - https://github.com/kalmiz
|
" Author: Zoltan Kalmar - https://github.com/kalmiz,
|
||||||
|
" w0rp <devw0rp@gmail.com>
|
||||||
" Description: Basic scala support using scalac
|
" Description: Basic scala support using scalac
|
||||||
|
|
||||||
|
function! ale_linters#scala#scalac#GetExecutable(buffer) abort
|
||||||
|
if index(split(getbufvar(a:buffer, '&filetype'), '\.'), 'sbt') >= 0
|
||||||
|
" Don't check sbt files with scalac.
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
|
||||||
|
return 'scalac'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#scala#scalac#GetCommand(buffer) abort
|
||||||
|
let l:executable = ale_linters#scala#scalac#GetExecutable(a:buffer)
|
||||||
|
|
||||||
|
if empty(l:executable)
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
|
||||||
|
return ale#Escape(l:executable) . ' -Ystop-after:parser %t'
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#scala#scalac#Handle(buffer, lines) abort
|
function! ale_linters#scala#scalac#Handle(buffer, lines) abort
|
||||||
" Matches patterns line the following:
|
" Matches patterns line the following:
|
||||||
"
|
"
|
||||||
@@ -18,7 +38,7 @@ function! ale_linters#scala#scalac#Handle(buffer, lines) abort
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
let l:text = l:match[3]
|
let l:text = l:match[3]
|
||||||
let l:type = l:match[2] ==# 'error' ? 'E' : 'W'
|
let l:type = l:match[2] is# 'error' ? 'E' : 'W'
|
||||||
let l:col = 0
|
let l:col = 0
|
||||||
|
|
||||||
if l:ln + 1 < len(a:lines)
|
if l:ln + 1 < len(a:lines)
|
||||||
@@ -38,8 +58,8 @@ endfunction
|
|||||||
|
|
||||||
call ale#linter#Define('scala', {
|
call ale#linter#Define('scala', {
|
||||||
\ 'name': 'scalac',
|
\ 'name': 'scalac',
|
||||||
\ 'executable': 'scalac',
|
\ 'executable_callback': 'ale_linters#scala#scalac#GetExecutable',
|
||||||
\ 'output_stream': 'stderr',
|
\ 'command_callback': 'ale_linters#scala#scalac#GetCommand',
|
||||||
\ 'command': 'scalac -Ystop-after:parser %t',
|
|
||||||
\ 'callback': 'ale_linters#scala#scalac#Handle',
|
\ 'callback': 'ale_linters#scala#scalac#Handle',
|
||||||
|
\ 'output_stream': 'stderr',
|
||||||
\})
|
\})
|
||||||
|
|||||||
94
ale_linters/scala/scalastyle.vim
Normal file
94
ale_linters/scala/scalastyle.vim
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
" Author: Kevin Kays - https://github.com/okkays
|
||||||
|
" Description: Support for the scalastyle checker.
|
||||||
|
|
||||||
|
let g:ale_scala_scalastyle_options =
|
||||||
|
\ get(g:, 'ale_scala_scalastyle_options', '')
|
||||||
|
|
||||||
|
let g:ale_scalastyle_config_loc =
|
||||||
|
\ get(g:, 'ale_scalastyle_config_loc', '')
|
||||||
|
|
||||||
|
function! ale_linters#scala#scalastyle#Handle(buffer, lines) abort
|
||||||
|
" Look for help output from scalastyle first, which indicates that no
|
||||||
|
" configuration file was found.
|
||||||
|
for l:line in a:lines[:10]
|
||||||
|
if l:line =~# '-c, --config'
|
||||||
|
return [{
|
||||||
|
\ 'lnum': 1,
|
||||||
|
\ 'text': '(See :help ale-scala-scalastyle)'
|
||||||
|
\ . ' No scalastyle configuration file was found.',
|
||||||
|
\}]
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
|
||||||
|
" Matches patterns like the following:
|
||||||
|
"
|
||||||
|
" warning file=/home/blurble/Doop.scala message=Missing or badly formed ScalaDoc: Extra @param foobles line=190
|
||||||
|
let l:patterns = [
|
||||||
|
\ '^\(.\+\) .\+ message=\(.\+\) line=\(\d\+\)$',
|
||||||
|
\ '^\(.\+\) .\+ message=\(.\+\) line=\(\d\+\) column=\(\d\+\)$',
|
||||||
|
\]
|
||||||
|
let l:output = []
|
||||||
|
|
||||||
|
for l:match in ale#util#GetMatches(a:lines, l:patterns)
|
||||||
|
let l:args = {
|
||||||
|
\ 'lnum': l:match[3] + 0,
|
||||||
|
\ 'type': l:match[1] =~? 'error' ? 'E' : 'W',
|
||||||
|
\ 'text': l:match[2]
|
||||||
|
\}
|
||||||
|
|
||||||
|
if !empty(l:match[4])
|
||||||
|
let l:args['col'] = l:match[4] + 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
call add(l:output, l:args)
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return l:output
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#scala#scalastyle#GetCommand(buffer) abort
|
||||||
|
" Search for scalastyle config in parent directories.
|
||||||
|
let l:scalastyle_config = ''
|
||||||
|
let l:potential_configs = [
|
||||||
|
\ 'scalastyle_config.xml',
|
||||||
|
\ 'scalastyle-config.xml'
|
||||||
|
\]
|
||||||
|
for l:config in l:potential_configs
|
||||||
|
let l:scalastyle_config = ale#path#ResolveLocalPath(
|
||||||
|
\ a:buffer,
|
||||||
|
\ l:config,
|
||||||
|
\ ''
|
||||||
|
\)
|
||||||
|
if !empty(l:scalastyle_config)
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
|
||||||
|
" If all else fails, try the global config.
|
||||||
|
if empty(l:scalastyle_config)
|
||||||
|
let l:scalastyle_config = get(g:, 'ale_scalastyle_config_loc', '')
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Build the command using the config file and additional options.
|
||||||
|
let l:command = 'scalastyle'
|
||||||
|
|
||||||
|
if !empty(l:scalastyle_config)
|
||||||
|
let l:command .= ' --config ' . ale#Escape(l:scalastyle_config)
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !empty(g:ale_scala_scalastyle_options)
|
||||||
|
let l:command .= ' ' . g:ale_scala_scalastyle_options
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:command .= ' %t'
|
||||||
|
|
||||||
|
return l:command
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('scala', {
|
||||||
|
\ 'name': 'scalastyle',
|
||||||
|
\ 'executable': 'scalastyle',
|
||||||
|
\ 'output_stream': 'stdout',
|
||||||
|
\ 'command_callback': 'ale_linters#scala#scalastyle#GetCommand',
|
||||||
|
\ 'callback': 'ale_linters#scala#scalastyle#Handle',
|
||||||
|
\})
|
||||||
@@ -19,7 +19,7 @@ function! ale_linters#scss#scsslint#Handle(buffer, lines) abort
|
|||||||
\ 'lnum': l:match[1] + 0,
|
\ 'lnum': l:match[1] + 0,
|
||||||
\ 'col': l:match[2] + 0,
|
\ 'col': l:match[2] + 0,
|
||||||
\ 'text': l:match[4],
|
\ 'text': l:match[4],
|
||||||
\ 'type': l:match[3] ==# 'E' ? 'E' : 'W',
|
\ 'type': l:match[3] is# 'E' ? 'E' : 'W',
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
|||||||
@@ -11,24 +11,16 @@ endif
|
|||||||
if !exists('g:ale_sh_shell_default_shell')
|
if !exists('g:ale_sh_shell_default_shell')
|
||||||
let g:ale_sh_shell_default_shell = fnamemodify($SHELL, ':t')
|
let g:ale_sh_shell_default_shell = fnamemodify($SHELL, ':t')
|
||||||
|
|
||||||
if g:ale_sh_shell_default_shell ==# '' || g:ale_sh_shell_default_shell ==# 'fish'
|
if g:ale_sh_shell_default_shell is# '' || g:ale_sh_shell_default_shell is# 'fish'
|
||||||
let g:ale_sh_shell_default_shell = 'bash'
|
let g:ale_sh_shell_default_shell = 'bash'
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
function! ale_linters#sh#shell#GetExecutable(buffer) abort
|
function! ale_linters#sh#shell#GetExecutable(buffer) abort
|
||||||
let l:banglines = getbufline(a:buffer, 1)
|
let l:shell_type = ale#handlers#sh#GetShellType(a:buffer)
|
||||||
|
|
||||||
" Take the shell executable from the hashbang, if we can.
|
if !empty(l:shell_type)
|
||||||
if len(l:banglines) == 1 && l:banglines[0] =~# '^#!'
|
return l:shell_type
|
||||||
" Remove options like -e, etc.
|
|
||||||
let l:line = substitute(l:banglines[0], '--\?[a-zA-Z0-9]\+', '', 'g')
|
|
||||||
|
|
||||||
for l:possible_shell in ['bash', 'tcsh', 'csh', 'zsh', 'sh']
|
|
||||||
if l:line =~# l:possible_shell . '\s*$'
|
|
||||||
return l:possible_shell
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return ale#Var(a:buffer, 'sh_shell_default_shell')
|
return ale#Var(a:buffer, 'sh_shell_default_shell')
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
" Description: This file adds support for using the shellcheck linter with
|
" Description: This file adds support for using the shellcheck linter with
|
||||||
" shell scripts.
|
" shell scripts.
|
||||||
|
|
||||||
" This global variable can be set with a string of comma-seperated error
|
" This global variable can be set with a string of comma-separated error
|
||||||
" codes to exclude from shellcheck. For example:
|
" codes to exclude from shellcheck. For example:
|
||||||
"
|
"
|
||||||
" let g:ale_sh_shellcheck_exclusions = 'SC2002,SC2004'
|
" let g:ale_sh_shellcheck_exclusions = 'SC2002,SC2004'
|
||||||
@@ -19,25 +19,40 @@ function! ale_linters#sh#shellcheck#GetExecutable(buffer) abort
|
|||||||
return ale#Var(a:buffer, 'sh_shellcheck_executable')
|
return ale#Var(a:buffer, 'sh_shellcheck_executable')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:GetDialectArgument() abort
|
function! ale_linters#sh#shellcheck#GetDialectArgument(buffer) abort
|
||||||
if exists('b:is_bash') && b:is_bash
|
let l:shell_type = ale#handlers#sh#GetShellType(a:buffer)
|
||||||
return '-s bash'
|
|
||||||
elseif exists('b:is_sh') && b:is_sh
|
if !empty(l:shell_type)
|
||||||
return '-s sh'
|
" Use the dash dialect for /bin/ash, etc.
|
||||||
elseif exists('b:is_kornshell') && b:is_kornshell
|
if l:shell_type is# 'ash'
|
||||||
return '-s ksh'
|
return 'dash'
|
||||||
|
endif
|
||||||
|
|
||||||
|
return l:shell_type
|
||||||
|
endif
|
||||||
|
|
||||||
|
" If there's no hashbang, try using Vim's buffer variables.
|
||||||
|
if getbufvar(a:buffer, 'is_bash', 0)
|
||||||
|
return 'bash'
|
||||||
|
elseif getbufvar(a:buffer, 'is_sh', 0)
|
||||||
|
return 'sh'
|
||||||
|
elseif getbufvar(a:buffer, 'is_kornshell', 0)
|
||||||
|
return 'ksh'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return ''
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#sh#shellcheck#GetCommand(buffer) abort
|
function! ale_linters#sh#shellcheck#GetCommand(buffer) abort
|
||||||
|
let l:options = ale#Var(a:buffer, 'sh_shellcheck_options')
|
||||||
let l:exclude_option = ale#Var(a:buffer, 'sh_shellcheck_exclusions')
|
let l:exclude_option = ale#Var(a:buffer, 'sh_shellcheck_exclusions')
|
||||||
|
let l:dialect = ale_linters#sh#shellcheck#GetDialectArgument(a:buffer)
|
||||||
|
|
||||||
return ale_linters#sh#shellcheck#GetExecutable(a:buffer)
|
return ale_linters#sh#shellcheck#GetExecutable(a:buffer)
|
||||||
\ . ' ' . ale#Var(a:buffer, 'sh_shellcheck_options')
|
\ . (!empty(l:dialect) ? ' -s ' . l:dialect : '')
|
||||||
\ . ' ' . (!empty(l:exclude_option) ? '-e ' . l:exclude_option : '')
|
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||||
\ . ' ' . s:GetDialectArgument() . ' -f gcc -'
|
\ . (!empty(l:exclude_option) ? ' -e ' . l:exclude_option : '')
|
||||||
|
\ . ' -f gcc -'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('sh', {
|
call ale#linter#Define('sh', {
|
||||||
|
|||||||
@@ -1,5 +1,25 @@
|
|||||||
" Author: Markus Doits - https://github.com/doits
|
" Author: Markus Doits - https://github.com/doits
|
||||||
" Description: slim-lint for Slim files, based on hamllint.vim
|
" Description: slim-lint for Slim files
|
||||||
|
|
||||||
|
function! ale_linters#slim#slimlint#GetCommand(buffer) abort
|
||||||
|
let l:command = 'slim-lint %t'
|
||||||
|
|
||||||
|
let l:rubocop_config = ale#path#FindNearestFile(a:buffer, '.rubocop.yml')
|
||||||
|
|
||||||
|
" Set SLIM_LINT_RUBOCOP_CONF variable as it is needed for slim-lint to
|
||||||
|
" pick up the rubocop config.
|
||||||
|
"
|
||||||
|
" See https://github.com/sds/slim-lint/blob/master/lib/slim_lint/linter/README.md#rubocop
|
||||||
|
if !empty(l:rubocop_config)
|
||||||
|
if ale#Has('win32')
|
||||||
|
let l:command = 'set SLIM_LINT_RUBOCOP_CONF=' . ale#Escape(l:rubocop_config) . ' && ' . l:command
|
||||||
|
else
|
||||||
|
let l:command = 'SLIM_LINT_RUBOCOP_CONF=' . ale#Escape(l:rubocop_config) . ' ' . l:command
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
return l:command
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#slim#slimlint#Handle(buffer, lines) abort
|
function! ale_linters#slim#slimlint#Handle(buffer, lines) abort
|
||||||
" Matches patterns like the following:
|
" Matches patterns like the following:
|
||||||
@@ -21,6 +41,6 @@ endfunction
|
|||||||
call ale#linter#Define('slim', {
|
call ale#linter#Define('slim', {
|
||||||
\ 'name': 'slimlint',
|
\ 'name': 'slimlint',
|
||||||
\ 'executable': 'slim-lint',
|
\ 'executable': 'slim-lint',
|
||||||
\ 'command': 'slim-lint %t',
|
\ 'command_callback': 'ale_linters#slim#slimlint#GetCommand',
|
||||||
\ 'callback': 'ale_linters#slim#slimlint#Handle'
|
\ 'callback': 'ale_linters#slim#slimlint#Handle'
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -1,47 +1,9 @@
|
|||||||
" Author: Paulo Alem <paulo.alem@gmail.com>
|
" Author: Paulo Alem <paulo.alem@gmail.com>, Jake Zimmerman <jake@zimmerman.io>
|
||||||
" Description: Rudimentary SML checking with smlnj compiler
|
" Description: Single-file SML checking with SML/NJ compiler
|
||||||
|
|
||||||
function! ale_linters#sml#smlnj#Handle(buffer, lines) abort
|
|
||||||
" Try to match basic sml errors
|
|
||||||
|
|
||||||
let l:out = []
|
|
||||||
let l:pattern = '^.*\:\([0-9\.]\+\)\ \(\w\+\)\:\ \(.*\)'
|
|
||||||
let l:pattern2 = '^.*\:\([0-9]\+\)\.\?\([0-9]\+\).* \(\(Warning\|Error\): .*\)'
|
|
||||||
|
|
||||||
for l:line in a:lines
|
|
||||||
let l:match2 = matchlist(l:line, l:pattern2)
|
|
||||||
|
|
||||||
if len(l:match2) != 0
|
|
||||||
call add(l:out, {
|
|
||||||
\ 'bufnr': a:buffer,
|
|
||||||
\ 'lnum': l:match2[1] + 0,
|
|
||||||
\ 'col' : l:match2[2] - 1,
|
|
||||||
\ 'text': l:match2[3],
|
|
||||||
\ 'type': l:match2[3] =~# '^Warning' ? 'W' : 'E',
|
|
||||||
\})
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
|
|
||||||
let l:match = matchlist(l:line, l:pattern)
|
|
||||||
|
|
||||||
if len(l:match) != 0
|
|
||||||
call add(l:out, {
|
|
||||||
\ 'bufnr': a:buffer,
|
|
||||||
\ 'lnum': l:match[1] + 0,
|
|
||||||
\ 'text': l:match[2] . ': ' . l:match[3],
|
|
||||||
\ 'type': l:match[2] ==# 'error' ? 'E' : 'W',
|
|
||||||
\})
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
|
|
||||||
endfor
|
|
||||||
|
|
||||||
return l:out
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
call ale#linter#Define('sml', {
|
call ale#linter#Define('sml', {
|
||||||
\ 'name': 'smlnj',
|
\ 'name': 'smlnj',
|
||||||
\ 'executable': 'sml',
|
\ 'executable_callback': 'ale#handlers#sml#GetExecutableSmlnjFile',
|
||||||
\ 'command': 'sml',
|
\ 'command': 'sml',
|
||||||
\ 'callback': 'ale_linters#sml#smlnj#Handle',
|
\ 'callback': 'ale#handlers#sml#Handle',
|
||||||
\})
|
\})
|
||||||
|
|||||||
19
ale_linters/sml/smlnj_cm.vim
Normal file
19
ale_linters/sml/smlnj_cm.vim
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
" Author: Jake Zimmerman <jake@zimmerman.io>
|
||||||
|
" Description: SML checking with SML/NJ Compilation Manager
|
||||||
|
|
||||||
|
function! ale_linters#sml#smlnj_cm#GetCommand(buffer) abort
|
||||||
|
let l:cmfile = ale#handlers#sml#GetCmFile(a:buffer)
|
||||||
|
return 'sml -m ' . l:cmfile . ' < /dev/null'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Using CM requires that we set "lint_file: 1", since it reads the files
|
||||||
|
" from the disk itself.
|
||||||
|
call ale#linter#Define('sml', {
|
||||||
|
\ 'name': 'smlnj-cm',
|
||||||
|
\ 'executable_callback': 'ale#handlers#sml#GetExecutableSmlnjCm',
|
||||||
|
\ 'lint_file': 1,
|
||||||
|
\ 'command_callback': 'ale_linters#sml#smlnj_cm#GetCommand',
|
||||||
|
\ 'callback': 'ale#handlers#sml#Handle',
|
||||||
|
\})
|
||||||
|
|
||||||
|
" vim:ts=4:sts=4:sw=4
|
||||||
9
ale_linters/solidity/solium.vim
Normal file
9
ale_linters/solidity/solium.vim
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
" Author: Jeff Sutherland - https://github.com/jdsutherland
|
||||||
|
" Description: Report errors in Solidity code with solium
|
||||||
|
|
||||||
|
call ale#linter#Define('solidity', {
|
||||||
|
\ 'name': 'solium',
|
||||||
|
\ 'executable': 'solium',
|
||||||
|
\ 'command': 'solium --reporter gcc --file %t',
|
||||||
|
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
||||||
|
\})
|
||||||
24
ale_linters/stylus/stylelint.vim
Normal file
24
ale_linters/stylus/stylelint.vim
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
" Author: diartyz <diartyz@gmail.com>, w0rp <devw0rp@gmail.com>
|
||||||
|
|
||||||
|
call ale#Set('stylus_stylelint_executable', 'stylelint')
|
||||||
|
call ale#Set('stylus_stylelint_options', '')
|
||||||
|
call ale#Set('stylus_stylelint_use_global', 0)
|
||||||
|
|
||||||
|
function! ale_linters#stylus#stylelint#GetExecutable(buffer) abort
|
||||||
|
return ale#node#FindExecutable(a:buffer, 'stylus_stylelint', [
|
||||||
|
\ 'node_modules/.bin/stylelint',
|
||||||
|
\])
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#stylus#stylelint#GetCommand(buffer) abort
|
||||||
|
return ale_linters#stylus#stylelint#GetExecutable(a:buffer)
|
||||||
|
\ . ' ' . ale#Var(a:buffer, 'stylus_stylelint_options')
|
||||||
|
\ . ' --stdin-filename %s'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('stylus', {
|
||||||
|
\ 'name': 'stylelint',
|
||||||
|
\ 'executable_callback': 'ale_linters#stylus#stylelint#GetExecutable',
|
||||||
|
\ 'command_callback': 'ale_linters#stylus#stylelint#GetCommand',
|
||||||
|
\ 'callback': 'ale#handlers#css#HandleStyleLintFormat',
|
||||||
|
\})
|
||||||
46
ale_linters/tcl/nagelfar.vim
Normal file
46
ale_linters/tcl/nagelfar.vim
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
" Author: Nick James <github@nsjuk.xyz>
|
||||||
|
" Description: nagelfar linter for tcl files
|
||||||
|
|
||||||
|
call ale#Set('tcl_nagelfar_executable', 'nagelfar.tcl')
|
||||||
|
call ale#Set('tcl_nagelfar_options', '')
|
||||||
|
|
||||||
|
function! ale_linters#tcl#nagelfar#GetExecutable(buffer) abort
|
||||||
|
return ale#Var(a:buffer, 'tcl_nagelfar_executable')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#tcl#nagelfar#GetCommand(buffer) abort
|
||||||
|
let l:options = ale#Var(a:buffer, 'tcl_nagelfar_options')
|
||||||
|
|
||||||
|
return ale#Escape(ale_linters#tcl#nagelfar#GetExecutable(a:buffer))
|
||||||
|
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||||
|
\ . ' %s'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#tcl#nagelfar#Handle(buffer, lines) abort
|
||||||
|
" Matches patterns like the following:
|
||||||
|
" Line 5: W Found constant "bepa" which is also a variable.
|
||||||
|
" Line 13: E Wrong number of arguments (3) to "set"
|
||||||
|
" Line 93: N Close brace not aligned with line 90 (4 0)
|
||||||
|
|
||||||
|
let l:pattern = '^Line\s\+\([0-9]\+\): \([NEW]\) \(.*\)$'
|
||||||
|
let l:output = []
|
||||||
|
|
||||||
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
|
call add(l:output, {
|
||||||
|
\ 'lnum': l:match[1] + 0,
|
||||||
|
\ 'type': l:match[2] is# 'N' ? 'W' : l:match[2],
|
||||||
|
\ 'text': l:match[3],
|
||||||
|
\})
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return l:output
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('tcl', {
|
||||||
|
\ 'name': 'nagelfar',
|
||||||
|
\ 'output_stream': 'stdout',
|
||||||
|
\ 'executable_callback': 'ale_linters#tcl#nagelfar#GetExecutable',
|
||||||
|
\ 'command_callback': 'ale_linters#tcl#nagelfar#GetCommand',
|
||||||
|
\ 'callback': 'ale_linters#tcl#nagelfar#Handle',
|
||||||
|
\ 'lint_file': 1,
|
||||||
|
\})
|
||||||
91
ale_linters/thrift/thrift.vim
Normal file
91
ale_linters/thrift/thrift.vim
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
" Author: Jon Parise <jon@indelible.org>
|
||||||
|
|
||||||
|
call ale#Set('thrift_thrift_executable', 'thrift')
|
||||||
|
call ale#Set('thrift_thrift_generators', ['cpp'])
|
||||||
|
call ale#Set('thrift_thrift_includes', [])
|
||||||
|
call ale#Set('thrift_thrift_options', '-strict')
|
||||||
|
|
||||||
|
function! ale_linters#thrift#thrift#GetExecutable(buffer) abort
|
||||||
|
return ale#Var(a:buffer, 'thrift_thrift_executable')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#thrift#thrift#GetCommand(buffer) abort
|
||||||
|
let l:generators = ale#Var(a:buffer, 'thrift_thrift_generators')
|
||||||
|
let l:includes = ale#Var(a:buffer, 'thrift_thrift_includes')
|
||||||
|
|
||||||
|
" The thrift compiler requires at least one generator. If none are set,
|
||||||
|
" fall back to our default value to avoid silently failing. We could also
|
||||||
|
" `throw` here, but that seems even less helpful.
|
||||||
|
if empty(l:generators)
|
||||||
|
let l:generators = ['cpp']
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:output_dir = tempname()
|
||||||
|
call mkdir(l:output_dir)
|
||||||
|
call ale#engine#ManageDirectory(a:buffer, l:output_dir)
|
||||||
|
|
||||||
|
return ale#Escape(ale_linters#thrift#thrift#GetExecutable(a:buffer))
|
||||||
|
\ . ' ' . join(map(copy(l:generators), "'--gen ' . v:val"))
|
||||||
|
\ . ' ' . join(map(copy(l:includes), "'-I ' . v:val"))
|
||||||
|
\ . ' ' . ale#Var(a:buffer, 'thrift_thrift_options')
|
||||||
|
\ . ' -out ' . ale#Escape(l:output_dir)
|
||||||
|
\ . ' %t'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#thrift#thrift#Handle(buffer, lines) abort
|
||||||
|
" Matches lines like the following:
|
||||||
|
"
|
||||||
|
" [SEVERITY:/path/filename.thrift:31] Message text
|
||||||
|
" [ERROR:/path/filename.thrift:31] (last token was ';')
|
||||||
|
let l:pattern = '\v^\[(\u+):(.*):(\d+)\] (.*)$'
|
||||||
|
|
||||||
|
let l:index = 0
|
||||||
|
let l:output = []
|
||||||
|
|
||||||
|
" Roll our own output-matching loop instead of using ale#util#GetMatches
|
||||||
|
" because we need to support error messages that span multiple lines.
|
||||||
|
while l:index < len(a:lines)
|
||||||
|
let l:line = a:lines[l:index]
|
||||||
|
|
||||||
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
if empty(l:match)
|
||||||
|
let l:index += 1
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:severity = l:match[1]
|
||||||
|
if l:severity is# 'WARNING'
|
||||||
|
let l:type = 'W'
|
||||||
|
else
|
||||||
|
let l:type = 'E'
|
||||||
|
endif
|
||||||
|
|
||||||
|
" If our text looks like "(last token was ';')", the *next* line
|
||||||
|
" should contain a more descriptive error message.
|
||||||
|
let l:text = l:match[4]
|
||||||
|
if l:text =~# '\(last token was .*\)'
|
||||||
|
let l:index += 1
|
||||||
|
let l:text = get(a:lines, l:index, 'Unknown error ' . l:text)
|
||||||
|
endif
|
||||||
|
|
||||||
|
call add(l:output, {
|
||||||
|
\ 'lnum': l:match[3] + 0,
|
||||||
|
\ 'col': 0,
|
||||||
|
\ 'type': l:type,
|
||||||
|
\ 'text': l:text,
|
||||||
|
\})
|
||||||
|
|
||||||
|
let l:index += 1
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
return l:output
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('thrift', {
|
||||||
|
\ 'name': 'thrift',
|
||||||
|
\ 'executable': 'thrift',
|
||||||
|
\ 'output_stream': 'both',
|
||||||
|
\ 'executable_callback': 'ale_linters#thrift#thrift#GetExecutable',
|
||||||
|
\ 'command_callback': 'ale_linters#thrift#thrift#GetCommand',
|
||||||
|
\ 'callback': 'ale_linters#thrift#thrift#Handle',
|
||||||
|
\})
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
" Author: Prashanth Chandra https://github.com/prashcr
|
" Author: Prashanth Chandra <https://github.com/prashcr>, Jonathan Clem <https://jclem.net>
|
||||||
" Description: tslint for TypeScript files
|
" Description: tslint for TypeScript files
|
||||||
|
|
||||||
call ale#Set('typescript_tslint_executable', 'tslint')
|
call ale#Set('typescript_tslint_executable', 'tslint')
|
||||||
call ale#Set('typescript_tslint_config_path', '')
|
call ale#Set('typescript_tslint_config_path', '')
|
||||||
|
call ale#Set('typescript_tslint_rules_dir', '')
|
||||||
call ale#Set('typescript_tslint_use_global', 0)
|
call ale#Set('typescript_tslint_use_global', 0)
|
||||||
|
call ale#Set('typescript_tslint_ignore_empty_files', 0)
|
||||||
|
|
||||||
function! ale_linters#typescript#tslint#GetExecutable(buffer) abort
|
function! ale_linters#typescript#tslint#GetExecutable(buffer) abort
|
||||||
return ale#node#FindExecutable(a:buffer, 'typescript_tslint', [
|
return ale#node#FindExecutable(a:buffer, 'typescript_tslint', [
|
||||||
@@ -12,44 +14,62 @@ function! ale_linters#typescript#tslint#GetExecutable(buffer) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#typescript#tslint#Handle(buffer, lines) abort
|
function! ale_linters#typescript#tslint#Handle(buffer, lines) abort
|
||||||
|
" Do not output any errors for empty files if the option is on.
|
||||||
|
if ale#Var(a:buffer, 'typescript_tslint_ignore_empty_files')
|
||||||
|
\&& getbufline(a:buffer, 1, '$') == ['']
|
||||||
|
return []
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:dir = expand('#' . a:buffer . ':p:h')
|
||||||
let l:output = []
|
let l:output = []
|
||||||
|
|
||||||
for l:error in json_decode(join(a:lines, ''))
|
for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
|
||||||
if ale#path#IsBufferPath(a:buffer, l:error.name)
|
if get(l:error, 'ruleName', '') is# 'no-implicit-dependencies'
|
||||||
call add(l:output, {
|
continue
|
||||||
\ 'type': (get(l:error, 'ruleSeverity', '') ==# 'WARNING' ? 'W' : 'E'),
|
|
||||||
\ 'text': l:error.failure,
|
|
||||||
\ 'lnum': l:error.startPosition.line + 1,
|
|
||||||
\ 'col': l:error.startPosition.character + 1,
|
|
||||||
\ 'end_lnum': l:error.endPosition.line + 1,
|
|
||||||
\ 'end_col': l:error.endPosition.character + 1,
|
|
||||||
\})
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
call add(l:output, {
|
||||||
|
\ 'filename': ale#path#GetAbsPath(l:dir, l:error.name),
|
||||||
|
\ 'type': (get(l:error, 'ruleSeverity', '') is# 'WARNING' ? 'W' : 'E'),
|
||||||
|
\ 'text': has_key(l:error, 'ruleName')
|
||||||
|
\ ? l:error.ruleName . ': ' . l:error.failure
|
||||||
|
\ : l:error.failure,
|
||||||
|
\ 'lnum': l:error.startPosition.line + 1,
|
||||||
|
\ 'col': l:error.startPosition.character + 1,
|
||||||
|
\ 'end_lnum': l:error.endPosition.line + 1,
|
||||||
|
\ 'end_col': l:error.endPosition.character + 1,
|
||||||
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return l:output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#typescript#tslint#BuildLintCommand(buffer) abort
|
function! ale_linters#typescript#tslint#GetCommand(buffer) abort
|
||||||
let l:tslint_config_path = ale#path#ResolveLocalPath(
|
let l:tslint_config_path = ale#path#ResolveLocalPath(
|
||||||
\ a:buffer,
|
\ a:buffer,
|
||||||
\ 'tslint.json',
|
\ 'tslint.json',
|
||||||
\ ale#Var(a:buffer, 'typescript_tslint_config_path')
|
\ ale#Var(a:buffer, 'typescript_tslint_config_path')
|
||||||
\)
|
\)
|
||||||
|
|
||||||
let l:tslint_config_option = !empty(l:tslint_config_path)
|
let l:tslint_config_option = !empty(l:tslint_config_path)
|
||||||
\ ? ' -c ' . ale#Escape(l:tslint_config_path)
|
\ ? ' -c ' . ale#Escape(l:tslint_config_path)
|
||||||
\ : ''
|
\ : ''
|
||||||
|
|
||||||
return ale_linters#typescript#tslint#GetExecutable(a:buffer)
|
let l:tslint_rules_dir = ale#Var(a:buffer, 'typescript_tslint_rules_dir')
|
||||||
|
let l:tslint_rules_option = !empty(l:tslint_rules_dir)
|
||||||
|
\ ? ' -r ' . ale#Escape(l:tslint_rules_dir)
|
||||||
|
\ : ''
|
||||||
|
|
||||||
|
return ale#path#BufferCdString(a:buffer)
|
||||||
|
\ . ale_linters#typescript#tslint#GetExecutable(a:buffer)
|
||||||
\ . ' --format json'
|
\ . ' --format json'
|
||||||
\ . l:tslint_config_option
|
\ . l:tslint_config_option
|
||||||
|
\ . l:tslint_rules_option
|
||||||
\ . ' %t'
|
\ . ' %t'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('typescript', {
|
call ale#linter#Define('typescript', {
|
||||||
\ 'name': 'tslint',
|
\ 'name': 'tslint',
|
||||||
\ 'executable_callback': 'ale_linters#typescript#tslint#GetExecutable',
|
\ 'executable_callback': 'ale_linters#typescript#tslint#GetExecutable',
|
||||||
\ 'command_callback': 'ale_linters#typescript#tslint#BuildLintCommand',
|
\ 'command_callback': 'ale_linters#typescript#tslint#GetCommand',
|
||||||
\ 'callback': 'ale_linters#typescript#tslint#Handle',
|
\ 'callback': 'ale_linters#typescript#tslint#Handle',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -5,19 +5,26 @@ call ale#Set('typescript_tsserver_executable', 'tsserver')
|
|||||||
call ale#Set('typescript_tsserver_config_path', '')
|
call ale#Set('typescript_tsserver_config_path', '')
|
||||||
call ale#Set('typescript_tsserver_use_global', 0)
|
call ale#Set('typescript_tsserver_use_global', 0)
|
||||||
|
|
||||||
|
" These functions need to be defined just to comply with the API for LSP.
|
||||||
|
function! ale_linters#typescript#tsserver#GetProjectRoot(buffer) abort
|
||||||
|
return ''
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#typescript#tsserver#GetLanguage(buffer) abort
|
||||||
|
return ''
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#typescript#tsserver#GetExecutable(buffer) abort
|
function! ale_linters#typescript#tsserver#GetExecutable(buffer) abort
|
||||||
return ale#node#FindExecutable(a:buffer, 'typescript_tsserver', [
|
return ale#node#FindExecutable(a:buffer, 'typescript_tsserver', [
|
||||||
\ 'node_modules/.bin/tsserver',
|
\ 'node_modules/.bin/tsserver',
|
||||||
\])
|
\])
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#typescript#tsserver#Handle(buffer, lines) abort
|
|
||||||
return a:lines
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
call ale#linter#Define('typescript', {
|
call ale#linter#Define('typescript', {
|
||||||
\ 'name': 'tsserver',
|
\ 'name': 'tsserver',
|
||||||
\ 'lsp': 'tsserver',
|
\ 'lsp': 'tsserver',
|
||||||
\ 'executable_callback': 'ale_linters#typescript#tsserver#GetExecutable',
|
\ 'executable_callback': 'ale_linters#typescript#tsserver#GetExecutable',
|
||||||
\ 'callback': 'ale_linters#typescript#tsserver#Handle',
|
\ 'command_callback': 'ale_linters#typescript#tsserver#GetExecutable',
|
||||||
|
\ 'project_root_callback': 'ale_linters#typescript#tsserver#GetProjectRoot',
|
||||||
|
\ 'language_callback': 'ale_linters#typescript#tsserver#GetLanguage',
|
||||||
\})
|
\})
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ function! ale_linters#verilog#iverilog#Handle(buffer, lines) abort
|
|||||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
let l:line = l:match[1] + 0
|
let l:line = l:match[1] + 0
|
||||||
let l:type = l:match[2] =~# 'error' ? 'E' : 'W'
|
let l:type = l:match[2] =~# 'error' ? 'E' : 'W'
|
||||||
let l:text = l:match[2] ==# 'syntax error' ? 'syntax error' : l:match[4]
|
let l:text = l:match[2] is# 'syntax error' ? 'syntax error' : l:match[4]
|
||||||
|
|
||||||
call add(l:output, {
|
call add(l:output, {
|
||||||
\ 'lnum': l:line,
|
\ 'lnum': l:line,
|
||||||
|
|||||||
@@ -1,14 +1,22 @@
|
|||||||
" Author: Masahiro H https://github.com/mshr-h
|
" Author: Masahiro H https://github.com/mshr-h
|
||||||
" Description: verilator for verilog files
|
" Description: verilator for verilog files
|
||||||
|
|
||||||
|
" Set this option to change Verilator lint options
|
||||||
|
if !exists('g:ale_verilog_verilator_options')
|
||||||
|
let g:ale_verilog_verilator_options = ''
|
||||||
|
endif
|
||||||
|
|
||||||
function! ale_linters#verilog#verilator#GetCommand(buffer) abort
|
function! ale_linters#verilog#verilator#GetCommand(buffer) abort
|
||||||
let l:filename = tempname() . '_verilator_linted.v'
|
let l:filename = tempname() . '_verilator_linted.v'
|
||||||
|
|
||||||
" Create a special filename, so we can detect it in the handler.
|
" Create a special filename, so we can detect it in the handler.
|
||||||
call ale#engine#ManageFile(a:buffer, l:filename)
|
call ale#engine#ManageFile(a:buffer, l:filename)
|
||||||
call writefile(getbufline(a:buffer, 1, '$'), l:filename)
|
let l:lines = getbufline(a:buffer, 1, '$')
|
||||||
|
call ale#util#Writefile(a:buffer, l:lines, l:filename)
|
||||||
|
|
||||||
return 'verilator --lint-only -Wall -Wno-DECLFILENAME ' . ale#Escape(l:filename)
|
return 'verilator --lint-only -Wall -Wno-DECLFILENAME '
|
||||||
|
\ . ale#Var(a:buffer, 'verilog_verilator_options') .' '
|
||||||
|
\ . ale#Escape(l:filename)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#verilog#verilator#Handle(buffer, lines) abort
|
function! ale_linters#verilog#verilator#Handle(buffer, lines) abort
|
||||||
@@ -25,7 +33,7 @@ function! ale_linters#verilog#verilator#Handle(buffer, lines) abort
|
|||||||
|
|
||||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
let l:line = l:match[3] + 0
|
let l:line = l:match[3] + 0
|
||||||
let l:type = l:match[1] ==# 'Error' ? 'E' : 'W'
|
let l:type = l:match[1] is# 'Error' ? 'E' : 'W'
|
||||||
let l:text = l:match[4]
|
let l:text = l:match[4]
|
||||||
let l:file = l:match[2]
|
let l:file = l:match[2]
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,32 @@ function! ale_linters#vim#vint#GetCommand(buffer, version_output) abort
|
|||||||
\ . ' %t'
|
\ . ' %t'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
let s:word_regex_list = [
|
||||||
|
\ '\v^Undefined variable: ([^ ]+)',
|
||||||
|
\ '\v^Make the scope explicit like ...([^ ]+). ',
|
||||||
|
\ '\v^.*start with a capital or contain a colon: ([^ ]+)',
|
||||||
|
\ '\v.*instead of .(\=[=~]).',
|
||||||
|
\]
|
||||||
|
|
||||||
|
function! ale_linters#vim#vint#Handle(buffer, lines) abort
|
||||||
|
let l:loclist = ale#handlers#gcc#HandleGCCFormat(a:buffer, a:lines)
|
||||||
|
|
||||||
|
for l:item in l:loclist
|
||||||
|
let l:match = []
|
||||||
|
|
||||||
|
for l:regex in s:word_regex_list
|
||||||
|
let l:match = matchlist(l:item.text, l:regex)
|
||||||
|
|
||||||
|
if !empty(l:match)
|
||||||
|
let l:item.end_col = l:item.col + len(l:match[1]) - 1
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return l:loclist
|
||||||
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('vim', {
|
call ale#linter#Define('vim', {
|
||||||
\ 'name': 'vint',
|
\ 'name': 'vint',
|
||||||
\ 'executable': 'vint',
|
\ 'executable': 'vint',
|
||||||
@@ -43,5 +69,5 @@ call ale#linter#Define('vim', {
|
|||||||
\ {'callback': 'ale_linters#vim#vint#VersionCommand', 'output_stream': 'stderr'},
|
\ {'callback': 'ale_linters#vim#vint#VersionCommand', 'output_stream': 'stderr'},
|
||||||
\ {'callback': 'ale_linters#vim#vint#GetCommand', 'output_stream': 'stdout'},
|
\ {'callback': 'ale_linters#vim#vint#GetCommand', 'output_stream': 'stdout'},
|
||||||
\ ],
|
\ ],
|
||||||
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
\ 'callback': 'ale_linters#vim#vint#Handle',
|
||||||
\})
|
\})
|
||||||
|
|||||||
41
ale_linters/yaml/swaglint.vim
Normal file
41
ale_linters/yaml/swaglint.vim
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
" Author: Matthew Turland <https://github.com/elazar>
|
||||||
|
" Description: This file adds support for linting Swagger / OpenAPI documents using swaglint
|
||||||
|
|
||||||
|
call ale#Set('yaml_swaglint_executable', 'swaglint')
|
||||||
|
call ale#Set('yaml_swaglint_use_global', 0)
|
||||||
|
|
||||||
|
function! ale_linters#yaml#swaglint#GetExecutable(buffer) abort
|
||||||
|
return ale#node#FindExecutable(a:buffer, 'yaml_swaglint', [
|
||||||
|
\ 'node_modules/.bin/swaglint',
|
||||||
|
\])
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#yaml#swaglint#GetCommand(buffer) abort
|
||||||
|
return ale_linters#yaml#swaglint#GetExecutable(a:buffer)
|
||||||
|
\ . ' -r compact --stdin'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#yaml#swaglint#Handle(buffer, lines) abort
|
||||||
|
let l:pattern = ': \([^\s]\+\) @ \(\d\+\):\(\d\+\) - \(.\+\)$'
|
||||||
|
let l:output = []
|
||||||
|
|
||||||
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
|
let l:obj = {
|
||||||
|
\ 'type': l:match[1] is# 'error' ? 'E' : 'W',
|
||||||
|
\ 'lnum': l:match[2] + 0,
|
||||||
|
\ 'col': l:match[3] + 0,
|
||||||
|
\ 'text': l:match[4],
|
||||||
|
\}
|
||||||
|
|
||||||
|
call add(l:output, l:obj)
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return l:output
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('yaml', {
|
||||||
|
\ 'name': 'swaglint',
|
||||||
|
\ 'executable_callback': 'ale_linters#yaml#swaglint#GetExecutable',
|
||||||
|
\ 'command_callback': 'ale_linters#yaml#swaglint#GetCommand',
|
||||||
|
\ 'callback': 'ale_linters#yaml#swaglint#Handle',
|
||||||
|
\})
|
||||||
@@ -33,7 +33,7 @@ function! ale_linters#yaml#yamllint#Handle(buffer, lines) abort
|
|||||||
\ 'lnum': l:line,
|
\ 'lnum': l:line,
|
||||||
\ 'col': l:col,
|
\ 'col': l:col,
|
||||||
\ 'text': l:text,
|
\ 'text': l:text,
|
||||||
\ 'type': l:type ==# 'error' ? 'E' : 'W',
|
\ 'type': l:type is# 'error' ? 'E' : 'W',
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
|||||||
185
autoload/ale.vim
185
autoload/ale.vim
@@ -5,6 +5,31 @@
|
|||||||
let s:lint_timer = -1
|
let s:lint_timer = -1
|
||||||
let s:queued_buffer_number = -1
|
let s:queued_buffer_number = -1
|
||||||
let s:should_lint_file_for_buffer = {}
|
let s:should_lint_file_for_buffer = {}
|
||||||
|
let s:error_delay_ms = 1000 * 60 * 2
|
||||||
|
|
||||||
|
let s:timestamp_map = {}
|
||||||
|
|
||||||
|
" Given a key for a script variable for tracking the time to wait until
|
||||||
|
" a given function should be called, a funcref for a function to call, and
|
||||||
|
" a List of arguments, call the function and return whatever value it returns.
|
||||||
|
"
|
||||||
|
" If the function throws an exception, then the function will not be called
|
||||||
|
" for a while, and 0 will be returned instead.
|
||||||
|
function! ale#CallWithCooldown(timestamp_key, func, arglist) abort
|
||||||
|
let l:now = ale#util#ClockMilliseconds()
|
||||||
|
|
||||||
|
if l:now < get(s:timestamp_map, a:timestamp_key, -1)
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
let s:timestamp_map[a:timestamp_key] = l:now + s:error_delay_ms
|
||||||
|
|
||||||
|
let l:return_value = call(a:func, a:arglist)
|
||||||
|
|
||||||
|
let s:timestamp_map[a:timestamp_key] = -1
|
||||||
|
|
||||||
|
return l:return_value
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Return 1 if a file is too large for ALE to handle.
|
" Return 1 if a file is too large for ALE to handle.
|
||||||
function! ale#FileTooLarge() abort
|
function! ale#FileTooLarge() abort
|
||||||
@@ -13,39 +38,93 @@ function! ale#FileTooLarge() abort
|
|||||||
return l:max > 0 ? (line2byte(line('$') + 1) > l:max) : 0
|
return l:max > 0 ? (line2byte(line('$') + 1) > l:max) : 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
let s:getcmdwintype_exists = exists('*getcmdwintype')
|
||||||
|
|
||||||
" A function for checking various conditions whereby ALE just shouldn't
|
" A function for checking various conditions whereby ALE just shouldn't
|
||||||
" attempt to do anything, say if particular buffer types are open in Vim.
|
" attempt to do anything, say if particular buffer types are open in Vim.
|
||||||
function! ale#ShouldDoNothing() abort
|
function! ale#ShouldDoNothing(buffer) abort
|
||||||
|
" The checks are split into separate if statements to make it possible to
|
||||||
|
" profile each check individually with Vim's profiling tools.
|
||||||
|
|
||||||
|
" Don't perform any checks when newer NeoVim versions are exiting.
|
||||||
|
if get(v:, 'exiting', v:null) isnot v:null
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
|
||||||
" Do nothing for blacklisted files
|
" Do nothing for blacklisted files
|
||||||
" OR if ALE is running in the sandbox
|
if index(g:ale_filetype_blacklist, getbufvar(a:buffer, '&filetype')) >= 0
|
||||||
return index(g:ale_filetype_blacklist, &filetype) >= 0
|
return 1
|
||||||
\ || (exists('*getcmdwintype') && !empty(getcmdwintype()))
|
endif
|
||||||
\ || ale#util#InSandbox()
|
|
||||||
\ || !ale#Var(bufnr(''), 'enabled')
|
" Do nothing if running from command mode
|
||||||
\ || ale#FileTooLarge()
|
if s:getcmdwintype_exists && !empty(getcmdwintype())
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:filename = fnamemodify(bufname(a:buffer), ':t')
|
||||||
|
|
||||||
|
if l:filename is# '.'
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Do nothing if running in the sandbox
|
||||||
|
if ale#util#InSandbox()
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Do nothing if ALE is disabled.
|
||||||
|
if !ale#Var(a:buffer, 'enabled')
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Do nothing if the file is too large.
|
||||||
|
if ale#FileTooLarge()
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Do nothing from CtrlP buffers with CtrlP-funky.
|
||||||
|
if exists(':CtrlPFunky') is 2
|
||||||
|
\&& getbufvar(a:buffer, '&l:statusline') =~# 'CtrlPMode.*funky'
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
return 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" (delay, [linting_flag])
|
" (delay, [linting_flag, buffer_number])
|
||||||
function! ale#Queue(delay, ...) abort
|
function! ale#Queue(delay, ...) abort
|
||||||
if len(a:0) > 1
|
if a:0 > 2
|
||||||
throw 'too many arguments!'
|
throw 'too many arguments!'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Default linting_flag to ''
|
" Default linting_flag to ''
|
||||||
let l:linting_flag = get(a:000, 0, '')
|
let l:linting_flag = get(a:000, 0, '')
|
||||||
|
let l:buffer = get(a:000, 1, bufnr(''))
|
||||||
|
|
||||||
if l:linting_flag !=# '' && l:linting_flag !=# 'lint_file'
|
return ale#CallWithCooldown(
|
||||||
|
\ 'dont_queue_until',
|
||||||
|
\ function('s:ALEQueueImpl'),
|
||||||
|
\ [a:delay, l:linting_flag, l:buffer],
|
||||||
|
\)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:ALEQueueImpl(delay, linting_flag, buffer) abort
|
||||||
|
if a:linting_flag isnot# '' && a:linting_flag isnot# 'lint_file'
|
||||||
throw "linting_flag must be either '' or 'lint_file'"
|
throw "linting_flag must be either '' or 'lint_file'"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if ale#ShouldDoNothing()
|
if type(a:buffer) != type(0)
|
||||||
|
throw 'buffer_number must be a Number'
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ale#ShouldDoNothing(a:buffer)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Remember that we want to check files for this buffer.
|
" Remember that we want to check files for this buffer.
|
||||||
" We will remember this until we finally run the linters, via any event.
|
" We will remember this until we finally run the linters, via any event.
|
||||||
if l:linting_flag ==# 'lint_file'
|
if a:linting_flag is# 'lint_file'
|
||||||
let s:should_lint_file_for_buffer[bufnr('%')] = 1
|
let s:should_lint_file_for_buffer[a:buffer] = 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if s:lint_timer != -1
|
if s:lint_timer != -1
|
||||||
@@ -53,63 +132,63 @@ function! ale#Queue(delay, ...) abort
|
|||||||
let s:lint_timer = -1
|
let s:lint_timer = -1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let l:linters = ale#linter#Get(&filetype)
|
let l:linters = ale#linter#Get(getbufvar(a:buffer, '&filetype'))
|
||||||
if len(l:linters) == 0
|
|
||||||
" There are no linters to lint with, so stop here.
|
" Don't set up buffer data and so on if there are no linters to run.
|
||||||
|
if empty(l:linters)
|
||||||
|
" If we have some previous buffer data, then stop any jobs currently
|
||||||
|
" running and clear everything.
|
||||||
|
if has_key(g:ale_buffer_info, a:buffer)
|
||||||
|
call ale#engine#RunLinters(a:buffer, [], 1)
|
||||||
|
endif
|
||||||
|
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if a:delay > 0
|
if a:delay > 0
|
||||||
let s:queued_buffer_number = bufnr('%')
|
let s:queued_buffer_number = a:buffer
|
||||||
let s:lint_timer = timer_start(a:delay, function('ale#Lint'))
|
let s:lint_timer = timer_start(a:delay, function('ale#Lint'))
|
||||||
else
|
else
|
||||||
call ale#Lint()
|
call ale#Lint(-1, a:buffer)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#Lint(...) abort
|
function! ale#Lint(...) abort
|
||||||
if ale#ShouldDoNothing()
|
if a:0 > 1
|
||||||
|
" Use the buffer number given as the optional second argument.
|
||||||
|
let l:buffer = a:2
|
||||||
|
elseif a:0 > 0 && a:1 == s:lint_timer
|
||||||
|
" Use the buffer number for the buffer linting was queued for.
|
||||||
|
let l:buffer = s:queued_buffer_number
|
||||||
|
else
|
||||||
|
" Use the current buffer number.
|
||||||
|
let l:buffer = bufnr('')
|
||||||
|
endif
|
||||||
|
|
||||||
|
return ale#CallWithCooldown(
|
||||||
|
\ 'dont_lint_until',
|
||||||
|
\ function('s:ALELintImpl'),
|
||||||
|
\ [l:buffer],
|
||||||
|
\)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:ALELintImpl(buffer) abort
|
||||||
|
if ale#ShouldDoNothing(a:buffer)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Get the buffer number linting was queued for.
|
|
||||||
" or else take the current one.
|
|
||||||
let l:buffer = len(a:0) > 1 && a:1 == s:lint_timer
|
|
||||||
\ ? s:queued_buffer_number
|
|
||||||
\ : bufnr('%')
|
|
||||||
|
|
||||||
" Use the filetype from the buffer
|
" Use the filetype from the buffer
|
||||||
let l:linters = ale#linter#Get(getbufvar(l:buffer, '&filetype'))
|
let l:linters = ale#linter#Get(getbufvar(a:buffer, '&filetype'))
|
||||||
let l:should_lint_file = 0
|
let l:should_lint_file = 0
|
||||||
|
|
||||||
" Check if we previously requested checking the file.
|
" Check if we previously requested checking the file.
|
||||||
if has_key(s:should_lint_file_for_buffer, l:buffer)
|
if has_key(s:should_lint_file_for_buffer, a:buffer)
|
||||||
unlet s:should_lint_file_for_buffer[l:buffer]
|
unlet s:should_lint_file_for_buffer[a:buffer]
|
||||||
" Lint files if they exist.
|
" Lint files if they exist.
|
||||||
let l:should_lint_file = filereadable(expand('#' . l:buffer . ':p'))
|
let l:should_lint_file = filereadable(expand('#' . a:buffer . ':p'))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Initialise the buffer information if needed.
|
call ale#engine#RunLinters(a:buffer, l:linters, l:should_lint_file)
|
||||||
call ale#engine#InitBufferInfo(l:buffer)
|
|
||||||
|
|
||||||
" Clear the new loclist again, so we will work with all new items.
|
|
||||||
let g:ale_buffer_info[l:buffer].new_loclist = []
|
|
||||||
|
|
||||||
if l:should_lint_file
|
|
||||||
" Clear loclist items for files if we are checking files again.
|
|
||||||
let g:ale_buffer_info[l:buffer].lint_file_loclist = []
|
|
||||||
else
|
|
||||||
" Otherwise, don't run any `lint_file` linters
|
|
||||||
" We will continue running any linters which are currently checking
|
|
||||||
" the file, and the items will be mixed together with any new items.
|
|
||||||
call filter(l:linters, '!v:val.lint_file')
|
|
||||||
endif
|
|
||||||
|
|
||||||
call ale#engine#StopCurrentJobs(l:buffer, l:should_lint_file)
|
|
||||||
|
|
||||||
for l:linter in l:linters
|
|
||||||
call ale#engine#Invoke(l:buffer, l:linter)
|
|
||||||
endfor
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Reset flags indicating that files should be checked for all buffers.
|
" Reset flags indicating that files should be checked for all buffers.
|
||||||
@@ -117,6 +196,10 @@ function! ale#ResetLintFileMarkers() abort
|
|||||||
let s:should_lint_file_for_buffer = {}
|
let s:should_lint_file_for_buffer = {}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! ale#ResetErrorDelays() abort
|
||||||
|
let s:timestamp_map = {}
|
||||||
|
endfunction
|
||||||
|
|
||||||
let g:ale_has_override = get(g:, 'ale_has_override', {})
|
let g:ale_has_override = get(g:, 'ale_has_override', {})
|
||||||
|
|
||||||
" Call has(), but check a global Dictionary so we can force flags on or off
|
" Call has(), but check a global Dictionary so we can force flags on or off
|
||||||
@@ -159,7 +242,7 @@ endfunction
|
|||||||
" Escape a string suitably for each platform.
|
" Escape a string suitably for each platform.
|
||||||
" shellescape does not work on Windows.
|
" shellescape does not work on Windows.
|
||||||
function! ale#Escape(str) abort
|
function! ale#Escape(str) abort
|
||||||
if fnamemodify(&shell, ':t') ==? 'cmd.exe'
|
if fnamemodify(&shell, ':t') is? 'cmd.exe'
|
||||||
" If the string contains spaces, it will be surrounded by quotes.
|
" If the string contains spaces, it will be surrounded by quotes.
|
||||||
" Otherwise, special characters will be escaped with carets (^).
|
" Otherwise, special characters will be escaped with carets (^).
|
||||||
return substitute(
|
return substitute(
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
function! ale#balloon#MessageForPos(bufnr, lnum, col) abort
|
function! ale#balloon#MessageForPos(bufnr, lnum, col) abort
|
||||||
let l:loclist = get(g:ale_buffer_info, a:bufnr, {'loclist': []}).loclist
|
let l:loclist = get(g:ale_buffer_info, a:bufnr, {'loclist': []}).loclist
|
||||||
let l:index = ale#util#BinarySearch(l:loclist, a:lnum, a:col)
|
let l:index = ale#util#BinarySearch(l:loclist, a:bufnr, a:lnum, a:col)
|
||||||
|
|
||||||
return l:index >= 0 ? l:loclist[l:index].text : ''
|
return l:index >= 0 ? l:loclist[l:index].text : ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user