mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-08 05:24:46 +08:00
Compare commits
267 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1428c7b29e | ||
|
|
7265ceb6d0 | ||
|
|
7ff87a942b | ||
|
|
0b5d72fecd | ||
|
|
e61e1147b0 | ||
|
|
ff6bfc3d37 | ||
|
|
3635285c02 | ||
|
|
3b4193175e | ||
|
|
69d96aa9d9 | ||
|
|
c2b01f0e28 | ||
|
|
ca97f32258 | ||
|
|
70005134e5 | ||
|
|
65bea1a5cb | ||
|
|
716f9a9bbb | ||
|
|
f67cb56e5e | ||
|
|
3f34265151 | ||
|
|
d4e1c57026 | ||
|
|
76cd6b0f92 | ||
|
|
47d941b491 | ||
|
|
36e5337e30 | ||
|
|
60d683da3b | ||
|
|
d2934ba017 | ||
|
|
36b50058bb | ||
|
|
3281321d5c | ||
|
|
e0181f8832 | ||
|
|
64b9a2708d | ||
|
|
1f9ac1c6dc | ||
|
|
93a13d7353 | ||
|
|
00eee550ea | ||
|
|
198361bc0d | ||
|
|
dc054f30c8 | ||
|
|
16cd59805b | ||
|
|
82f734a7c2 | ||
|
|
6087765cad | ||
|
|
58404b5b83 | ||
|
|
852a6a1753 | ||
|
|
9edefa724b | ||
|
|
fa19bca80e | ||
|
|
302ce71931 | ||
|
|
bbe5153fcb | ||
|
|
46d7ee564f | ||
|
|
8f7ccdc5e9 | ||
|
|
634c81fd46 | ||
|
|
8012809c3f | ||
|
|
d6d2a0c770 | ||
|
|
07ee4d39c5 | ||
|
|
4afbf2f25d | ||
|
|
72d2c55479 | ||
|
|
57eba1afac | ||
|
|
8c4c8dfd97 | ||
|
|
0cb432cb82 | ||
|
|
874c98b96d | ||
|
|
7a4f5cefba | ||
|
|
6ad8836c68 | ||
|
|
8148a67b37 | ||
|
|
25e457595a | ||
|
|
493705336c | ||
|
|
4cbe16197c | ||
|
|
9ee57d4362 | ||
|
|
715733f44d | ||
|
|
5f84325cd8 | ||
|
|
d8195e9276 | ||
|
|
5f95d032ee | ||
|
|
31715ff227 | ||
|
|
b91d82bfaa | ||
|
|
9005a62dc2 | ||
|
|
7665559d0e | ||
|
|
66a8df081e | ||
|
|
b76165abf6 | ||
|
|
abad8e474b | ||
|
|
f09cc26f87 | ||
|
|
e2a67812de | ||
|
|
e6ee613e00 | ||
|
|
6637de46c2 | ||
|
|
5985f8bd63 | ||
|
|
977921461d | ||
|
|
0b5fcbad1f | ||
|
|
db6b1b5ecc | ||
|
|
a273b9cf4a | ||
|
|
f11f6a2195 | ||
|
|
bde9b1cfcd | ||
|
|
5eefe544ed | ||
|
|
dfbb387cc7 | ||
|
|
2d9380d75c | ||
|
|
e259dd525f | ||
|
|
9a0b604a99 | ||
|
|
47eb3dd0c0 | ||
|
|
af8c8516d1 | ||
|
|
0d4dfb61dc | ||
|
|
463deedc29 | ||
|
|
40890cfcf3 | ||
|
|
ea91209a66 | ||
|
|
cf5120ba75 | ||
|
|
79e9ae4550 | ||
|
|
9017d3ef9c | ||
|
|
67d0ccc398 | ||
|
|
9c797961fa | ||
|
|
c06467438d | ||
|
|
5e69aaf4c2 | ||
|
|
9125ec8739 | ||
|
|
99e64ed084 | ||
|
|
8698c44e2a | ||
|
|
b27df1b169 | ||
|
|
dfe9b7cc26 | ||
|
|
e5a4c82917 | ||
|
|
f4070f6c43 | ||
|
|
fedd3de59f | ||
|
|
4b53d88cb8 | ||
|
|
29d0987859 | ||
|
|
d74db90550 | ||
|
|
b24fd13423 | ||
|
|
81cb40ce4b | ||
|
|
f5c289dce6 | ||
|
|
7c5825ecbc | ||
|
|
01219f0308 | ||
|
|
af1643a948 | ||
|
|
5a1505ad62 | ||
|
|
31d6f72abf | ||
|
|
e19b8c05cd | ||
|
|
c8c142b881 | ||
|
|
a1fab59811 | ||
|
|
d488198c9c | ||
|
|
a62f26434a | ||
|
|
35f51221f1 | ||
|
|
3fe2223a48 | ||
|
|
e8de12c9f0 | ||
|
|
95b8689835 | ||
|
|
f932211309 | ||
|
|
6d88801789 | ||
|
|
59b34dd017 | ||
|
|
f2b231dd76 | ||
|
|
8fda1cebff | ||
|
|
8097d51e33 | ||
|
|
06082ef377 | ||
|
|
d3a3f4011b | ||
|
|
cebbb67ea6 | ||
|
|
32b784219b | ||
|
|
7795898841 | ||
|
|
06a97a8541 | ||
|
|
0fa2d18230 | ||
|
|
d0e87c0df4 | ||
|
|
89fa43551f | ||
|
|
98b0dcd7d6 | ||
|
|
b96574e5b5 | ||
|
|
a486aa1d24 | ||
|
|
7c2f5e83ab | ||
|
|
618f2d71fc | ||
|
|
889e6338fe | ||
|
|
62602569b3 | ||
|
|
41ff80dc9e | ||
|
|
6746eaeaa0 | ||
|
|
d7dbc8f2cf | ||
|
|
e329413a31 | ||
|
|
e6241ee0d2 | ||
|
|
07c11e4e7f | ||
|
|
ab8e043353 | ||
|
|
e6946de98a | ||
|
|
6ab264ff0f | ||
|
|
d93512fe60 | ||
|
|
7b38e97943 | ||
|
|
f5e44415e8 | ||
|
|
e3784c4c4e | ||
|
|
b531a4e0b3 | ||
|
|
dd6bd6f0fe | ||
|
|
529f57a66f | ||
|
|
b8949aaac3 | ||
|
|
dc42c0f948 | ||
|
|
41ed10be4e | ||
|
|
34431d885b | ||
|
|
61cfb3fefb | ||
|
|
321ee6d26b | ||
|
|
58b7c281c5 | ||
|
|
a6c59faa0f | ||
|
|
3e8c8d3ccb | ||
|
|
b66d202c1d | ||
|
|
05ba522c9a | ||
|
|
34f2943fdd | ||
|
|
84a455185c | ||
|
|
fbe7cea91c | ||
|
|
cda46636f4 | ||
|
|
2e323b529d | ||
|
|
bd1f7e1420 | ||
|
|
6e18c03d80 | ||
|
|
9f814a8ce9 | ||
|
|
67ee2b9586 | ||
|
|
7d7ddf22d3 | ||
|
|
2b12c8ccbf | ||
|
|
5fcb24bb3e | ||
|
|
cf47bda024 | ||
|
|
da262f40dd | ||
|
|
6aeb462171 | ||
|
|
442fb2d22f | ||
|
|
08a5bfcaa9 | ||
|
|
73812c3e41 | ||
|
|
91636cff06 | ||
|
|
d787369f37 | ||
|
|
c4bdf165ca | ||
|
|
ddb559b3be | ||
|
|
ee62cc6898 | ||
|
|
219fb5873c | ||
|
|
b62e306222 | ||
|
|
5388ff1d54 | ||
|
|
266fa1c0a4 | ||
|
|
b70eeaadb4 | ||
|
|
74a43755c6 | ||
|
|
58e8d32d79 | ||
|
|
8aa1578605 | ||
|
|
501af8dd8b | ||
|
|
b1810b2752 | ||
|
|
f89b49a014 | ||
|
|
28c93ab185 | ||
|
|
ab0bf61512 | ||
|
|
9ee8067df6 | ||
|
|
20cc6d3e05 | ||
|
|
dd1e1025b8 | ||
|
|
3ae01ba249 | ||
|
|
9c7673e6c9 | ||
|
|
8f5ecf0120 | ||
|
|
d1c56769b7 | ||
|
|
b1230873b6 | ||
|
|
4fe7402e89 | ||
|
|
e47c1965a6 | ||
|
|
c675212ddd | ||
|
|
d25711a516 | ||
|
|
aae6d30b1e | ||
|
|
bafa1c619d | ||
|
|
240bb8abae | ||
|
|
36a50111b9 | ||
|
|
abb38955d3 | ||
|
|
fa5aecc250 | ||
|
|
6e6ad2e430 | ||
|
|
79dde5f0e5 | ||
|
|
6c47d7fc35 | ||
|
|
a5240009ba | ||
|
|
46ab7c5904 | ||
|
|
8700586890 | ||
|
|
221aceb6db | ||
|
|
49db8210f6 | ||
|
|
89f7292138 | ||
|
|
6feeca793a | ||
|
|
53b0e6c37d | ||
|
|
a3521de64e | ||
|
|
e52388b8b1 | ||
|
|
0843efc7a5 | ||
|
|
65ba4b85ec | ||
|
|
bf0d0597cb | ||
|
|
9ad8fd6a1b | ||
|
|
d2c3141f26 | ||
|
|
418f8a6fed | ||
|
|
9c48c584a9 | ||
|
|
38a55fa9fe | ||
|
|
4e1c46947d | ||
|
|
e0f8304860 | ||
|
|
f5a908bf99 | ||
|
|
f2e52b9432 | ||
|
|
40bf6e6b5c | ||
|
|
c5a4bbf8b0 | ||
|
|
1c71da5624 | ||
|
|
701c1e4f17 | ||
|
|
15f23532b7 | ||
|
|
3acfa0813e | ||
|
|
e0871be22b | ||
|
|
6e28eec243 | ||
|
|
86205967ea | ||
|
|
eb6a7b7516 | ||
|
|
0135fb3ad3 | ||
|
|
3e4b8ea466 |
@@ -5,6 +5,11 @@ clone_depth: 10
|
||||
# Use the directory C:\testplugin so test directories will mostly work.
|
||||
clone_folder: C:\testplugin
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- /v\d+\.\d+\.(x|\d+)/
|
||||
|
||||
# Cache the vim and vader directories between builds.
|
||||
cache:
|
||||
- C:\vim -> .appveyor.yml
|
||||
|
||||
1
.github/ISSUE_TEMPLATE/report-a-bug.md
vendored
1
.github/ISSUE_TEMPLATE/report-a-bug.md
vendored
@@ -1,5 +1,6 @@
|
||||
---
|
||||
name: Report a bug
|
||||
labels: bug
|
||||
about: Report a bug with ALE.
|
||||
|
||||
---
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
name: Suggest a new linter or fixer
|
||||
labels: new tool
|
||||
about: Suggest a new tool ALE can officially integrate with.
|
||||
|
||||
---
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
name: Suggest an improvement
|
||||
labels: enhancement
|
||||
about: Suggest some way to improve ALE, or add a new feature.
|
||||
|
||||
---
|
||||
|
||||
@@ -3,6 +3,10 @@ sudo: required
|
||||
services:
|
||||
- docker
|
||||
language: generic
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- /^v\d+\.\d+\.(x|\d+)$/
|
||||
env:
|
||||
- OPTIONS=--vim-80-only
|
||||
- OPTIONS=--vim-81-only
|
||||
|
||||
35
README.md
35
README.md
@@ -1,4 +1,4 @@
|
||||
# Asynchronous Lint Engine [](https://travis-ci.com/w0rp/ale) [](https://ci.appveyor.com/project/w0rp/ale) [](https://gitter.im/vim-ale/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
# Asynchronous Lint Engine [](https://travis-ci.com/dense-analysis/ale) [](https://ci.appveyor.com/project/dense-analysis/ale) [](https://gitter.im/vim-ale/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
|
||||

|
||||
@@ -35,6 +35,10 @@ If you don't care about Language Server Protocol, ALE won't load any of the code
|
||||
for working with it unless needed. One of ALE's general missions is that you
|
||||
won't pay for the features that you don't use.
|
||||
|
||||
**Help Wanted:** If you would like to help maintain this plugin by managing the
|
||||
many issues and pull requests that are submitted, please send the author an
|
||||
email at [dev@w0rp.com](mailto:dev@w0rp.com?subject=Helping%20with%20ALE).
|
||||
|
||||
If you enjoy this plugin, feel free to contribute or check out the author's
|
||||
other content at [w0rp.com](https://w0rp.com).
|
||||
|
||||
@@ -189,6 +193,14 @@ completion manually with `<C-x><C-o>`.
|
||||
set omnifunc=ale#completion#OmniFunc
|
||||
```
|
||||
|
||||
When working with TypeScript files, ALE supports automatic imports from
|
||||
external modules. This behavior is disabled by default and can be enabled by
|
||||
setting:
|
||||
|
||||
```vim
|
||||
let g:ale_completion_tsserver_autoimport = 1
|
||||
```
|
||||
|
||||
See `:help ale-completion` for more information.
|
||||
|
||||
<a name="usage-go-to-definition"></a>
|
||||
@@ -258,14 +270,14 @@ any other tools. Simply clone the plugin into your `pack` directory.
|
||||
|
||||
```bash
|
||||
mkdir -p ~/.vim/pack/git-plugins/start
|
||||
git clone --depth 1 https://github.com/w0rp/ale.git ~/.vim/pack/git-plugins/start/ale
|
||||
git clone --depth 1 https://github.com/dense-analysis/ale.git ~/.vim/pack/git-plugins/start/ale
|
||||
```
|
||||
|
||||
#### NeoVim on Unix
|
||||
|
||||
```bash
|
||||
mkdir -p ~/.local/share/nvim/site/pack/git-plugins/start
|
||||
git clone --depth 1 https://github.com/w0rp/ale.git ~/.local/share/nvim/site/pack/git-plugins/start/ale
|
||||
git clone --depth 1 https://github.com/dense-analysis/ale.git ~/.local/share/nvim/site/pack/git-plugins/start/ale
|
||||
```
|
||||
|
||||
#### Vim 8 on Windows
|
||||
@@ -273,7 +285,7 @@ git clone --depth 1 https://github.com/w0rp/ale.git ~/.local/share/nvim/site/pac
|
||||
```bash
|
||||
# Run these commands in the "Git for Windows" Bash terminal
|
||||
mkdir -p ~/vimfiles/pack/git-plugins/start
|
||||
git clone --depth 1 https://github.com/w0rp/ale.git ~/vimfiles/pack/git-plugins/start/ale
|
||||
git clone --depth 1 https://github.com/dense-analysis/ale.git ~/vimfiles/pack/git-plugins/start/ale
|
||||
```
|
||||
|
||||
#### Generating Vim help files
|
||||
@@ -304,7 +316,7 @@ You can run the following commands in your terminal to do so:
|
||||
|
||||
```bash
|
||||
cd ~/.vim/bundle
|
||||
git clone https://github.com/w0rp/ale.git
|
||||
git clone https://github.com/dense-analysis/ale.git
|
||||
```
|
||||
|
||||
<a name="installation-with-vundle"></a>
|
||||
@@ -315,7 +327,7 @@ You can install this plugin using [Vundle](https://github.com/VundleVim/Vundle.v
|
||||
by using the path on GitHub for this repository.
|
||||
|
||||
```vim
|
||||
Plugin 'w0rp/ale'
|
||||
Plugin 'dense-analysis/ale'
|
||||
```
|
||||
|
||||
See the Vundle documentation for more information.
|
||||
@@ -329,7 +341,7 @@ by adding the GitHub path for this repository to your `~/.vimrc`
|
||||
and running `:PlugInstall`.
|
||||
|
||||
```vim
|
||||
Plug 'w0rp/ale'
|
||||
Plug 'dense-analysis/ale'
|
||||
```
|
||||
|
||||
<a name="contributing"></a>
|
||||
@@ -337,14 +349,14 @@ Plug 'w0rp/ale'
|
||||
## 4. Contributing
|
||||
|
||||
If you would like to see support for more languages and tools, please
|
||||
[create an issue](https://github.com/w0rp/ale/issues)
|
||||
or [create a pull request](https://github.com/w0rp/ale/pulls).
|
||||
[create an issue](https://github.com/dense-analysis/ale/issues)
|
||||
or [create a pull request](https://github.com/dense-analysis/ale/pulls).
|
||||
If your tool can read from stdin or you have code to suggest which is good,
|
||||
support can be happily added for it.
|
||||
|
||||
If you are interested in the general direction of the project, check out the
|
||||
[wiki home page](https://github.com/w0rp/ale/wiki). The wiki includes a
|
||||
Roadmap for the future, and more.
|
||||
[wiki home page](https://github.com/dense-analysis/ale/wiki). The wiki includes
|
||||
a Roadmap for the future, and more.
|
||||
|
||||
If you'd liked to discuss the project more directly, check out the `#vim-ale` channel
|
||||
on Freenode. Web chat is available [here](https://webchat.freenode.net/?channels=vim-ale).
|
||||
@@ -596,6 +608,7 @@ options off.
|
||||
```vim
|
||||
" Write this in your vimrc file
|
||||
let g:ale_lint_on_text_changed = 'never'
|
||||
let g:ale_lint_on_insert_leave = 0
|
||||
" You can disable this option too
|
||||
" if you don't want linters to run on opening a file
|
||||
let g:ale_lint_on_enter = 0
|
||||
|
||||
4
ale_linters/bats/shellcheck.vim
Normal file
4
ale_linters/bats/shellcheck.vim
Normal file
@@ -0,0 +1,4 @@
|
||||
" Author: Ian2020 <https://github.com/Ian2020>
|
||||
" Description: shellcheck linter for bats scripts.
|
||||
|
||||
call ale#handlers#shellcheck#DefineLinter('bats')
|
||||
@@ -3,9 +3,14 @@
|
||||
|
||||
call ale#Set('c_clangd_executable', 'clangd')
|
||||
call ale#Set('c_clangd_options', '')
|
||||
call ale#Set('c_build_dir', '')
|
||||
|
||||
function! ale_linters#c#clangd#GetCommand(buffer) abort
|
||||
return '%e' . ale#Pad(ale#Var(a:buffer, 'c_clangd_options'))
|
||||
let l:build_dir = ale#c#GetBuildDirectory(a:buffer)
|
||||
|
||||
return '%e'
|
||||
\ . ale#Pad(ale#Var(a:buffer, 'c_clangd_options'))
|
||||
\ . (!empty(l:build_dir) ? ' -compile-commands-dir=' . ale#Escape(l:build_dir) : '')
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('c', {
|
||||
|
||||
@@ -19,14 +19,17 @@ call ale#Set('c_clangtidy_options', '')
|
||||
call ale#Set('c_clangtidy_extra_options', '')
|
||||
call ale#Set('c_build_dir', '')
|
||||
|
||||
function! ale_linters#c#clangtidy#GetCommand(buffer) abort
|
||||
function! ale_linters#c#clangtidy#GetCommand(buffer, output) abort
|
||||
let l:checks = join(ale#Var(a:buffer, 'c_clangtidy_checks'), ',')
|
||||
let l:build_dir = ale#c#GetBuildDirectory(a:buffer)
|
||||
let l:options = ''
|
||||
|
||||
" 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')
|
||||
\ : ''
|
||||
if empty(l:build_dir)
|
||||
let l:options = ale#Var(a:buffer, 'c_clangtidy_options')
|
||||
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
|
||||
let l:options .= !empty(l:options) ? ale#Pad(l:cflags) : l:cflags
|
||||
endif
|
||||
|
||||
" Get the options to pass directly to clang-tidy
|
||||
let l:extra_options = ale#Var(a:buffer, 'c_clangtidy_extra_options')
|
||||
@@ -43,7 +46,7 @@ call ale#linter#Define('c', {
|
||||
\ 'name': 'clangtidy',
|
||||
\ 'output_stream': 'stdout',
|
||||
\ 'executable': {b -> ale#Var(b, 'c_clangtidy_executable')},
|
||||
\ 'command': function('ale_linters#c#clangtidy#GetCommand'),
|
||||
\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#c#clangtidy#GetCommand'))},
|
||||
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
||||
\ 'lint_file': 1,
|
||||
\})
|
||||
|
||||
@@ -29,6 +29,6 @@ call ale#linter#Define('clojure', {
|
||||
\ 'name': 'clj-kondo',
|
||||
\ 'output_stream': 'stdout',
|
||||
\ 'executable': 'clj-kondo',
|
||||
\ 'command': 'clj-kondo --lint %t',
|
||||
\ 'command': 'clj-kondo --cache --lint %t',
|
||||
\ 'callback': 'ale_linters#clojure#clj_kondo#HandleCljKondoFormat',
|
||||
\})
|
||||
|
||||
@@ -20,7 +20,7 @@ function! ale_linters#cpp#clangcheck#GetCommand(buffer) abort
|
||||
" being generated. These are only added if no build directory can be
|
||||
" detected.
|
||||
return '%e -analyze %s'
|
||||
\ . (empty(l:build_dir) ? ' -extra-arg -Xclang -extra-arg -analyzer-output=text' : '')
|
||||
\ . (empty(l:build_dir) ? ' --extra-arg=-Xclang --extra-arg=-analyzer-output=text --extra-arg=-fno-color-diagnostics': '')
|
||||
\ . ale#Pad(l:user_options)
|
||||
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
|
||||
endfunction
|
||||
|
||||
@@ -3,9 +3,14 @@
|
||||
|
||||
call ale#Set('cpp_clangd_executable', 'clangd')
|
||||
call ale#Set('cpp_clangd_options', '')
|
||||
call ale#Set('c_build_dir', '')
|
||||
|
||||
function! ale_linters#cpp#clangd#GetCommand(buffer) abort
|
||||
return '%e' . ale#Pad(ale#Var(a:buffer, 'cpp_clangd_options'))
|
||||
let l:build_dir = ale#c#GetBuildDirectory(a:buffer)
|
||||
|
||||
return '%e'
|
||||
\ . ale#Pad(ale#Var(a:buffer, 'cpp_clangd_options'))
|
||||
\ . (!empty(l:build_dir) ? ' -compile-commands-dir=' . ale#Escape(l:build_dir) : '')
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('cpp', {
|
||||
|
||||
@@ -13,14 +13,17 @@ call ale#Set('cpp_clangtidy_options', '')
|
||||
call ale#Set('cpp_clangtidy_extra_options', '')
|
||||
call ale#Set('c_build_dir', '')
|
||||
|
||||
function! ale_linters#cpp#clangtidy#GetCommand(buffer) abort
|
||||
function! ale_linters#cpp#clangtidy#GetCommand(buffer, output) abort
|
||||
let l:checks = join(ale#Var(a:buffer, 'cpp_clangtidy_checks'), ',')
|
||||
let l:build_dir = ale#c#GetBuildDirectory(a:buffer)
|
||||
let l:options = ''
|
||||
|
||||
" 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')
|
||||
\ : ''
|
||||
if empty(l:build_dir)
|
||||
let l:options = ale#Var(a:buffer, 'cpp_clangtidy_options')
|
||||
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
|
||||
let l:options .= !empty(l:options) ? ale#Pad(l:cflags) : l:cflags
|
||||
endif
|
||||
|
||||
" Get the options to pass directly to clang-tidy
|
||||
let l:extra_options = ale#Var(a:buffer, 'cpp_clangtidy_extra_options')
|
||||
@@ -37,7 +40,7 @@ call ale#linter#Define('cpp', {
|
||||
\ 'name': 'clangtidy',
|
||||
\ 'output_stream': 'stdout',
|
||||
\ 'executable': {b -> ale#Var(b, 'cpp_clangtidy_executable')},
|
||||
\ 'command': function('ale_linters#cpp#clangtidy#GetCommand'),
|
||||
\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#cpp#clangtidy#GetCommand'))},
|
||||
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
||||
\ 'lint_file': 1,
|
||||
\})
|
||||
|
||||
@@ -5,6 +5,10 @@ function! ale_linters#crystal#crystal#Handle(buffer, lines) abort
|
||||
let l:output = []
|
||||
|
||||
for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
|
||||
if !has_key(l:error, 'file')
|
||||
continue
|
||||
endif
|
||||
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:error.line + 0,
|
||||
\ 'col': l:error.column + 0,
|
||||
|
||||
95
ale_linters/cs/csc.vim
Normal file
95
ale_linters/cs/csc.vim
Normal file
@@ -0,0 +1,95 @@
|
||||
call ale#Set('cs_csc_options', '')
|
||||
call ale#Set('cs_csc_source', '')
|
||||
call ale#Set('cs_csc_assembly_path', [])
|
||||
call ale#Set('cs_csc_assemblies', [])
|
||||
|
||||
function! s:GetWorkingDirectory(buffer) abort
|
||||
let l:working_directory = ale#Var(a:buffer, 'cs_csc_source')
|
||||
|
||||
if !empty(l:working_directory)
|
||||
return l:working_directory
|
||||
endif
|
||||
|
||||
return expand('#' . a:buffer . ':p:h')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#cs#csc#GetCommand(buffer) abort
|
||||
" Pass assembly paths via the -lib: parameter.
|
||||
let l:path_list = ale#Var(a:buffer, 'cs_csc_assembly_path')
|
||||
|
||||
let l:lib_option = !empty(l:path_list)
|
||||
\ ? '/lib:' . join(map(copy(l:path_list), 'ale#Escape(v:val)'), ',')
|
||||
\ : ''
|
||||
|
||||
" Pass paths to DLL files via the -r: parameter.
|
||||
let l:assembly_list = ale#Var(a:buffer, 'cs_csc_assemblies')
|
||||
|
||||
let l:r_option = !empty(l:assembly_list)
|
||||
\ ? '/r:' . join(map(copy(l:assembly_list), 'ale#Escape(v:val)'), ',')
|
||||
\ : ''
|
||||
|
||||
" register temporary module target file with ale
|
||||
" register temporary module target file with ALE.
|
||||
let l:out = ale#command#CreateFile(a:buffer)
|
||||
|
||||
" The code is compiled as a module and the output is redirected to a
|
||||
" temporary file.
|
||||
return ale#path#CdString(s:GetWorkingDirectory(a:buffer))
|
||||
\ . 'csc /unsafe'
|
||||
\ . ale#Pad(ale#Var(a:buffer, 'cs_csc_options'))
|
||||
\ . ale#Pad(l:lib_option)
|
||||
\ . ale#Pad(l:r_option)
|
||||
\ . ' /out:' . l:out
|
||||
\ . ' /t:module'
|
||||
\ . ' /recurse:' . ale#Escape('*.cs')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#cs#csc#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:patterns = [
|
||||
\ '^\v(.+\.cs)\((\d+),(\d+)\)\:\s+([^ ]+)\s+([cC][sS][^ ]+):\s(.+)$',
|
||||
\ '^\v([^ ]+)\s+([Cc][sS][^ ]+):\s+(.+)$',
|
||||
\]
|
||||
let l:output = []
|
||||
|
||||
let l:dir = s:GetWorkingDirectory(a:buffer)
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:patterns)
|
||||
if len(l:match) > 6 && strlen(l:match[5]) > 2 && l:match[5][:1] is? 'CS'
|
||||
call add(l:output, {
|
||||
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'col': l:match[3] + 0,
|
||||
\ 'type': l:match[4] is# 'error' ? 'E' : 'W',
|
||||
\ 'code': l:match[5],
|
||||
\ 'text': l:match[6] ,
|
||||
\})
|
||||
elseif strlen(l:match[2]) > 2 && l:match[2][:1] is? 'CS'
|
||||
call add(l:output, {
|
||||
\ 'filename':'<csc>',
|
||||
\ 'lnum': -1,
|
||||
\ 'col': -1,
|
||||
\ 'type': l:match[1] is# 'error' ? 'E' : 'W',
|
||||
\ 'code': l:match[2],
|
||||
\ 'text': l:match[3],
|
||||
\})
|
||||
endif
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('cs',{
|
||||
\ 'name': 'csc',
|
||||
\ 'output_stream': 'stdout',
|
||||
\ 'executable': 'csc',
|
||||
\ 'command': function('ale_linters#cs#csc#GetCommand'),
|
||||
\ 'callback': 'ale_linters#cs#csc#Handle',
|
||||
\ 'lint_file': 1
|
||||
\})
|
||||
@@ -52,20 +52,34 @@ function! ale_linters#cs#mcsc#Handle(buffer, lines) abort
|
||||
" 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 = '^\v(.+\.cs)\((\d+),(\d+)\)\: ([^ ]+) ([^ ]+): (.+)$'
|
||||
let l:patterns = [
|
||||
\ '^\v(.+\.cs)\((\d+),(\d+)\)\:\s+([^ ]+)\s+([cC][sS][^ ]+):\s(.+)$',
|
||||
\ '^\v([^ ]+)\s+([Cc][sS][^ ]+):\s+(.+)$',
|
||||
\]
|
||||
let l:output = []
|
||||
|
||||
let l:dir = s:GetWorkingDirectory(a:buffer)
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
for l:match in ale#util#GetMatches(a:lines, l:patterns)
|
||||
if len(l:match) > 6 && strlen(l:match[5]) > 2 && l:match[5][:1] is? 'CS'
|
||||
call add(l:output, {
|
||||
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'col': l:match[3] + 0,
|
||||
\ 'type': l:match[4] is# 'error' ? 'E' : 'W',
|
||||
\ 'code': l:match[5],
|
||||
\ 'text': l:match[6],
|
||||
\ 'text': l:match[6] ,
|
||||
\})
|
||||
elseif strlen(l:match[2]) > 2 && l:match[2][:1] is? 'CS'
|
||||
call add(l:output, {
|
||||
\ 'filename':'<mcs>',
|
||||
\ 'lnum': -1,
|
||||
\ 'col': -1,
|
||||
\ 'type': l:match[1] is# 'error' ? 'E' : 'W',
|
||||
\ 'code': l:match[2],
|
||||
\ 'text': l:match[3],
|
||||
\})
|
||||
endif
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
|
||||
40
ale_linters/elm/elm_ls.vim
Normal file
40
ale_linters/elm/elm_ls.vim
Normal file
@@ -0,0 +1,40 @@
|
||||
" Author: antew - https://github.com/antew
|
||||
" Description: elm-language-server integration for elm (diagnostics, formatting, and more)
|
||||
|
||||
call ale#Set('elm_ls_executable', 'elm-language-server')
|
||||
call ale#Set('elm_ls_use_global', get(g:, 'ale_use_global_executables', 1))
|
||||
|
||||
" elm-language-server will search for local and global binaries, if empty
|
||||
call ale#Set('elm_ls_elm_path', '')
|
||||
call ale#Set('elm_ls_elm_format_path', '')
|
||||
call ale#Set('elm_ls_elm_test_path', '')
|
||||
call ale#Set('elm_ls_elm_analyse_trigger', 'change')
|
||||
|
||||
function! elm_ls#GetRootDir(buffer) abort
|
||||
let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm.json')
|
||||
|
||||
return !empty(l:elm_json) ? fnamemodify(l:elm_json, ':p:h') : ''
|
||||
endfunction
|
||||
|
||||
function! elm_ls#GetOptions(buffer) abort
|
||||
return {
|
||||
\ 'elmPath': ale#Var(a:buffer, 'elm_ls_elm_path'),
|
||||
\ 'elmFormatPath': ale#Var(a:buffer, 'elm_ls_elm_format_path'),
|
||||
\ 'elmTestPath': ale#Var(a:buffer, 'elm_ls_elm_test_path'),
|
||||
\ 'elmAnalyseTrigger': ale#Var(a:buffer, 'elm_ls_elm_analyse_trigger'),
|
||||
\}
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('elm', {
|
||||
\ 'name': 'elm_ls',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': {b -> ale#node#FindExecutable(b, 'elm_ls', [
|
||||
\ 'node_modules/.bin/elm-language-server',
|
||||
\ 'node_modules/.bin/elm-lsp',
|
||||
\ 'elm-lsp'
|
||||
\ ])},
|
||||
\ 'command': '%e --stdio',
|
||||
\ 'project_root': function('elm_ls#GetRootDir'),
|
||||
\ 'language': 'elm',
|
||||
\ 'initialization_options': function('elm_ls#GetOptions')
|
||||
\})
|
||||
@@ -1,22 +0,0 @@
|
||||
" Author: antew - https://github.com/antew
|
||||
" Description: LSP integration for elm, currently supports diagnostics (linting)
|
||||
|
||||
call ale#Set('elm_lsp_executable', 'elm-lsp')
|
||||
call ale#Set('elm_lsp_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
|
||||
function! elm_lsp#GetRootDir(buffer) abort
|
||||
let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm.json')
|
||||
|
||||
return !empty(l:elm_json) ? fnamemodify(l:elm_json, ':p:h') : ''
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('elm', {
|
||||
\ 'name': 'elm_lsp',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': {b -> ale#node#FindExecutable(b, 'elm_lsp', [
|
||||
\ 'node_modules/.bin/elm-lsp',
|
||||
\ ])},
|
||||
\ 'command': '%e --stdio',
|
||||
\ 'project_root': function('elm_lsp#GetRootDir'),
|
||||
\ 'language': 'elm'
|
||||
\})
|
||||
@@ -15,10 +15,10 @@ endfunction
|
||||
function! ale_linters#erlang#dialyzer#FindPlt(buffer) abort
|
||||
let l:plt_file = ''
|
||||
let l:rebar3_profile = ale_linters#erlang#dialyzer#GetRebar3Profile(a:buffer)
|
||||
let l:plt_file_directory = ale#path#FindNearestDirectory(a:buffer, '_build' . l:rebar3_profile)
|
||||
let l:plt_file_directory = ale#path#FindNearestDirectory(a:buffer, '_build/' . l:rebar3_profile)
|
||||
|
||||
if !empty(l:plt_file_directory)
|
||||
let l:plt_file = split(globpath(l:plt_file_directory, '/*_plt'), '\n')
|
||||
let l:plt_file = globpath(l:plt_file_directory, '*_plt', 0, 1)
|
||||
endif
|
||||
|
||||
if !empty(l:plt_file)
|
||||
|
||||
@@ -8,7 +8,7 @@ call ale#Set('eruby_ruumba_options', '')
|
||||
function! ale_linters#eruby#ruumba#GetCommand(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'eruby_ruumba_executable')
|
||||
|
||||
return ale#handlers#ruby#EscapeExecutable(l:executable, 'ruumba')
|
||||
return ale#ruby#EscapeExecutable(l:executable, 'ruumba')
|
||||
\ . ' --format json --force-exclusion '
|
||||
\ . ale#Var(a:buffer, 'eruby_ruumba_options')
|
||||
\ . ' --stdin ' . ale#Escape(expand('#' . a:buffer . ':p'))
|
||||
|
||||
@@ -5,11 +5,13 @@ call ale#Set('go_bingo_executable', 'bingo')
|
||||
call ale#Set('go_bingo_options', '--mode stdio')
|
||||
|
||||
function! ale_linters#go#bingo#GetCommand(buffer) abort
|
||||
return '%e' . ale#Pad(ale#Var(a:buffer, 'go_bingo_options'))
|
||||
return ale#go#EnvString(a:buffer) . '%e' . ale#Pad(ale#Var(a:buffer, 'go_bingo_options'))
|
||||
endfunction
|
||||
|
||||
function! ale_linters#go#bingo#FindProjectRoot(buffer) abort
|
||||
let l:project_root = ale#path#FindNearestFile(a:buffer, 'go.mod')
|
||||
let l:go_modules_off = ale#Var(a:buffer, 'go_go111module') is# 'off'
|
||||
let l:project_root = l:go_modules_off ?
|
||||
\ '' : ale#path#FindNearestFile(a:buffer, 'go.mod')
|
||||
let l:mods = ':h'
|
||||
|
||||
if empty(l:project_root)
|
||||
|
||||
@@ -11,6 +11,7 @@ function! ale_linters#go#gobuild#GetCommand(buffer) abort
|
||||
|
||||
" Run go test in local directory with relative path
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#go#EnvString(a:buffer)
|
||||
\ . ale#Var(a:buffer, 'go_go_executable') . ' test'
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' -c -o /dev/null ./'
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
" Author: neersighted <bjorn@neersighted.com>
|
||||
" Description: gofmt for Go files
|
||||
|
||||
function! ale_linters#go#gofmt#GetCommand(buffer) abort
|
||||
return ale#go#EnvString(a:buffer)
|
||||
\ . '%e -e %t'
|
||||
endfunction
|
||||
|
||||
|
||||
call ale#linter#Define('go', {
|
||||
\ 'name': 'gofmt',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': 'gofmt',
|
||||
\ 'command': 'gofmt -e %t',
|
||||
\ 'command': function('ale_linters#go#gofmt#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsError',
|
||||
\})
|
||||
|
||||
@@ -10,13 +10,16 @@ function! ale_linters#go#golangci_lint#GetCommand(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'go_golangci_lint_options')
|
||||
let l:lint_package = ale#Var(a:buffer, 'go_golangci_lint_package')
|
||||
|
||||
|
||||
if l:lint_package
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#go#EnvString(a:buffer)
|
||||
\ . '%e run '
|
||||
\ . l:options
|
||||
endif
|
||||
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#go#EnvString(a:buffer)
|
||||
\ . '%e run '
|
||||
\ . ale#Escape(l:filename)
|
||||
\ . ' ' . l:options
|
||||
|
||||
@@ -7,7 +7,7 @@ call ale#Set('go_golint_options', '')
|
||||
function! ale_linters#go#golint#GetCommand(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'go_golint_options')
|
||||
|
||||
return '%e'
|
||||
return ale#go#EnvString(a:buffer) . '%e'
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' %t'
|
||||
endfunction
|
||||
|
||||
@@ -14,11 +14,13 @@ function! ale_linters#go#gometalinter#GetCommand(buffer) abort
|
||||
" be calculated to absolute paths in the Handler
|
||||
if l:lint_package
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#go#EnvString(a:buffer)
|
||||
\ . '%e'
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
|
||||
endif
|
||||
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#go#EnvString(a:buffer)
|
||||
\ . '%e'
|
||||
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(l:filename))
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
|
||||
|
||||
@@ -6,11 +6,15 @@ call ale#Set('go_gopls_executable', 'gopls')
|
||||
call ale#Set('go_gopls_options', '--mode stdio')
|
||||
|
||||
function! ale_linters#go#gopls#GetCommand(buffer) abort
|
||||
return '%e' . ale#Pad(ale#Var(a:buffer, 'go_gopls_options'))
|
||||
return ale#go#EnvString(a:buffer)
|
||||
\ . '%e'
|
||||
\ . ale#Pad(ale#Var(a:buffer, 'go_gopls_options'))
|
||||
endfunction
|
||||
|
||||
function! ale_linters#go#gopls#FindProjectRoot(buffer) abort
|
||||
let l:project_root = ale#path#FindNearestFile(a:buffer, 'go.mod')
|
||||
let l:go_modules_off = ale#Var(a:buffer, 'go_go111module') is# 'off'
|
||||
let l:project_root = l:go_modules_off ?
|
||||
\ '' : ale#path#FindNearestFile(a:buffer, 'go.mod')
|
||||
let l:mods = ':h'
|
||||
|
||||
if empty(l:project_root)
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
" Description: gosimple for Go files
|
||||
|
||||
function! ale_linters#go#gosimple#GetCommand(buffer) abort
|
||||
return ale#path#BufferCdString(a:buffer) . ' gosimple .'
|
||||
return ale#path#BufferCdString(a:buffer) . ' '
|
||||
\ . ale#go#EnvString(a:buffer) . 'gosimple .'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('go', {
|
||||
|
||||
@@ -6,7 +6,8 @@ function! ale_linters#go#gotype#GetCommand(buffer) abort
|
||||
return ''
|
||||
endif
|
||||
|
||||
return ale#path#BufferCdString(a:buffer) . ' gotype -e .'
|
||||
return ale#path#BufferCdString(a:buffer) . ' '
|
||||
\ . ale#go#EnvString(a:buffer) . 'gotype -e .'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('go', {
|
||||
|
||||
@@ -11,6 +11,7 @@ function! ale_linters#go#govet#GetCommand(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'go_govet_options')
|
||||
|
||||
return ale#path#BufferCdString(a:buffer) . ' '
|
||||
\ . ale#go#EnvString(a:buffer)
|
||||
\ . ale#Var(a:buffer, 'go_go_executable') . ' vet '
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' .'
|
||||
|
||||
@@ -15,8 +15,9 @@ function! ale_linters#go#langserver#GetCommand(buffer) abort
|
||||
endif
|
||||
|
||||
let l:options = uniq(sort(l:options))
|
||||
let l:env = ale#go#EnvString(a:buffer)
|
||||
|
||||
return join(extend(l:executable, l:options), ' ')
|
||||
return l:env . join(extend(l:executable, l:options), ' ')
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('go', {
|
||||
|
||||
21
ale_linters/go/revive.vim
Normal file
21
ale_linters/go/revive.vim
Normal file
@@ -0,0 +1,21 @@
|
||||
" Author: Penghui Liao <liaoishere@gmail.com>
|
||||
" Description: Adds support for revive
|
||||
|
||||
call ale#Set('go_revive_executable', 'revive')
|
||||
call ale#Set('go_revive_options', '')
|
||||
|
||||
function! ale_linters#go#revive#GetCommand(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'go_revive_options')
|
||||
|
||||
return ale#go#EnvString(a:buffer) . '%e'
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' %t'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('go', {
|
||||
\ 'name': 'revive',
|
||||
\ 'output_stream': 'both',
|
||||
\ 'executable': {b -> ale#Var(b, 'go_revive_executable')},
|
||||
\ 'command': function('ale_linters#go#revive#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\})
|
||||
@@ -8,17 +8,18 @@ function! ale_linters#go#staticcheck#GetCommand(buffer) abort
|
||||
let l:filename = expand('#' . a:buffer . ':t')
|
||||
let l:options = ale#Var(a:buffer, 'go_staticcheck_options')
|
||||
let l:lint_package = ale#Var(a:buffer, 'go_staticcheck_lint_package')
|
||||
let l:env = ale#go#EnvString(a:buffer)
|
||||
|
||||
" BufferCdString is used so that we can be sure the paths output from
|
||||
" staticcheck can be calculated to absolute paths in the Handler
|
||||
if l:lint_package
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . 'staticcheck'
|
||||
\ . l:env . 'staticcheck'
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
|
||||
endif
|
||||
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . 'staticcheck'
|
||||
\ . l:env . 'staticcheck'
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' ' . ale#Escape(l:filename)
|
||||
endfunction
|
||||
|
||||
@@ -5,5 +5,5 @@ call ale#linter#Define('graphql', {
|
||||
\ 'name': 'eslint',
|
||||
\ 'executable': function('ale#handlers#eslint#GetExecutable'),
|
||||
\ 'command': function('ale#handlers#eslint#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#eslint#Handle',
|
||||
\ 'callback': 'ale#handlers#eslint#HandleJSON',
|
||||
\})
|
||||
|
||||
35
ale_linters/ink/ls.vim
Normal file
35
ale_linters/ink/ls.vim
Normal file
@@ -0,0 +1,35 @@
|
||||
" Author: Andreww Hayworth <ahayworth@gmail.com>
|
||||
" Description: Integrate ALE with ink-language-server
|
||||
|
||||
call ale#Set('ink_ls_executable', 'ink-language-server')
|
||||
call ale#Set('ink_ls_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('ink_ls_initialization_options', {})
|
||||
|
||||
function! ale_linters#ink#ls#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'ink_ls', [
|
||||
\ 'ink-language-server',
|
||||
\ 'node_modules/.bin/ink-language-server',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#ink#ls#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#ink#ls#GetExecutable(a:buffer)
|
||||
|
||||
return ale#Escape(l:executable) . ' --stdio'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#ink#ls#FindProjectRoot(buffer) abort
|
||||
let l:main_file = get(ale#Var(a:buffer, 'ink_ls_initialization_options'), 'mainStoryPath', 'main.ink')
|
||||
let l:config = ale#path#ResolveLocalPath(a:buffer, l:main_file, expand('#' . a:buffer . ':p'))
|
||||
|
||||
return ale#path#Dirname(l:config)
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('ink', {
|
||||
\ 'name': 'ink-language-server',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': function('ale_linters#ink#ls#GetExecutable'),
|
||||
\ 'command': function('ale_linters#ink#ls#GetCommand'),
|
||||
\ 'project_root': function('ale_linters#ink#ls#FindProjectRoot'),
|
||||
\ 'initialization_options': {b -> ale#Var(b, 'ink_ls_initialization_options')},
|
||||
\})
|
||||
@@ -2,7 +2,7 @@
|
||||
" Description: checkstyle for Java files
|
||||
|
||||
call ale#Set('java_checkstyle_executable', 'checkstyle')
|
||||
call ale#Set('java_checkstyle_config', 'google_checks.xml')
|
||||
call ale#Set('java_checkstyle_config', '/google_checks.xml')
|
||||
call ale#Set('java_checkstyle_options', '')
|
||||
|
||||
function! ale_linters#java#checkstyle#Handle(buffer, lines) abort
|
||||
@@ -39,11 +39,21 @@ function! ale_linters#java#checkstyle#Handle(buffer, lines) abort
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
function! s:GetConfig(buffer, config) abort
|
||||
if ale#path#IsAbsolute(a:config)
|
||||
return a:config
|
||||
endif
|
||||
|
||||
let s:file = ale#path#FindNearestFile(a:buffer, a:config)
|
||||
|
||||
return !empty(s:file) ? s:file : a:config
|
||||
endfunction
|
||||
|
||||
function! ale_linters#java#checkstyle#GetCommand(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'java_checkstyle_options')
|
||||
let l:config_option = ale#Var(a:buffer, 'java_checkstyle_config')
|
||||
let l:config = l:options !~# '\v(^| )-c' && !empty(l:config_option)
|
||||
\ ? ale#path#FindNearestFile(a:buffer, l:config_option)
|
||||
\ ? s:GetConfig(a:buffer, l:config_option)
|
||||
\ : ''
|
||||
|
||||
return '%e'
|
||||
|
||||
@@ -7,6 +7,7 @@ call ale#Set('java_eclipselsp_path', ale#path#Simplify($HOME . '/eclipse.jdt.ls'
|
||||
call ale#Set('java_eclipselsp_config_path', '')
|
||||
call ale#Set('java_eclipselsp_workspace_path', '')
|
||||
call ale#Set('java_eclipselsp_executable', 'java')
|
||||
call ale#Set('java_eclipselsp_javaagent', '')
|
||||
|
||||
function! ale_linters#java#eclipselsp#Executable(buffer) abort
|
||||
return ale#Var(a:buffer, 'java_eclipselsp_executable')
|
||||
@@ -100,12 +101,30 @@ function! ale_linters#java#eclipselsp#WorkspacePath(buffer) abort
|
||||
return ale#path#Dirname(ale#java#FindProjectRoot(a:buffer))
|
||||
endfunction
|
||||
|
||||
function! ale_linters#java#eclipselsp#Javaagent(buffer) abort
|
||||
let l:rets = []
|
||||
let l:raw = ale#Var(a:buffer, 'java_eclipselsp_javaagent')
|
||||
|
||||
if empty(l:raw)
|
||||
return ''
|
||||
endif
|
||||
|
||||
let l:jars = split(l:raw)
|
||||
|
||||
for l:jar in l:jars
|
||||
call add(l:rets, ale#Escape('-javaagent:' . l:jar))
|
||||
endfor
|
||||
|
||||
return join(l:rets, ' ')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#java#eclipselsp#Command(buffer, version) abort
|
||||
let l:path = ale#Var(a:buffer, 'java_eclipselsp_path')
|
||||
|
||||
let l:executable = ale_linters#java#eclipselsp#Executable(a:buffer)
|
||||
|
||||
let l:cmd = [ ale#Escape(l:executable),
|
||||
\ ale_linters#java#eclipselsp#Javaagent(a:buffer),
|
||||
\ '-Declipse.application=org.eclipse.jdt.ls.core.id1',
|
||||
\ '-Dosgi.bundles.defaultStartLevel=4',
|
||||
\ '-Declipse.product=org.eclipse.jdt.ls.core.product',
|
||||
|
||||
@@ -6,6 +6,7 @@ let s:classpath_sep = has('unix') ? ':' : ';'
|
||||
call ale#Set('java_javac_executable', 'javac')
|
||||
call ale#Set('java_javac_options', '')
|
||||
call ale#Set('java_javac_classpath', '')
|
||||
call ale#Set('java_javac_sourcepath', '')
|
||||
|
||||
function! ale_linters#java#javac#RunWithImportPaths(buffer) abort
|
||||
let l:command = ''
|
||||
@@ -40,10 +41,15 @@ endfunction
|
||||
function! s:BuildClassPathOption(buffer, import_paths) abort
|
||||
" Filter out lines like [INFO], etc.
|
||||
let l:class_paths = filter(a:import_paths[:], 'v:val !~# ''[''')
|
||||
call extend(
|
||||
\ l:class_paths,
|
||||
\ split(ale#Var(a:buffer, 'java_javac_classpath'), s:classpath_sep),
|
||||
\)
|
||||
let l:cls_path = ale#Var(a:buffer, 'java_javac_classpath')
|
||||
|
||||
if !empty(l:cls_path) && type(l:cls_path) is v:t_string
|
||||
call extend(l:class_paths, split(l:cls_path, s:classpath_sep))
|
||||
endif
|
||||
|
||||
if !empty(l:cls_path) && type(l:cls_path) is v:t_list
|
||||
call extend(l:class_paths, l:cls_path)
|
||||
endif
|
||||
|
||||
return !empty(l:class_paths)
|
||||
\ ? '-cp ' . ale#Escape(join(l:class_paths, s:classpath_sep))
|
||||
@@ -79,6 +85,27 @@ function! ale_linters#java#javac#GetCommand(buffer, import_paths, meta) abort
|
||||
endif
|
||||
endif
|
||||
|
||||
let l:source_paths = []
|
||||
let l:source_path = ale#Var(a:buffer, 'java_javac_sourcepath')
|
||||
|
||||
if !empty(l:source_path) && type(l:source_path) is v:t_string
|
||||
let l:source_paths = split(l:source_path, s:classpath_sep)
|
||||
endif
|
||||
|
||||
if !empty(l:source_path) && type(l:source_path) is v:t_list
|
||||
let l:source_paths = l:source_path
|
||||
endif
|
||||
|
||||
if !empty(l:source_paths)
|
||||
for l:path in l:source_paths
|
||||
let l:sp_path = ale#path#FindNearestDirectory(a:buffer, l:path)
|
||||
|
||||
if !empty(l:sp_path)
|
||||
call add(l:sp_dirs, l:sp_path)
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
if !empty(l:sp_dirs)
|
||||
let l:sp_option = '-sourcepath '
|
||||
\ . ale#Escape(join(l:sp_dirs, s:classpath_sep))
|
||||
|
||||
@@ -2,11 +2,24 @@
|
||||
" Description: Support for the Java language server https://github.com/georgewfraser/vscode-javac
|
||||
|
||||
call ale#Set('java_javalsp_executable', '')
|
||||
call ale#Set('java_javalsp_config', {})
|
||||
|
||||
function! ale_linters#java#javalsp#Executable(buffer) abort
|
||||
return ale#Var(a:buffer, 'java_javalsp_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#java#javalsp#Config(buffer) abort
|
||||
let l:defaults = { 'java': { 'classPath': [], 'externalDependencies': [] } }
|
||||
let l:config = ale#Var(a:buffer, 'java_javalsp_config')
|
||||
|
||||
" Ensure the config dictionary contains both classPath and
|
||||
" externalDependencies keys to avoid a NPE crash on Java Language Server.
|
||||
call extend(l:config, l:defaults, 'keep')
|
||||
call extend(l:config['java'], l:defaults['java'], 'keep')
|
||||
|
||||
return l:config
|
||||
endfunction
|
||||
|
||||
function! ale_linters#java#javalsp#Command(buffer) abort
|
||||
let l:executable = ale_linters#java#javalsp#Executable(a:buffer)
|
||||
|
||||
@@ -38,4 +51,5 @@ call ale#linter#Define('java', {
|
||||
\ 'command': function('ale_linters#java#javalsp#Command'),
|
||||
\ 'language': 'java',
|
||||
\ 'project_root': function('ale#java#FindProjectRoot'),
|
||||
\ 'lsp_config': function('ale_linters#java#javalsp#Config')
|
||||
\})
|
||||
|
||||
0
ale_linters/javascript/flow.vim
Executable file → Normal file
0
ale_linters/javascript/flow.vim
Executable file → Normal file
@@ -7,7 +7,9 @@ call ale#Set('javascript_standard_options', '')
|
||||
|
||||
function! ale_linters#javascript#standard#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'javascript_standard', [
|
||||
\ 'node_modules/standardx/bin/cmd.js',
|
||||
\ 'node_modules/standard/bin/cmd.js',
|
||||
\ 'node_modules/semistandard/bin/cmd.js',
|
||||
\ 'node_modules/.bin/standard',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
@@ -174,6 +174,7 @@ endfunction
|
||||
call ale#linter#Define('kotlin', {
|
||||
\ 'name': 'kotlinc',
|
||||
\ 'executable': 'kotlinc',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'command': function('ale_linters#kotlin#kotlinc#RunWithImportPaths'),
|
||||
\ 'callback': 'ale_linters#kotlin#kotlinc#Handle',
|
||||
\ 'lint_file': 1,
|
||||
|
||||
0
ale_linters/less/lessc.vim
Executable file → Normal file
0
ale_linters/less/lessc.vim
Executable file → Normal file
@@ -17,18 +17,17 @@ function! ale_linters#markdown#mdl#GetCommand(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'markdown_mdl_options')
|
||||
|
||||
return ale#Escape(l:executable) . l:exec_args
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' -j' . (!empty(l:options) ? ' ' . l:options : '')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#markdown#mdl#Handle(buffer, lines) abort
|
||||
" matches: '(stdin):173: MD004 Unordered list style'
|
||||
let l:pattern = ':\(\d*\): \(.*\)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'text': l:match[2],
|
||||
\ 'lnum': l:error['line'],
|
||||
\ 'code': l:error['rule'] . '/' . join(l:error['aliases'], '/'),
|
||||
\ 'text': l:error['description'],
|
||||
\ 'type': 'W',
|
||||
\})
|
||||
endfor
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
" Author: Baabelfish
|
||||
" Description: Typechecking for nim files
|
||||
|
||||
let s:end_col_patterns = [
|
||||
\ '\v''([^'']+)'' is declared but not used.*',
|
||||
\ '\videntifier expected, but found ''([^'']+)''',
|
||||
\ '\vimported and not used: ''([^'']+)''.*',
|
||||
\ '\vundeclared identifier: ''([^'']+)''',
|
||||
\ '\v''([^'']+)'' cannot be assigned to',
|
||||
\ '\vredefinition of ''([^'']+)'';',
|
||||
\]
|
||||
|
||||
function! ale_linters#nim#nimcheck#Handle(buffer, lines) abort
|
||||
let l:buffer_filename = fnamemodify(bufname(a:buffer), ':p:t')
|
||||
let l:pattern = '^\(.\+\.nim\)(\(\d\+\), \(\d\+\)) \(.\+\)'
|
||||
@@ -43,6 +52,11 @@ function! ale_linters#nim#nimcheck#Handle(buffer, lines) abort
|
||||
let l:item.code = l:code_match[2]
|
||||
endif
|
||||
|
||||
" Find position end_col.
|
||||
for l:col_match in ale#util#GetMatches(l:item.text, s:end_col_patterns)
|
||||
let l:item.end_col = l:item.col + len(l:col_match[1]) - 1
|
||||
endfor
|
||||
|
||||
call add(l:output, l:item)
|
||||
endfor
|
||||
|
||||
|
||||
33
ale_linters/nim/nimlsp.vim
Normal file
33
ale_linters/nim/nimlsp.vim
Normal file
@@ -0,0 +1,33 @@
|
||||
" Author: jeremija <https://github.com/jeremija>
|
||||
" Description: Support for nimlsp (language server for nim)
|
||||
|
||||
call ale#Set('nim_nimlsp_nim_sources', '')
|
||||
|
||||
function! ale_linters#nim#nimlsp#GetProjectRoot(buffer) abort
|
||||
let l:project_root = ale#path#FindNearestDirectory(a:buffer, '.git')
|
||||
|
||||
if !empty(l:project_root)
|
||||
return fnamemodify(l:project_root, ':h:h')
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! ale_linters#nim#nimlsp#GetCommand(buffer) abort
|
||||
let l:nim_sources = ale#Var(a:buffer, 'nim_nimlsp_nim_sources')
|
||||
|
||||
if !empty(l:nim_sources)
|
||||
let l:nim_sources = ale#Escape(l:nim_sources)
|
||||
endif
|
||||
|
||||
return '%e' . ale#Pad(l:nim_sources)
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('nim', {
|
||||
\ 'name': 'nimlsp',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': 'nimlsp',
|
||||
\ 'command': function('ale_linters#nim#nimlsp#GetCommand'),
|
||||
\ 'language': 'nim',
|
||||
\ 'project_root': function('ale_linters#nim#nimlsp#GetProjectRoot'),
|
||||
\})
|
||||
@@ -1,7 +1,8 @@
|
||||
" Author: Matt Brown <https://github.com/muglug>
|
||||
" Description: plugin for Psalm, static analyzer for PHP
|
||||
|
||||
call ale#Set('psalm_langserver_executable', 'psalm-language-server')
|
||||
call ale#Set('psalm_langserver_executable', 'psalm')
|
||||
call ale#Set('psalm_langserver_options', '')
|
||||
call ale#Set('psalm_langserver_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
|
||||
function! ale_linters#php#psalm#GetProjectRoot(buffer) abort
|
||||
@@ -10,12 +11,16 @@ function! ale_linters#php#psalm#GetProjectRoot(buffer) abort
|
||||
return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : ''
|
||||
endfunction
|
||||
|
||||
function! ale_linters#php#psalm#GetCommand(buffer) abort
|
||||
return '%e --language-server' . ale#Pad(ale#Var(a:buffer, 'psalm_langserver_options'))
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('php', {
|
||||
\ 'name': 'psalm',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': {b -> ale#node#FindExecutable(b, 'psalm_langserver', [
|
||||
\ 'vendor/bin/psalm-language-server',
|
||||
\ 'vendor/bin/psalm',
|
||||
\ ])},
|
||||
\ 'command': '%e',
|
||||
\ 'command': function('ale_linters#php#psalm#GetCommand'),
|
||||
\ 'project_root': function('ale_linters#php#psalm#GetProjectRoot'),
|
||||
\})
|
||||
|
||||
13
ale_linters/powershell/powershell.vim
Executable file → Normal file
13
ale_linters/powershell/powershell.vim
Executable file → Normal file
@@ -12,6 +12,7 @@ endfunction
|
||||
" https://rkeithhill.wordpress.com/2007/10/30/powershell-quicktip-preparsing-scripts-to-check-for-syntax-errors/
|
||||
function! ale_linters#powershell#powershell#GetCommand(buffer) abort
|
||||
let l:script = ['Param($Script);
|
||||
\ $ErrorView = "Normal";
|
||||
\ trap {$_;continue} & {
|
||||
\ $Contents = Get-Content -Path $Script;
|
||||
\ $Contents = [string]::Join([Environment]::NewLine, $Contents);
|
||||
@@ -49,11 +50,19 @@ function! ale_linters#powershell#powershell#Handle(buffer, lines) abort
|
||||
let l:matchcount = 1
|
||||
endif
|
||||
|
||||
" If the match is 0, it was a failed match
|
||||
" probably due to an unexpected token which
|
||||
" contained a newline. Reset matchcount. to
|
||||
" continue to the next match
|
||||
if !empty(l:match[1])
|
||||
let l:item = {
|
||||
\ 'lnum': str2nr(l:match[1]),
|
||||
\ 'col': str2nr(l:match[2]),
|
||||
\ 'type': 'E',
|
||||
\}
|
||||
else
|
||||
let l:matchcount = 0
|
||||
endif
|
||||
elseif l:matchcount == 2
|
||||
" Second match[0] grabs the full line in order
|
||||
" to handles the text
|
||||
@@ -84,8 +93,8 @@ endfunction
|
||||
|
||||
call ale#linter#Define('powershell', {
|
||||
\ 'name': 'powershell',
|
||||
\ 'executable_callback': 'ale_linters#powershell#powershell#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#powershell#powershell#GetCommand',
|
||||
\ 'executable': function('ale_linters#powershell#powershell#GetExecutable'),
|
||||
\ 'command': function('ale_linters#powershell#powershell#GetCommand'),
|
||||
\ 'output_stream': 'stdout',
|
||||
\ 'callback': 'ale_linters#powershell#powershell#Handle',
|
||||
\})
|
||||
|
||||
49
ale_linters/purescript/ls.vim
Normal file
49
ale_linters/purescript/ls.vim
Normal file
@@ -0,0 +1,49 @@
|
||||
" Author: Drew Olson <drew@drewolson.org>
|
||||
" Description: Integrate ALE with purescript-language-server.
|
||||
|
||||
call ale#Set('purescript_ls_executable', 'purescript-language-server')
|
||||
call ale#Set('purescript_ls_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('purescript_ls_config', {})
|
||||
|
||||
function! ale_linters#purescript#ls#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'purescript_ls', [
|
||||
\ 'node_modules/.bin/purescript-language-server',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#purescript#ls#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#purescript#ls#GetExecutable(a:buffer)
|
||||
|
||||
return ale#Escape(l:executable) . ' --stdio'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#purescript#ls#FindProjectRoot(buffer) abort
|
||||
let l:config = ale#path#FindNearestFile(a:buffer, 'bower.json')
|
||||
|
||||
if !empty(l:config)
|
||||
return fnamemodify(l:config, ':h')
|
||||
endif
|
||||
|
||||
let l:config = ale#path#FindNearestFile(a:buffer, 'psc-package.json')
|
||||
|
||||
if !empty(l:config)
|
||||
return fnamemodify(l:config, ':h')
|
||||
endif
|
||||
|
||||
let l:config = ale#path#FindNearestFile(a:buffer, 'spago.dhall')
|
||||
|
||||
if !empty(l:config)
|
||||
return fnamemodify(l:config, ':h')
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('purescript', {
|
||||
\ 'name': 'purescript-language-server',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': function('ale_linters#purescript#ls#GetExecutable'),
|
||||
\ 'command': function('ale_linters#purescript#ls#GetCommand'),
|
||||
\ 'project_root': function('ale_linters#purescript#ls#FindProjectRoot'),
|
||||
\ 'lsp_config': {b -> ale#Var(b, 'purescript_ls_config')},
|
||||
\})
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
call ale#Set('python_mypy_executable', 'mypy')
|
||||
call ale#Set('python_mypy_ignore_invalid_syntax', 0)
|
||||
call ale#Set('python_mypy_show_notes', 1)
|
||||
call ale#Set('python_mypy_options', '')
|
||||
call ale#Set('python_mypy_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('python_mypy_auto_pipenv', 0)
|
||||
@@ -18,6 +19,15 @@ endfunction
|
||||
|
||||
" The directory to change to before running mypy
|
||||
function! s:GetDir(buffer) abort
|
||||
" If we find a directory with "mypy.ini" in it use that,
|
||||
" else try and find the "python project" root, or failing
|
||||
" that, run from the same folder as the current file
|
||||
for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h'))
|
||||
if filereadable(l:path . '/mypy.ini')
|
||||
return l:path
|
||||
endif
|
||||
endfor
|
||||
|
||||
let l:project_root = ale#python#FindProjectRoot(a:buffer)
|
||||
|
||||
return !empty(l:project_root)
|
||||
@@ -51,7 +61,16 @@ function! ale_linters#python#mypy#Handle(buffer, lines) abort
|
||||
" Lines like these should be ignored below:
|
||||
"
|
||||
" 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:types = 'error|warning'
|
||||
|
||||
if ale#Var(a:buffer, 'python_mypy_show_notes')
|
||||
let l:types = 'error|warning|note'
|
||||
endif
|
||||
|
||||
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?: ('
|
||||
\ . l:types
|
||||
\ . '): (.+)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
@@ -65,7 +84,7 @@ function! ale_linters#python#mypy#Handle(buffer, lines) abort
|
||||
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'col': l:match[3] + 0,
|
||||
\ 'type': l:match[4] is# 'error' ? 'E' : 'W',
|
||||
\ 'type': l:match[4] is# 'error' ? 'E' : (l:match[4] is# 'note' ? 'I': 'W'),
|
||||
\ 'text': l:match[5],
|
||||
\})
|
||||
endfor
|
||||
@@ -78,4 +97,5 @@ call ale#linter#Define('python', {
|
||||
\ 'executable': function('ale_linters#python#mypy#GetExecutable'),
|
||||
\ 'command': function('ale_linters#python#mypy#GetCommand'),
|
||||
\ 'callback': 'ale_linters#python#mypy#Handle',
|
||||
\ 'output_stream': 'both'
|
||||
\})
|
||||
|
||||
@@ -36,7 +36,7 @@ function! ale_linters#ruby#brakeman#GetCommand(buffer) abort
|
||||
|
||||
let l:executable = ale#Var(a:buffer, 'ruby_brakeman_executable')
|
||||
|
||||
return ale#handlers#ruby#EscapeExecutable(l:executable, 'brakeman')
|
||||
return ale#ruby#EscapeExecutable(l:executable, 'brakeman')
|
||||
\ . ' -f json -q '
|
||||
\ . ale#Var(a:buffer, 'ruby_brakeman_options')
|
||||
\ . ' -p ' . ale#Escape(l:rails_root)
|
||||
|
||||
42
ale_linters/ruby/debride.vim
Normal file
42
ale_linters/ruby/debride.vim
Normal file
@@ -0,0 +1,42 @@
|
||||
" Author: Eddie Lebow https://github.com/elebow
|
||||
" Description: debride, a dead method detector for Ruby files
|
||||
|
||||
call ale#Set('ruby_debride_executable', 'debride')
|
||||
call ale#Set('ruby_debride_options', '')
|
||||
|
||||
function! ale_linters#ruby#debride#GetCommand(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'ruby_debride_executable')
|
||||
|
||||
return ale#ruby#EscapeExecutable(l:executable, 'debride')
|
||||
\ . ale#Var(a:buffer, 'ruby_debride_options')
|
||||
\ . ' %s'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#ruby#debride#HandleOutput(buffer, lines) abort
|
||||
let l:output = []
|
||||
|
||||
for l:line in a:lines
|
||||
if l:line !~# '^ '
|
||||
continue
|
||||
endif
|
||||
|
||||
let l:elements = split(l:line)
|
||||
let l:method_name = l:elements[0]
|
||||
let l:lnum = split(l:elements[1], ':')[1]
|
||||
|
||||
call add(l:output, {
|
||||
\ 'lnum': 0 + l:lnum,
|
||||
\ 'text': 'Possible unused method: ' . l:method_name,
|
||||
\ 'type': 'W',
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('ruby', {
|
||||
\ 'name': 'debride',
|
||||
\ 'executable': {b -> ale#Var(b, 'ruby_debride_executable')},
|
||||
\ 'command': function('ale_linters#ruby#debride#GetCommand'),
|
||||
\ 'callback': 'ale_linters#ruby#debride#HandleOutput',
|
||||
\})
|
||||
@@ -33,7 +33,7 @@ function! ale_linters#ruby#rails_best_practices#GetCommand(buffer) abort
|
||||
let l:output_file = has('win32') ? '%t ' : '/dev/stdout '
|
||||
let l:cat_file = has('win32') ? '; type %t' : ''
|
||||
|
||||
return ale#handlers#ruby#EscapeExecutable(l:executable, 'rails_best_practices')
|
||||
return ale#ruby#EscapeExecutable(l:executable, 'rails_best_practices')
|
||||
\ . ' --silent -f json --output-file ' . l:output_file
|
||||
\ . ale#Var(a:buffer, 'ruby_rails_best_practices_options')
|
||||
\ . ale#Escape(l:rails_root)
|
||||
|
||||
@@ -14,7 +14,7 @@ function! ale_linters#ruby#reek#GetCommand(buffer, version) abort
|
||||
\ ? ' --stdin-filename %s'
|
||||
\ : ''
|
||||
|
||||
return ale#handlers#ruby#EscapeExecutable(l:executable, 'reek')
|
||||
return ale#ruby#EscapeExecutable(l:executable, 'reek')
|
||||
\ . ' -f json --no-progress --no-color --force-exclusion'
|
||||
\ . l:display_name_args
|
||||
endfunction
|
||||
|
||||
@@ -7,7 +7,7 @@ call ale#Set('ruby_rubocop_options', '')
|
||||
function! ale_linters#ruby#rubocop#GetCommand(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'ruby_rubocop_executable')
|
||||
|
||||
return ale#handlers#ruby#EscapeExecutable(l:executable, 'rubocop')
|
||||
return ale#ruby#EscapeExecutable(l:executable, 'rubocop')
|
||||
\ . ' --format json --force-exclusion '
|
||||
\ . ale#Var(a:buffer, 'ruby_rubocop_options')
|
||||
\ . ' --stdin ' . ale#Escape(expand('#' . a:buffer . ':p'))
|
||||
|
||||
23
ale_linters/ruby/sorbet.vim
Normal file
23
ale_linters/ruby/sorbet.vim
Normal file
@@ -0,0 +1,23 @@
|
||||
call ale#Set('ruby_sorbet_executable', 'srb')
|
||||
call ale#Set('ruby_sorbet_options', '')
|
||||
|
||||
function! ale_linters#ruby#sorbet#GetCommand(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'ruby_sorbet_executable')
|
||||
let l:options = ale#Var(a:buffer, 'ruby_sorbet_options')
|
||||
|
||||
return ale#ruby#EscapeExecutable(l:executable, 'srb')
|
||||
\ . ' tc'
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' --lsp --disable-watchman'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('ruby', {
|
||||
\ 'name': 'sorbet',
|
||||
\ 'aliases': ['srb'],
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'language': 'ruby',
|
||||
\ 'executable': {b -> ale#Var(b, 'ruby_sorbet_executable')},
|
||||
\ 'command': function('ale_linters#ruby#sorbet#GetCommand'),
|
||||
\ 'project_root': function('ale#ruby#FindProjectRoot')
|
||||
\})
|
||||
|
||||
@@ -8,7 +8,7 @@ call ale#Set('ruby_standardrb_options', '')
|
||||
function! ale_linters#ruby#standardrb#GetCommand(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'ruby_standardrb_executable')
|
||||
|
||||
return ale#handlers#ruby#EscapeExecutable(l:executable, 'standardrb')
|
||||
return ale#ruby#EscapeExecutable(l:executable, 'standardrb')
|
||||
\ . ' --format json --force-exclusion '
|
||||
\ . ale#Var(a:buffer, 'ruby_standardrb_options')
|
||||
\ . ' --stdin ' . ale#Escape(expand('#' . a:buffer . ':p'))
|
||||
|
||||
24
ale_linters/rust/analyzer.vim
Normal file
24
ale_linters/rust/analyzer.vim
Normal file
@@ -0,0 +1,24 @@
|
||||
" Author: Jon Gjengset <jon@thesquareplanet.com>
|
||||
" Description: The next generation language server for Rust
|
||||
|
||||
call ale#Set('rust_analyzer_executable', 'rust-analyzer')
|
||||
call ale#Set('rust_analyzer_config', {})
|
||||
|
||||
function! ale_linters#rust#analyzer#GetCommand(buffer) abort
|
||||
return '%e'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#rust#analyzer#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': 'analyzer',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'lsp_config': {b -> ale#Var(b, 'rust_analyzer_config')},
|
||||
\ 'executable': {b -> ale#Var(b, 'rust_analyzer_executable')},
|
||||
\ 'command': function('ale_linters#rust#analyzer#GetCommand'),
|
||||
\ 'project_root': function('ale_linters#rust#analyzer#GetProjectRoot'),
|
||||
\})
|
||||
@@ -25,14 +25,11 @@ endfunction
|
||||
function! ale_linters#rust#cargo#GetCommand(buffer, version) abort
|
||||
let l:use_check = ale#Var(a:buffer, 'rust_cargo_use_check')
|
||||
\ && ale#semver#GTE(a:version, [0, 17, 0])
|
||||
let l:use_all_targets = l:use_check
|
||||
\ && ale#Var(a:buffer, 'rust_cargo_check_all_targets')
|
||||
let l:use_all_targets = ale#Var(a:buffer, 'rust_cargo_check_all_targets')
|
||||
\ && ale#semver#GTE(a:version, [0, 22, 0])
|
||||
let l:use_examples = l:use_check
|
||||
\ && ale#Var(a:buffer, 'rust_cargo_check_examples')
|
||||
let l:use_examples = ale#Var(a:buffer, 'rust_cargo_check_examples')
|
||||
\ && ale#semver#GTE(a:version, [0, 22, 0])
|
||||
let l:use_tests = l:use_check
|
||||
\ && ale#Var(a:buffer, 'rust_cargo_check_tests')
|
||||
let l:use_tests = ale#Var(a:buffer, 'rust_cargo_check_tests')
|
||||
\ && ale#semver#GTE(a:version, [0, 22, 0])
|
||||
|
||||
let l:include_features = ale#Var(a:buffer, 'rust_cargo_include_features')
|
||||
@@ -69,7 +66,15 @@ function! ale_linters#rust#cargo#GetCommand(buffer, version) abort
|
||||
|
||||
if ale#Var(a:buffer, 'rust_cargo_use_clippy')
|
||||
let l:subcommand = 'clippy'
|
||||
let l:clippy_options = ' ' . ale#Var(a:buffer, 'rust_cargo_clippy_options')
|
||||
let l:clippy_options = ale#Var(a:buffer, 'rust_cargo_clippy_options')
|
||||
|
||||
if l:clippy_options =~# '^-- '
|
||||
let l:clippy_options = join(split(l:clippy_options, '-- '))
|
||||
endif
|
||||
|
||||
if l:clippy_options isnot# ''
|
||||
let l:clippy_options = ' -- ' . l:clippy_options
|
||||
endif
|
||||
endif
|
||||
|
||||
return l:nearest_cargo_prefix . 'cargo '
|
||||
|
||||
50
ale_linters/scala/metals.vim
Normal file
50
ale_linters/scala/metals.vim
Normal file
@@ -0,0 +1,50 @@
|
||||
" Author: Jeffrey Lau - https://github.com/zoonfafer
|
||||
" Description: Metals Language Server for Scala https://scalameta.org/metals/
|
||||
|
||||
call ale#Set('scala_metals_executable', 'metals-vim')
|
||||
call ale#Set('scala_metals_project_root', '')
|
||||
|
||||
function! ale_linters#scala#metals#GetProjectRoot(buffer) abort
|
||||
let l:project_root = ale#Var(a:buffer, 'scala_metals_project_root')
|
||||
|
||||
if !empty(l:project_root)
|
||||
return l:project_root
|
||||
endif
|
||||
|
||||
let l:potential_roots = [
|
||||
\ 'build.sc',
|
||||
\ 'build.sbt',
|
||||
\ '.bloop',
|
||||
\ '.metals',
|
||||
\]
|
||||
|
||||
for l:root in l:potential_roots
|
||||
let l:project_root = ale#path#ResolveLocalPath(
|
||||
\ a:buffer,
|
||||
\ l:root,
|
||||
\ ''
|
||||
\)
|
||||
|
||||
if !empty(l:project_root)
|
||||
return fnamemodify(
|
||||
\ l:project_root,
|
||||
\ ':h',
|
||||
\)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! ale_linters#scala#metals#GetCommand(buffer) abort
|
||||
return '%e' . ale#Pad('stdio')
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('scala', {
|
||||
\ 'name': 'metals',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'language': 'scala',
|
||||
\ 'executable': {b -> ale#Var(b, 'scala_metals_executable')},
|
||||
\ 'command': function('ale_linters#scala#metals#GetCommand'),
|
||||
\ 'project_root': function('ale_linters#scala#metals#GetProjectRoot'),
|
||||
\})
|
||||
@@ -34,8 +34,10 @@ function! ale_linters#sh#shell#Handle(buffer, lines) abort
|
||||
" Matches patterns line the following:
|
||||
"
|
||||
" bash: line 13: syntax error near unexpected token `d'
|
||||
" bash:行0: 未预期的符号“done”附近有语法错误
|
||||
" bash: 列 90: 尋找匹配的「"」時遇到了未預期的檔案結束符
|
||||
" sh: 11: Syntax error: "(" unexpected
|
||||
let l:pattern = '\v(line |: ?)(\d+): (.+)$'
|
||||
let l:pattern = '\v([^:]+:\D*)(\d+): (.+)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
|
||||
@@ -1,107 +1,4 @@
|
||||
" Author: w0rp <devw0rp@gmail.com>
|
||||
" Description: This file adds support for using the shellcheck linter with
|
||||
" shell scripts.
|
||||
" Description: shellcheck linter for shell scripts.
|
||||
|
||||
" This global variable can be set with a string of comma-separated error
|
||||
" codes to exclude from shellcheck. For example:
|
||||
"
|
||||
" let g:ale_sh_shellcheck_exclusions = 'SC2002,SC2004'
|
||||
call ale#Set('sh_shellcheck_exclusions', get(g:, 'ale_linters_sh_shellcheck_exclusions', ''))
|
||||
call ale#Set('sh_shellcheck_executable', 'shellcheck')
|
||||
call ale#Set('sh_shellcheck_dialect', 'auto')
|
||||
call ale#Set('sh_shellcheck_options', '')
|
||||
call ale#Set('sh_shellcheck_change_directory', 1)
|
||||
|
||||
function! ale_linters#sh#shellcheck#GetDialectArgument(buffer) abort
|
||||
let l:shell_type = ale#handlers#sh#GetShellType(a:buffer)
|
||||
|
||||
if !empty(l:shell_type)
|
||||
" Use the dash dialect for /bin/ash, etc.
|
||||
if l:shell_type is# 'ash'
|
||||
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
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! ale_linters#sh#shellcheck#GetCommand(buffer, version) abort
|
||||
let l:options = ale#Var(a:buffer, 'sh_shellcheck_options')
|
||||
let l:exclude_option = ale#Var(a:buffer, 'sh_shellcheck_exclusions')
|
||||
let l:dialect = ale#Var(a:buffer, 'sh_shellcheck_dialect')
|
||||
let l:external_option = ale#semver#GTE(a:version, [0, 4, 0]) ? ' -x' : ''
|
||||
let l:cd_string = ale#Var(a:buffer, 'sh_shellcheck_change_directory')
|
||||
\ ? ale#path#BufferCdString(a:buffer)
|
||||
\ : ''
|
||||
|
||||
if l:dialect is# 'auto'
|
||||
let l:dialect = ale_linters#sh#shellcheck#GetDialectArgument(a:buffer)
|
||||
endif
|
||||
|
||||
return l:cd_string
|
||||
\ . '%e'
|
||||
\ . (!empty(l:dialect) ? ' -s ' . l:dialect : '')
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . (!empty(l:exclude_option) ? ' -e ' . l:exclude_option : '')
|
||||
\ . l:external_option
|
||||
\ . ' -f gcc -'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#sh#shellcheck#Handle(buffer, lines) abort
|
||||
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+)?:? ([^:]+): (.+) \[([^\]]+)\]$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
if l:match[4] is# 'error'
|
||||
let l:type = 'E'
|
||||
elseif l:match[4] is# 'note'
|
||||
let l:type = 'I'
|
||||
else
|
||||
let l:type = 'W'
|
||||
endif
|
||||
|
||||
let l:item = {
|
||||
\ 'lnum': str2nr(l:match[2]),
|
||||
\ 'type': l:type,
|
||||
\ 'text': l:match[5],
|
||||
\ 'code': l:match[6],
|
||||
\}
|
||||
|
||||
if !empty(l:match[3])
|
||||
let l:item.col = str2nr(l:match[3])
|
||||
endif
|
||||
|
||||
" If the filename is something like <stdin>, <nofile> or -, then
|
||||
" this is an error for the file we checked.
|
||||
if l:match[1] isnot# '-' && l:match[1][0] isnot# '<'
|
||||
let l:item['filename'] = l:match[1]
|
||||
endif
|
||||
|
||||
call add(l:output, l:item)
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('sh', {
|
||||
\ 'name': 'shellcheck',
|
||||
\ 'executable': {buffer -> ale#Var(buffer, 'sh_shellcheck_executable')},
|
||||
\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
|
||||
\ buffer,
|
||||
\ ale#Var(buffer, 'sh_shellcheck_executable'),
|
||||
\ '%e --version',
|
||||
\ function('ale_linters#sh#shellcheck#GetCommand'),
|
||||
\ )},
|
||||
\ 'callback': 'ale_linters#sh#shellcheck#Handle',
|
||||
\})
|
||||
call ale#handlers#shellcheck#DefineLinter('sh')
|
||||
|
||||
35
ale_linters/solidity/solc.vim
Normal file
35
ale_linters/solidity/solc.vim
Normal file
@@ -0,0 +1,35 @@
|
||||
" Author: Karl Bartel <karl42@gmail.com> - http://karl.berlin/
|
||||
" Description: Report solc compiler errors in Solidity code
|
||||
|
||||
call ale#Set('solidity_solc_options', '')
|
||||
|
||||
function! ale_linters#solidity#solc#Handle(buffer, lines) abort
|
||||
" Matches patterns like the following:
|
||||
" /path/to/file/file.sol:1:10: Error: Identifier not found or not unique.
|
||||
let l:pattern = '\v^[^:]+:(\d+):(\d+): (Error|Warning): (.*)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:isError = l:match[3] is? 'error'
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'col': l:match[2] + 0,
|
||||
\ 'text': l:match[4],
|
||||
\ 'type': l:isError ? 'E' : 'W',
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
function! ale_linters#solidity#solc#GetCommand(buffer) abort
|
||||
return 'solc' . ale#Pad(ale#Var(a:buffer, 'solidity_solc_options')) . ' %s'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('solidity', {
|
||||
\ 'name': 'solc',
|
||||
\ 'executable': 'solc',
|
||||
\ 'command': function('ale_linters#solidity#solc#GetCommand'),
|
||||
\ 'callback': 'ale_linters#solidity#solc#Handle',
|
||||
\ 'output_stream': 'stderr',
|
||||
\})
|
||||
0
ale_linters/terraform/terraform.vim
Executable file → Normal file
0
ale_linters/terraform/terraform.vim
Executable file → Normal file
25
ale_linters/terraform/terraform_lsp.vim
Normal file
25
ale_linters/terraform/terraform_lsp.vim
Normal file
@@ -0,0 +1,25 @@
|
||||
" Author: OJFord <dev@ojford.com>
|
||||
" Description: terraform-lsp integration for ALE (cf. https://github.com/juliosueiras/terraform-lsp)
|
||||
|
||||
call ale#Set('terraform_langserver_executable', 'terraform-lsp')
|
||||
call ale#Set('terraform_langserver_options', '')
|
||||
|
||||
function! ale_linters#terraform#terraform_lsp#GetCommand(buffer) abort
|
||||
return '%e'
|
||||
\ . ale#Pad(ale#Var(a:buffer, 'terraform_langserver_options'))
|
||||
endfunction
|
||||
|
||||
function! ale_linters#terraform#terraform_lsp#GetProjectRoot(buffer) abort
|
||||
let l:tf_dir = ale#path#FindNearestDirectory(a:buffer, '.terraform')
|
||||
|
||||
return !empty(l:tf_dir) ? fnamemodify(l:tf_dir, ':h:h') : ''
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('terraform', {
|
||||
\ 'name': 'terraform_lsp',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': {b -> ale#Var(b, 'terraform_langserver_executable')},
|
||||
\ 'command': function('ale_linters#terraform#terraform_lsp#GetCommand'),
|
||||
\ 'project_root': function('ale_linters#terraform#terraform_lsp#GetProjectRoot'),
|
||||
\ 'language': 'terraform',
|
||||
\})
|
||||
@@ -9,8 +9,13 @@ call ale#Set('terraform_tflint_executable', 'tflint')
|
||||
|
||||
function! ale_linters#terraform#tflint#Handle(buffer, lines) abort
|
||||
let l:output = []
|
||||
let l:pattern = '\v^(.*):(\d+),(\d+)-(\d+)?,?(\d+): (.{-1,}); (.+)$'
|
||||
let l:json = ale#util#FuzzyJSONDecode(a:lines, {})
|
||||
|
||||
for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
|
||||
" This is a rough test for tflint's output format
|
||||
" On versions prior to 0.11 it outputs all errors as a single level list
|
||||
if type(l:json) is v:t_list
|
||||
for l:error in l:json
|
||||
if l:error.type is# 'ERROR'
|
||||
let l:type = 'E'
|
||||
elseif l:error.type is# 'NOTICE'
|
||||
@@ -26,6 +31,47 @@ function! ale_linters#terraform#tflint#Handle(buffer, lines) abort
|
||||
\ 'code': l:error.detector,
|
||||
\})
|
||||
endfor
|
||||
else
|
||||
for l:error in get(l:json, 'errors', [])
|
||||
for l:match in ale#util#GetMatches(l:error.message, [l:pattern])
|
||||
if l:match[4] is# ''
|
||||
let l:match[4] = l:match[2]
|
||||
endif
|
||||
|
||||
call add(l:output, {
|
||||
\ 'filename': l:match[1],
|
||||
\ 'lnum': str2nr(l:match[2]),
|
||||
\ 'col': str2nr(l:match[3]),
|
||||
\ 'end_lnum': str2nr(l:match[4]),
|
||||
\ 'end_col': str2nr(l:match[5]),
|
||||
\ 'text': l:match[7],
|
||||
\ 'code': l:match[6],
|
||||
\ 'type': 'E',
|
||||
\})
|
||||
endfor
|
||||
endfor
|
||||
|
||||
for l:error in get(l:json, 'issues', [])
|
||||
if l:error.rule.severity is# 'ERROR'
|
||||
let l:type = 'E'
|
||||
elseif l:error.rule.severity is# 'NOTICE'
|
||||
let l:type = 'I'
|
||||
else
|
||||
let l:type = 'W'
|
||||
endif
|
||||
|
||||
call add(l:output, {
|
||||
\ 'filename': l:error.range.filename,
|
||||
\ 'lnum': l:error.range.start.line,
|
||||
\ 'col': l:error.range.start.column,
|
||||
\ 'end_lnum': l:error.range.end.line,
|
||||
\ 'end_col': l:error.range.end.column,
|
||||
\ 'text': l:error.message,
|
||||
\ 'code': l:error.rule.name,
|
||||
\ 'type': l:type,
|
||||
\})
|
||||
endfor
|
||||
endif
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
31
ale_linters/typescript/standard.vim
Normal file
31
ale_linters/typescript/standard.vim
Normal file
@@ -0,0 +1,31 @@
|
||||
" Author: Ahmed El Gabri <@ahmedelgabri>
|
||||
" Description: standardjs for typescript files
|
||||
|
||||
call ale#Set('typescript_standard_executable', 'standard')
|
||||
call ale#Set('typescript_standard_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('typescript_standard_options', '')
|
||||
|
||||
function! ale_linters#typescript#standard#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'typescript_standard', [
|
||||
\ 'node_modules/standardx/bin/cmd.js',
|
||||
\ 'node_modules/standard/bin/cmd.js',
|
||||
\ 'node_modules/.bin/standard',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#typescript#standard#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#typescript#standard#GetExecutable(a:buffer)
|
||||
let l:options = ale#Var(a:buffer, 'typescript_standard_options')
|
||||
|
||||
return ale#node#Executable(a:buffer, l:executable)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' --stdin %s'
|
||||
endfunction
|
||||
|
||||
" standard uses eslint and the output format is the same
|
||||
call ale#linter#Define('typescript', {
|
||||
\ 'name': 'standard',
|
||||
\ 'executable': function('ale_linters#typescript#standard#GetExecutable'),
|
||||
\ 'command': function('ale_linters#typescript#standard#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#eslint#Handle',
|
||||
\})
|
||||
@@ -28,21 +28,30 @@ function! ale_linters#verilog#verilator#Handle(buffer, lines) abort
|
||||
" %Warning-UNDRIVEN: test.v:3: Signal is not driven: clk
|
||||
" %Warning-UNUSED: test.v:4: Signal is not used: dout
|
||||
" %Warning-BLKSEQ: test.v:10: Blocking assignments (=) in sequential (flop or latch) block; suggest delayed assignments (<=).
|
||||
let l:pattern = '^%\(Warning\|Error\)[^:]*:\([^:]\+\):\(\d\+\): \(.\+\)$'
|
||||
" Since version 4.032 (04/2020) verilator linter messages also contain the column number,
|
||||
" and look like:
|
||||
" %Error: /tmp/test.sv:3:1: syntax error, unexpected endmodule, expecting ';'
|
||||
"
|
||||
" to stay compatible with old versions of the tool, the column number is
|
||||
" optional in the researched pattern
|
||||
let l:pattern = '^%\(Warning\|Error\)[^:]*:\([^:]\+\):\(\d\+\):\(\d\+\)\?:\? \(.\+\)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:line = l:match[3] + 0
|
||||
let l:type = l:match[1] is# 'Error' ? 'E' : 'W'
|
||||
let l:text = l:match[4]
|
||||
let l:item = {
|
||||
\ 'lnum': str2nr(l:match[3]),
|
||||
\ 'text': l:match[5],
|
||||
\ 'type': l:match[1] is# 'Error' ? 'E' : 'W',
|
||||
\}
|
||||
|
||||
if !empty(l:match[4])
|
||||
let l:item.col = str2nr(l:match[4])
|
||||
endif
|
||||
|
||||
let l:file = l:match[2]
|
||||
|
||||
if l:file =~# '_verilator_linted.v'
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:line,
|
||||
\ 'text': l:text,
|
||||
\ 'type': l:type,
|
||||
\})
|
||||
call add(l:output, l:item)
|
||||
endif
|
||||
endfor
|
||||
|
||||
|
||||
@@ -24,6 +24,20 @@ function! ale_linters#verilog#vlog#Handle(buffer, lines) abort
|
||||
\})
|
||||
endfor
|
||||
|
||||
"Matches patterns like the following:
|
||||
"** Warning: (vlog-2623) add.v(7): Undefined variable: C.
|
||||
"** Error: (vlog-13294) file.v(1): Identifier must be declared with a port mode: C.
|
||||
" let l:pattern = '^**\s\(\w*\):[a-zA-Z0-9\-\.\_\/ ]\+(\(\d\+\)):\s\+\(.*\)'
|
||||
let l:pattern = '^**\s\(\w*\):\s\([^)]*)\)[a-zA-Z0-9\-\.\_\/ ]\+(\(\d\+\)):\s\+\(.*\)'
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[3] + 0,
|
||||
\ 'type': l:match[1] is? 'Error' ? 'E' : 'W',
|
||||
\ 'text': l:match[2] . ' ' . l:match[4],
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
|
||||
61
ale_linters/vim/vimls.vim
Normal file
61
ale_linters/vim/vimls.vim
Normal file
@@ -0,0 +1,61 @@
|
||||
" Author: Jeffrey Lau - https://github.com/zoonfafer
|
||||
" Description: Vim Language Server integration for ALE
|
||||
|
||||
call ale#Set('vim_vimls_executable', 'vim-language-server')
|
||||
call ale#Set('vim_vimls_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('vim_vimls_config', {})
|
||||
|
||||
function! ale_linters#vim#vimls#GetProjectRoot(buffer) abort
|
||||
let l:trigger_file_candidates = [
|
||||
\ '.vimrc',
|
||||
\ 'init.vim',
|
||||
\]
|
||||
|
||||
for l:candidate in l:trigger_file_candidates
|
||||
let l:trigger_file = fnamemodify(bufname(a:buffer), ':t')
|
||||
|
||||
if l:trigger_file is# l:candidate
|
||||
return fnamemodify(
|
||||
\ bufname(a:buffer),
|
||||
\ ':h',
|
||||
\)
|
||||
endif
|
||||
endfor
|
||||
|
||||
let l:trigger_dir_candidates = [
|
||||
\ 'autoload',
|
||||
\ 'plugin',
|
||||
\ '.git',
|
||||
\]
|
||||
|
||||
let l:path_upwards = ale#path#Upwards(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||
|
||||
for l:path in l:path_upwards
|
||||
for l:candidate in l:trigger_dir_candidates
|
||||
let l:trigger_dir = ale#path#Simplify(
|
||||
\ l:path . '/' . l:candidate,
|
||||
\)
|
||||
|
||||
if isdirectory(l:trigger_dir)
|
||||
return fnamemodify(
|
||||
\ l:trigger_dir,
|
||||
\ ':p:h:h',
|
||||
\)
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('vim', {
|
||||
\ 'name': 'vimls',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'lsp_config': {b -> ale#Var(b, 'vim_vimls_config')},
|
||||
\ 'executable': {b -> ale#node#FindExecutable(b, 'vim_vimls', [
|
||||
\ 'node_modules/.bin/vim-language-server',
|
||||
\ ])},
|
||||
\ 'command': '%e --stdio',
|
||||
\ 'language': 'vim',
|
||||
\ 'project_root': function('ale_linters#vim#vimls#GetProjectRoot'),
|
||||
\})
|
||||
@@ -5,11 +5,18 @@
|
||||
" Strings used for severity in the echoed message
|
||||
let g:ale_echo_msg_error_str = get(g:, 'ale_echo_msg_error_str', 'Error')
|
||||
let g:ale_echo_msg_info_str = get(g:, 'ale_echo_msg_info_str', 'Info')
|
||||
let g:ale_echo_msg_log_str = get(g:, 'ale_echo_msg_log_str', 'Log')
|
||||
let g:ale_echo_msg_warning_str = get(g:, 'ale_echo_msg_warning_str', 'Warning')
|
||||
" Ignoring linters, for disabling some, or ignoring LSP diagnostics.
|
||||
let g:ale_linters_ignore = get(g:, 'ale_linters_ignore', {})
|
||||
let g:ale_disable_lsp = get(g:, 'ale_disable_lsp', 0)
|
||||
|
||||
" LSP window/showMessage format
|
||||
let g:ale_lsp_show_message_format = get(g:, 'ale_lsp_show_message_format', '%severity%:%linter%: %s')
|
||||
" Valid values mimic LSP definitions (error, warning and information; log is
|
||||
" never shown)
|
||||
let g:ale_lsp_show_message_severity = get(g:, 'ale_lsp_show_message_severity', 'error')
|
||||
|
||||
let s:lint_timer = -1
|
||||
let s:getcmdwintype_exists = exists('*getcmdwintype')
|
||||
|
||||
@@ -156,7 +163,7 @@ function! ale#Queue(delay, ...) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let s:current_ale_version = [2, 5, 0]
|
||||
let s:current_ale_version = [2, 7, 0]
|
||||
|
||||
" A function used to check for ALE features in files outside of the project.
|
||||
function! ale#Has(feature) abort
|
||||
@@ -251,9 +258,9 @@ function! ale#GetLocItemMessage(item, format_string) abort
|
||||
|
||||
" Replace special markers with certain information.
|
||||
" \=l:variable is used to avoid escaping issues.
|
||||
let l:msg = substitute(l:msg, '\v\%([^\%]*)code([^\%]*)\%', l:code_repl, 'g')
|
||||
let l:msg = substitute(l:msg, '\V%severity%', '\=l:severity', 'g')
|
||||
let l:msg = substitute(l:msg, '\V%linter%', '\=l:linter_name', 'g')
|
||||
let l:msg = substitute(l:msg, '\v\%([^\%]*)code([^\%]*)\%', l:code_repl, 'g')
|
||||
" Replace %s with the text.
|
||||
let l:msg = substitute(l:msg, '\V%s', '\=a:item.text', 'g')
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
" Author: Andrew Lee <andrewl@mbda.fun>.
|
||||
" Author: Andrew Lee <andrew.lambda@tuta.io>.
|
||||
" Inspired by ale/gradle.vim by Michael Pardo <michael@michaelpardo.com>
|
||||
" Description: Functions for working with Ant projects.
|
||||
|
||||
|
||||
@@ -267,14 +267,22 @@ function! ale#assert#TearDownLinterTest() abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! ale#assert#SetUpFixerTest(filetype, name) abort
|
||||
function! ale#assert#SetUpFixerTest(filetype, name, ...) abort
|
||||
" If the suffix of the option names format is different, an additional
|
||||
" argument can be used for that instead.
|
||||
if a:0 > 1
|
||||
throw 'Too many arguments'
|
||||
endif
|
||||
|
||||
" Set up a marker so ALE doesn't create real random temporary filenames.
|
||||
let g:ale_create_dummy_temporary_file = 1
|
||||
|
||||
let l:function_name = ale#fix#registry#GetFunc(a:name)
|
||||
let s:FixerFunction = function(l:function_name)
|
||||
|
||||
let l:prefix = 'ale_' . a:filetype . '_' . a:name
|
||||
let l:option_suffix = get(a:000, 0, a:name)
|
||||
let l:prefix = 'ale_' . a:filetype . '_'
|
||||
\ . substitute(l:option_suffix, '-', '_', 'g')
|
||||
let b:filter_expr = 'v:val[: len(l:prefix) - 1] is# l:prefix'
|
||||
|
||||
for l:key in filter(keys(g:), b:filter_expr)
|
||||
@@ -286,7 +294,7 @@ function! ale#assert#SetUpFixerTest(filetype, name) abort
|
||||
unlet b:[l:key]
|
||||
endfor
|
||||
|
||||
execute 'runtime autoload/ale/fixers/' . a:name . '.vim'
|
||||
execute 'runtime autoload/ale/fixers/' . substitute(a:name, '-', '_', 'g') . '.vim'
|
||||
|
||||
if !exists('g:dir')
|
||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||
|
||||
@@ -28,76 +28,107 @@ function! ale#c#GetBuildDirectory(buffer) abort
|
||||
return ale#path#Dirname(l:json_file)
|
||||
endfunction
|
||||
|
||||
function! ale#c#AreSpecialCharsBalanced(option) abort
|
||||
" Escape \"
|
||||
let l:option_escaped = substitute(a:option, '\\"', '', 'g')
|
||||
|
||||
" Retain special chars only
|
||||
let l:special_chars = substitute(l:option_escaped, '[^"''()`]', '', 'g')
|
||||
let l:special_chars = split(l:special_chars, '\zs')
|
||||
|
||||
" Check if they are balanced
|
||||
function! ale#c#ShellSplit(line) abort
|
||||
let l:stack = []
|
||||
let l:args = ['']
|
||||
let l:prev = ''
|
||||
|
||||
for l:char in l:special_chars
|
||||
if l:char is# ')'
|
||||
if len(l:stack) == 0 || get(l:stack, -1) isnot# '('
|
||||
return 0
|
||||
endif
|
||||
|
||||
for l:char in split(a:line, '\zs')
|
||||
if l:char is# ''''
|
||||
if len(l:stack) > 0 && get(l:stack, -1) is# ''''
|
||||
call remove(l:stack, -1)
|
||||
elseif l:char is# '('
|
||||
elseif (len(l:stack) == 0 || get(l:stack, -1) isnot# '"') && l:prev isnot# '\'
|
||||
call add(l:stack, l:char)
|
||||
else
|
||||
endif
|
||||
elseif (l:char is# '"' || l:char is# '`') && l:prev isnot# '\'
|
||||
if len(l:stack) > 0 && get(l:stack, -1) is# l:char
|
||||
call remove(l:stack, -1)
|
||||
else
|
||||
elseif len(l:stack) == 0 || get(l:stack, -1) isnot# ''''
|
||||
call add(l:stack, l:char)
|
||||
endif
|
||||
elseif (l:char is# '(' || l:char is# '[' || l:char is# '{') && l:prev isnot# '\'
|
||||
if len(l:stack) == 0 || get(l:stack, -1) isnot# ''''
|
||||
call add(l:stack, l:char)
|
||||
endif
|
||||
elseif (l:char is# ')' || l:char is# ']' || l:char is# '}') && l:prev isnot# '\'
|
||||
if len(l:stack) > 0 && get(l:stack, -1) is# {')': '(', ']': '[', '}': '{'}[l:char]
|
||||
call remove(l:stack, -1)
|
||||
endif
|
||||
elseif l:char is# ' ' && len(l:stack) == 0
|
||||
if len(get(l:args, -1)) > 0
|
||||
call add(l:args, '')
|
||||
endif
|
||||
|
||||
continue
|
||||
endif
|
||||
|
||||
let l:args[-1] = get(l:args, -1) . l:char
|
||||
endfor
|
||||
|
||||
return len(l:stack) == 0
|
||||
return l:args
|
||||
endfunction
|
||||
|
||||
function! ale#c#ParseCFlags(path_prefix, cflag_line) abort
|
||||
let l:split_lines = split(a:cflag_line)
|
||||
let l:cflags_list = []
|
||||
|
||||
let l:split_lines = ale#c#ShellSplit(a:cflag_line)
|
||||
let l:option_index = 0
|
||||
|
||||
while l:option_index < len(l:split_lines)
|
||||
let l:next_option_index = l:option_index + 1
|
||||
|
||||
" Join space-separated option
|
||||
while l:next_option_index < len(l:split_lines)
|
||||
\&& stridx(l:split_lines[l:next_option_index], '-') != 0
|
||||
let l:next_option_index += 1
|
||||
endwhile
|
||||
|
||||
let l:option = join(l:split_lines[l:option_index : l:next_option_index-1], ' ')
|
||||
call remove(l:split_lines, l:option_index, l:next_option_index-1)
|
||||
call insert(l:split_lines, l:option, l:option_index)
|
||||
|
||||
" Ignore invalid or conflicting options
|
||||
if stridx(l:option, '-') != 0
|
||||
\|| stridx(l:option, '-o') == 0
|
||||
\|| stridx(l:option, '-c') == 0
|
||||
call remove(l:split_lines, l:option_index)
|
||||
let l:option_index = l:option_index - 1
|
||||
" Fix relative path
|
||||
elseif stridx(l:option, '-I') == 0
|
||||
if !(stridx(l:option, ':') == 2+1 || stridx(l:option, '/') == 2+0)
|
||||
let l:option = '-I' . a:path_prefix . s:sep . l:option[2:]
|
||||
call remove(l:split_lines, l:option_index)
|
||||
call insert(l:split_lines, l:option, l:option_index)
|
||||
endif
|
||||
endif
|
||||
|
||||
let l:option = l:split_lines[l:option_index]
|
||||
let l:option_index = l:option_index + 1
|
||||
|
||||
" Include options, that may need relative path fix
|
||||
if stridx(l:option, '-I') == 0
|
||||
\ || stridx(l:option, '-iquote') == 0
|
||||
\ || stridx(l:option, '-isystem') == 0
|
||||
\ || stridx(l:option, '-idirafter') == 0
|
||||
if stridx(l:option, '-I') == 0 && l:option isnot# '-I'
|
||||
let l:arg = join(split(l:option, '\zs')[2:], '')
|
||||
let l:option = '-I'
|
||||
else
|
||||
let l:arg = l:split_lines[l:option_index]
|
||||
let l:option_index = l:option_index + 1
|
||||
endif
|
||||
|
||||
" Fix relative paths if needed
|
||||
if stridx(l:arg, s:sep) != 0 && stridx(l:arg, '/') != 0
|
||||
let l:rel_path = substitute(l:arg, '"', '', 'g')
|
||||
let l:rel_path = substitute(l:rel_path, '''', '', 'g')
|
||||
let l:arg = ale#Escape(a:path_prefix . s:sep . l:rel_path)
|
||||
endif
|
||||
|
||||
call add(l:cflags_list, l:option)
|
||||
call add(l:cflags_list, l:arg)
|
||||
" Options with arg that can be grouped with the option or separate
|
||||
elseif stridx(l:option, '-D') == 0 || stridx(l:option, '-B') == 0
|
||||
call add(l:cflags_list, l:option)
|
||||
|
||||
if l:option is# '-D' || l:option is# '-B'
|
||||
call add(l:cflags_list, l:split_lines[l:option_index])
|
||||
let l:option_index = l:option_index + 1
|
||||
endif
|
||||
" Options that have an argument (always separate)
|
||||
elseif l:option is# '-iprefix' || stridx(l:option, '-iwithprefix') == 0
|
||||
\ || l:option is# '-isysroot' || l:option is# '-imultilib'
|
||||
call add(l:cflags_list, l:option)
|
||||
call add(l:cflags_list, l:split_lines[l:option_index])
|
||||
let l:option_index = l:option_index + 1
|
||||
" Options without argument
|
||||
elseif (stridx(l:option, '-W') == 0 && stridx(l:option, '-Wa,') != 0 && stridx(l:option, '-Wl,') != 0 && stridx(l:option, '-Wp,') != 0)
|
||||
\ || l:option is# '-w' || stridx(l:option, '-pedantic') == 0
|
||||
\ || l:option is# '-ansi' || stridx(l:option, '-std=') == 0
|
||||
\ || (stridx(l:option, '-f') == 0 && stridx(l:option, '-fdump') != 0 && stridx(l:option, '-fdiagnostics') != 0 && stridx(l:option, '-fno-show-column') != 0)
|
||||
\ || stridx(l:option, '-O') == 0
|
||||
\ || l:option is# '-C' || l:option is# '-CC' || l:option is# '-trigraphs'
|
||||
\ || stridx(l:option, '-nostdinc') == 0 || stridx(l:option, '-iplugindir=') == 0
|
||||
\ || stridx(l:option, '--sysroot=') == 0 || l:option is# '--no-sysroot-suffix'
|
||||
\ || stridx(l:option, '-m') == 0
|
||||
call add(l:cflags_list, l:option)
|
||||
endif
|
||||
endwhile
|
||||
|
||||
call uniq(l:split_lines)
|
||||
|
||||
return join(l:split_lines, ' ')
|
||||
return join(l:cflags_list, ' ')
|
||||
endfunction
|
||||
|
||||
function! ale#c#ParseCFlagsFromMakeOutput(buffer, make_output) abort
|
||||
@@ -234,6 +265,16 @@ function! s:GetLookupFromCompileCommandsFile(compile_commands_file) abort
|
||||
return l:empty
|
||||
endfunction
|
||||
|
||||
function! ale#c#GetCompileCommand(json_item) abort
|
||||
if has_key(a:json_item, 'command')
|
||||
return a:json_item.command
|
||||
elseif has_key(a:json_item, 'arguments')
|
||||
return join(a:json_item.arguments, ' ')
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! ale#c#ParseCompileCommandsFlags(buffer, file_lookup, dir_lookup) abort
|
||||
" Search for an exact file match first.
|
||||
let l:basename = tolower(expand('#' . a:buffer . ':t'))
|
||||
@@ -256,15 +297,14 @@ function! ale#c#ParseCompileCommandsFlags(buffer, file_lookup, dir_lookup) abort
|
||||
for l:item in l:file_list
|
||||
" Load the flags for this file, or for a source file matching the
|
||||
" header file.
|
||||
if has_key(l:item, 'command')
|
||||
\&& (
|
||||
if (
|
||||
\ bufnr(l:item.file) is a:buffer
|
||||
\ || (
|
||||
\ !empty(l:source_file)
|
||||
\ && l:item.file[-len(l:source_file):] is? l:source_file
|
||||
\ )
|
||||
\)
|
||||
return ale#c#ParseCFlags(l:item.directory, l:item.command)
|
||||
return ale#c#ParseCFlags(l:item.directory, ale#c#GetCompileCommand(l:item))
|
||||
endif
|
||||
endfor
|
||||
|
||||
@@ -276,8 +316,7 @@ function! ale#c#ParseCompileCommandsFlags(buffer, file_lookup, dir_lookup) abort
|
||||
|
||||
for l:item in l:dir_list
|
||||
if ale#path#Simplify(fnamemodify(l:item.file, ':h')) is? l:dir
|
||||
\&& has_key(l:item, 'command')
|
||||
return ale#c#ParseCFlags(l:item.directory, l:item.command)
|
||||
return ale#c#ParseCFlags(l:item.directory, ale#c#GetCompileCommand(l:item))
|
||||
endif
|
||||
endfor
|
||||
|
||||
|
||||
173
autoload/ale/code_action.vim
Normal file
173
autoload/ale/code_action.vim
Normal file
@@ -0,0 +1,173 @@
|
||||
" Author: Jerko Steiner <jerko.steiner@gmail.com>
|
||||
" Description: Code action support for LSP / tsserver
|
||||
|
||||
function! ale#code_action#HandleCodeAction(code_action, should_save) abort
|
||||
let l:current_buffer = bufnr('')
|
||||
let l:changes = a:code_action.changes
|
||||
|
||||
for l:file_code_edit in l:changes
|
||||
let l:buf = bufnr(l:file_code_edit.fileName)
|
||||
|
||||
if l:buf != -1 && l:buf != l:current_buffer && getbufvar(l:buf, '&mod')
|
||||
call ale#util#Execute('echom ''Aborting action, file is unsaved''')
|
||||
|
||||
return
|
||||
endif
|
||||
endfor
|
||||
|
||||
for l:file_code_edit in l:changes
|
||||
call ale#code_action#ApplyChanges(
|
||||
\ l:file_code_edit.fileName,
|
||||
\ l:file_code_edit.textChanges,
|
||||
\ a:should_save,
|
||||
\ )
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! ale#code_action#ApplyChanges(filename, changes, should_save) abort
|
||||
let l:current_buffer = bufnr('')
|
||||
" The buffer is used to determine the fileformat, if available.
|
||||
let l:buffer = bufnr(a:filename)
|
||||
let l:is_current_buffer = l:buffer > 0 && l:buffer == l:current_buffer
|
||||
|
||||
if l:buffer > 0
|
||||
let l:lines = getbufline(l:buffer, 1, '$')
|
||||
else
|
||||
let l:lines = readfile(a:filename, 'b')
|
||||
endif
|
||||
|
||||
if l:is_current_buffer
|
||||
let l:pos = getpos('.')[1:2]
|
||||
else
|
||||
let l:pos = [1, 1]
|
||||
endif
|
||||
|
||||
" We have to keep track of how many lines we have added, and offset
|
||||
" changes accordingly.
|
||||
let l:line_offset = 0
|
||||
let l:column_offset = 0
|
||||
let l:last_end_line = 0
|
||||
|
||||
for l:code_edit in a:changes
|
||||
if l:code_edit.start.line isnot l:last_end_line
|
||||
let l:column_offset = 0
|
||||
endif
|
||||
|
||||
let l:line = l:code_edit.start.line + l:line_offset
|
||||
let l:column = l:code_edit.start.offset + l:column_offset
|
||||
let l:end_line = l:code_edit.end.line + l:line_offset
|
||||
let l:end_column = l:code_edit.end.offset + l:column_offset
|
||||
let l:text = l:code_edit.newText
|
||||
|
||||
let l:cur_line = l:pos[0]
|
||||
let l:cur_column = l:pos[1]
|
||||
|
||||
let l:last_end_line = l:end_line
|
||||
|
||||
" Adjust the ends according to previous edits.
|
||||
if l:end_line > len(l:lines)
|
||||
let l:end_line_len = 0
|
||||
else
|
||||
let l:end_line_len = len(l:lines[l:end_line - 1])
|
||||
endif
|
||||
|
||||
let l:insertions = split(l:text, '\n', 1)
|
||||
|
||||
if l:line is 1
|
||||
" Same logic as for column below. Vimscript's slice [:-1] will not
|
||||
" be an empty list.
|
||||
let l:start = []
|
||||
else
|
||||
let l:start = l:lines[: l:line - 2]
|
||||
endif
|
||||
|
||||
if l:column is 1
|
||||
" We need to handle column 1 specially, because we can't slice an
|
||||
" empty string ending on index 0.
|
||||
let l:middle = [l:insertions[0]]
|
||||
else
|
||||
let l:middle = [l:lines[l:line - 1][: l:column - 2] . l:insertions[0]]
|
||||
endif
|
||||
|
||||
call extend(l:middle, l:insertions[1:])
|
||||
let l:middle[-1] .= l:lines[l:end_line - 1][l:end_column - 1 :]
|
||||
|
||||
let l:lines_before_change = len(l:lines)
|
||||
let l:lines = l:start + l:middle + l:lines[l:end_line :]
|
||||
|
||||
let l:current_line_offset = len(l:lines) - l:lines_before_change
|
||||
let l:line_offset += l:current_line_offset
|
||||
let l:column_offset = len(l:middle[-1]) - l:end_line_len
|
||||
|
||||
let l:pos = s:UpdateCursor(l:pos,
|
||||
\ [l:line, l:column],
|
||||
\ [l:end_line, l:end_column],
|
||||
\ [l:current_line_offset, l:column_offset])
|
||||
endfor
|
||||
|
||||
if l:lines[-1] is# ''
|
||||
call remove(l:lines, -1)
|
||||
endif
|
||||
|
||||
if a:should_save
|
||||
call ale#util#Writefile(l:buffer, l:lines, a:filename)
|
||||
else
|
||||
call ale#util#SetBufferContents(l:buffer, l:lines)
|
||||
endif
|
||||
|
||||
if l:is_current_buffer
|
||||
if a:should_save
|
||||
call ale#util#Execute(':e!')
|
||||
endif
|
||||
|
||||
call setpos('.', [0, l:pos[0], l:pos[1], 0])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:UpdateCursor(cursor, start, end, offset) abort
|
||||
let l:cur_line = a:cursor[0]
|
||||
let l:cur_column = a:cursor[1]
|
||||
let l:line = a:start[0]
|
||||
let l:column = a:start[1]
|
||||
let l:end_line = a:end[0]
|
||||
let l:end_column = a:end[1]
|
||||
let l:line_offset = a:offset[0]
|
||||
let l:column_offset = a:offset[1]
|
||||
|
||||
if l:end_line < l:cur_line
|
||||
" both start and end lines are before the cursor. only line offset
|
||||
" needs to be updated
|
||||
let l:cur_line += l:line_offset
|
||||
elseif l:end_line == l:cur_line
|
||||
" end line is at the same location as cursor, which means
|
||||
" l:line <= l:cur_line
|
||||
if l:line < l:cur_line || l:column <= l:cur_column
|
||||
" updates are happening either before or around the cursor
|
||||
if l:end_column < l:cur_column
|
||||
" updates are happening before the cursor, update the
|
||||
" column offset for cursor
|
||||
let l:cur_line += l:line_offset
|
||||
let l:cur_column += l:column_offset
|
||||
else
|
||||
" updates are happening around the cursor, move the cursor
|
||||
" to the end of the changes
|
||||
let l:cur_line += l:line_offset
|
||||
let l:cur_column = l:end_column + l:column_offset
|
||||
endif
|
||||
" else is not necessary, it means modifications are happening
|
||||
" after the cursor so no cursor updates need to be done
|
||||
endif
|
||||
else
|
||||
" end line is after the cursor
|
||||
if l:line < l:cur_line || l:line == l:cur_line && l:column <= l:cur_column
|
||||
" changes are happening around the cursor, move the cursor
|
||||
" to the end of the changes
|
||||
let l:cur_line = l:end_line + l:line_offset
|
||||
let l:cur_column = l:end_column + l:column_offset
|
||||
" else is not necesary, it means modifications are happening
|
||||
" after the cursor so no cursor updates need to be done
|
||||
endif
|
||||
endif
|
||||
|
||||
return [l:cur_line, l:cur_column]
|
||||
endfunction
|
||||
@@ -1,5 +1,6 @@
|
||||
" Author: w0rp <devw0rp@gmail.com>
|
||||
" Description: Completion support for LSP linters
|
||||
scriptencoding utf-8
|
||||
|
||||
" The omnicompletion menu is shown through a special Plug mapping which is
|
||||
" only valid in Insert mode. This way, feedkeys() won't send these keys if you
|
||||
@@ -15,29 +16,107 @@ onoremap <silent> <Plug>(ale_show_completion_menu) <Nop>
|
||||
let g:ale_completion_delay = get(g:, 'ale_completion_delay', 100)
|
||||
let g:ale_completion_excluded_words = get(g:, 'ale_completion_excluded_words', [])
|
||||
let g:ale_completion_max_suggestions = get(g:, 'ale_completion_max_suggestions', 50)
|
||||
let g:ale_completion_tsserver_autoimport = get(g:, 'ale_completion_tsserver_autoimport', 0)
|
||||
|
||||
let s:timer_id = -1
|
||||
let s:last_done_pos = []
|
||||
|
||||
" CompletionItemKind values from the LSP protocol.
|
||||
let s:LSP_COMPLETION_TEXT_KIND = 1
|
||||
let s:LSP_COMPLETION_METHOD_KIND = 2
|
||||
let s:LSP_COMPLETION_FUNCTION_KIND = 3
|
||||
let s:LSP_COMPLETION_CONSTRUCTOR_KIND = 4
|
||||
let s:LSP_COMPLETION_FIELD_KIND = 5
|
||||
let s:LSP_COMPLETION_VARIABLE_KIND = 6
|
||||
let s:LSP_COMPLETION_CLASS_KIND = 7
|
||||
let s:LSP_COMPLETION_INTERFACE_KIND = 8
|
||||
let s:LSP_COMPLETION_MODULE_KIND = 9
|
||||
let s:LSP_COMPLETION_PROPERTY_KIND = 10
|
||||
let s:LSP_COMPLETION_UNIT_KIND = 11
|
||||
let s:LSP_COMPLETION_VALUE_KIND = 12
|
||||
let s:LSP_COMPLETION_ENUM_KIND = 13
|
||||
let s:LSP_COMPLETION_KEYWORD_KIND = 14
|
||||
let s:LSP_COMPLETION_SNIPPET_KIND = 15
|
||||
let s:LSP_COMPLETION_COLOR_KIND = 16
|
||||
let s:LSP_COMPLETION_FILE_KIND = 17
|
||||
let s:LSP_COMPLETION_REFERENCE_KIND = 18
|
||||
let g:ale_lsp_types = {
|
||||
\ 1: 'text',
|
||||
\ 2: 'method',
|
||||
\ 3: 'function',
|
||||
\ 4: 'constructor',
|
||||
\ 5: 'field',
|
||||
\ 6: 'variable',
|
||||
\ 7: 'class',
|
||||
\ 8: 'interface',
|
||||
\ 9: 'module',
|
||||
\ 10: 'property',
|
||||
\ 11: 'unit',
|
||||
\ 12: 'value',
|
||||
\ 13: 'enum',
|
||||
\ 14: 'keyword',
|
||||
\ 15: 'snippet',
|
||||
\ 16: 'color',
|
||||
\ 17: 'file',
|
||||
\ 18: 'reference',
|
||||
\ 19: 'folder',
|
||||
\ 20: 'enum_member',
|
||||
\ 21: 'constant',
|
||||
\ 22: 'struct',
|
||||
\ 23: 'event',
|
||||
\ 24: 'operator',
|
||||
\ 25: 'type_parameter',
|
||||
\ }
|
||||
|
||||
" from https://github.com/microsoft/TypeScript/blob/29becf05012bfa7ba20d50b0d16813971e46b8a6/lib/protocol.d.ts#L2472
|
||||
let g:ale_tsserver_types = {
|
||||
\ 'warning': 'text',
|
||||
\ 'keyword': 'keyword',
|
||||
\ 'script': 'file',
|
||||
\ 'module': 'module',
|
||||
\ 'class': 'class',
|
||||
\ 'local class': 'class',
|
||||
\ 'interface': 'interface',
|
||||
\ 'type': 'class',
|
||||
\ 'enum': 'enum',
|
||||
\ 'enum member': 'enum_member',
|
||||
\ 'var': 'variable',
|
||||
\ 'local var': 'variable',
|
||||
\ 'function': 'function',
|
||||
\ 'local function': 'function',
|
||||
\ 'method': 'method',
|
||||
\ 'getter': 'property',
|
||||
\ 'setter': 'method',
|
||||
\ 'property': 'property',
|
||||
\ 'constructor': 'constructor',
|
||||
\ 'call': 'method',
|
||||
\ 'index': 'index',
|
||||
\ 'construct': 'constructor',
|
||||
\ 'parameter': 'parameter',
|
||||
\ 'type parameter': 'type_parameter',
|
||||
\ 'primitive type': 'unit',
|
||||
\ 'label': 'text',
|
||||
\ 'alias': 'class',
|
||||
\ 'const': 'constant',
|
||||
\ 'let': 'variable',
|
||||
\ 'directory': 'folder',
|
||||
\ 'external module name': 'text',
|
||||
\ 'JSX attribute': 'parameter',
|
||||
\ 'string': 'text'
|
||||
\ }
|
||||
|
||||
" For compatibility reasons, we only use built in VIM completion kinds
|
||||
" See :help complete-items for Vim completion kinds
|
||||
let g:ale_completion_symbols = get(g:, 'ale_completion_symbols', {
|
||||
\ 'text': 'v',
|
||||
\ 'method': 'f',
|
||||
\ 'function': 'f',
|
||||
\ 'constructor': 'f',
|
||||
\ 'field': 'm',
|
||||
\ 'variable': 'v',
|
||||
\ 'class': 't',
|
||||
\ 'interface': 't',
|
||||
\ 'module': 'd',
|
||||
\ 'property': 'm',
|
||||
\ 'unit': 'v',
|
||||
\ 'value': 'v',
|
||||
\ 'enum': 't',
|
||||
\ 'keyword': 'v',
|
||||
\ 'snippet': 'v',
|
||||
\ 'color': 'v',
|
||||
\ 'file': 'v',
|
||||
\ 'reference': 'v',
|
||||
\ 'folder': 'v',
|
||||
\ 'enum_member': 'm',
|
||||
\ 'constant': 'm',
|
||||
\ 'struct': 't',
|
||||
\ 'event': 'v',
|
||||
\ 'operator': 'f',
|
||||
\ 'type_parameter': 'p',
|
||||
\ '<default>': 'v'
|
||||
\ })
|
||||
|
||||
let s:LSP_INSERT_TEXT_FORMAT_PLAIN = 1
|
||||
let s:LSP_INSERT_TEXT_FORMAT_SNIPPET = 2
|
||||
@@ -52,6 +131,7 @@ let s:should_complete_map = {
|
||||
\ 'lisp': s:lisp_regex,
|
||||
\ 'typescript': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|''$|"$',
|
||||
\ 'rust': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|::$',
|
||||
\ 'cpp': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|::$|-\>$',
|
||||
\}
|
||||
|
||||
" Regular expressions for finding the start column to replace with completion.
|
||||
@@ -59,11 +139,13 @@ let s:omni_start_map = {
|
||||
\ '<default>': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$',
|
||||
\}
|
||||
|
||||
" A map of exact characters for triggering LSP completions.
|
||||
" A map of exact characters for triggering LSP completions. Do not forget to
|
||||
" update self.input_patterns in ale.py in updating entries in this map.
|
||||
let s:trigger_character_map = {
|
||||
\ '<default>': ['.'],
|
||||
\ 'typescript': ['.', '''', '"'],
|
||||
\ 'rust': ['.', '::'],
|
||||
\ 'cpp': ['.', '::', '->'],
|
||||
\}
|
||||
|
||||
function! s:GetFiletypeValue(map, filetype) abort
|
||||
@@ -179,6 +261,8 @@ function! s:ReplaceCompletionOptions() abort
|
||||
|
||||
if &l:completeopt =~# 'preview'
|
||||
let &l:completeopt = 'menu,menuone,preview,noselect,noinsert'
|
||||
elseif &l:completeopt =~# 'popup'
|
||||
let &l:completeopt = 'menu,menuone,popup,noselect,noinsert'
|
||||
else
|
||||
let &l:completeopt = 'menu,menuone,noselect,noinsert'
|
||||
endif
|
||||
@@ -215,6 +299,10 @@ function! ale#completion#GetCompletionPosition() abort
|
||||
return l:column - len(l:match) - 1
|
||||
endfunction
|
||||
|
||||
function! ale#completion#GetCompletionPositionForDeoplete(input) abort
|
||||
return match(a:input, '\k*$')
|
||||
endfunction
|
||||
|
||||
function! ale#completion#GetCompletionResult() abort
|
||||
if exists('b:ale_completion_result')
|
||||
return b:ale_completion_result
|
||||
@@ -260,6 +348,35 @@ function! ale#completion#Show(result) abort
|
||||
\ {-> ale#util#FeedKeys("\<Plug>(ale_show_completion_menu)")}
|
||||
\)
|
||||
endif
|
||||
|
||||
if l:source is# 'ale-callback'
|
||||
call b:CompleteCallback(b:ale_completion_result)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! ale#completion#GetAllTriggers() abort
|
||||
return deepcopy(s:trigger_character_map)
|
||||
endfunction
|
||||
|
||||
function! ale#completion#GetCompletionKind(kind) abort
|
||||
let l:lsp_symbol = get(g:ale_lsp_types, a:kind, '')
|
||||
|
||||
if !empty(l:lsp_symbol)
|
||||
return l:lsp_symbol
|
||||
endif
|
||||
|
||||
return get(g:ale_tsserver_types, a:kind, '')
|
||||
endfunction
|
||||
|
||||
function! ale#completion#GetCompletionSymbols(kind) abort
|
||||
let l:kind = ale#completion#GetCompletionKind(a:kind)
|
||||
let l:symbol = get(g:ale_completion_symbols, l:kind, '')
|
||||
|
||||
if !empty(l:symbol)
|
||||
return l:symbol
|
||||
endif
|
||||
|
||||
return get(g:ale_completion_symbols, '<default>', 'v')
|
||||
endfunction
|
||||
|
||||
function! s:CompletionStillValid(request_id) abort
|
||||
@@ -271,8 +388,8 @@ function! s:CompletionStillValid(request_id) abort
|
||||
\&& b:ale_completion_info.line == l:line
|
||||
\&& (
|
||||
\ b:ale_completion_info.column == l:column
|
||||
\ || b:ale_completion_info.source is# 'deoplete'
|
||||
\ || b:ale_completion_info.source is# 'ale-omnifunc'
|
||||
\ || b:ale_completion_info.source is# 'ale-callback'
|
||||
\)
|
||||
endfunction
|
||||
|
||||
@@ -280,7 +397,10 @@ function! ale#completion#ParseTSServerCompletions(response) abort
|
||||
let l:names = []
|
||||
|
||||
for l:suggestion in a:response.body
|
||||
call add(l:names, l:suggestion.name)
|
||||
call add(l:names, {
|
||||
\ 'word': l:suggestion.name,
|
||||
\ 'source': get(l:suggestion, 'source', ''),
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:names
|
||||
@@ -294,6 +414,10 @@ function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort
|
||||
for l:suggestion in a:response.body
|
||||
let l:displayParts = []
|
||||
|
||||
for l:action in get(l:suggestion, 'codeActions', [])
|
||||
call add(l:displayParts, l:action.description . ' ')
|
||||
endfor
|
||||
|
||||
for l:part in l:suggestion.displayParts
|
||||
call add(l:displayParts, l:part.text)
|
||||
endfor
|
||||
@@ -305,22 +429,23 @@ function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort
|
||||
call add(l:documentationParts, l:part.text)
|
||||
endfor
|
||||
|
||||
if l:suggestion.kind is# 'className'
|
||||
let l:kind = 'f'
|
||||
elseif l:suggestion.kind is# 'parameterName'
|
||||
let l:kind = 'f'
|
||||
else
|
||||
let l:kind = 'v'
|
||||
endif
|
||||
|
||||
" See :help complete-items
|
||||
call add(l:results, {
|
||||
let l:result = {
|
||||
\ 'word': l:suggestion.name,
|
||||
\ 'kind': l:kind,
|
||||
\ 'kind': ale#completion#GetCompletionSymbols(l:suggestion.kind),
|
||||
\ 'icase': 1,
|
||||
\ 'menu': join(l:displayParts, ''),
|
||||
\ 'dup': g:ale_completion_tsserver_autoimport,
|
||||
\ 'info': join(l:documentationParts, ''),
|
||||
\})
|
||||
\}
|
||||
|
||||
if has_key(l:suggestion, 'codeActions')
|
||||
let l:result.user_data = json_encode({
|
||||
\ 'codeActions': l:suggestion.codeActions,
|
||||
\ })
|
||||
endif
|
||||
|
||||
call add(l:results, l:result)
|
||||
endfor
|
||||
|
||||
let l:names = getbufvar(l:buffer, 'ale_tsserver_completion_names', [])
|
||||
@@ -329,12 +454,12 @@ function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort
|
||||
let l:names_with_details = map(copy(l:results), 'v:val.word')
|
||||
let l:missing_names = filter(
|
||||
\ copy(l:names),
|
||||
\ 'index(l:names_with_details, v:val) < 0',
|
||||
\ 'index(l:names_with_details, v:val.word) < 0',
|
||||
\)
|
||||
|
||||
for l:name in l:missing_names
|
||||
call add(l:results, {
|
||||
\ 'word': l:name,
|
||||
\ 'word': l:name.word,
|
||||
\ 'kind': 'v',
|
||||
\ 'icase': 1,
|
||||
\ 'menu': '',
|
||||
@@ -392,23 +517,6 @@ function! ale#completion#ParseLSPCompletions(response) abort
|
||||
continue
|
||||
endif
|
||||
|
||||
" See :help complete-items for Vim completion kinds
|
||||
if !has_key(l:item, 'kind')
|
||||
let l:kind = 'v'
|
||||
elseif l:item.kind is s:LSP_COMPLETION_METHOD_KIND
|
||||
let l:kind = 'm'
|
||||
elseif l:item.kind is s:LSP_COMPLETION_CONSTRUCTOR_KIND
|
||||
let l:kind = 'm'
|
||||
elseif l:item.kind is s:LSP_COMPLETION_FUNCTION_KIND
|
||||
let l:kind = 'f'
|
||||
elseif l:item.kind is s:LSP_COMPLETION_CLASS_KIND
|
||||
let l:kind = 'f'
|
||||
elseif l:item.kind is s:LSP_COMPLETION_INTERFACE_KIND
|
||||
let l:kind = 'f'
|
||||
else
|
||||
let l:kind = 'v'
|
||||
endif
|
||||
|
||||
let l:doc = get(l:item, 'documentation', '')
|
||||
|
||||
if type(l:doc) is v:t_dict && has_key(l:doc, 'value')
|
||||
@@ -417,7 +525,7 @@ function! ale#completion#ParseLSPCompletions(response) abort
|
||||
|
||||
call add(l:results, {
|
||||
\ 'word': l:word,
|
||||
\ 'kind': l:kind,
|
||||
\ 'kind': ale#completion#GetCompletionSymbols(get(l:item, 'kind', '')),
|
||||
\ 'icase': 1,
|
||||
\ 'menu': get(l:item, 'detail', ''),
|
||||
\ 'info': (type(l:doc) is v:t_string ? l:doc : ''),
|
||||
@@ -456,13 +564,29 @@ function! ale#completion#HandleTSServerResponse(conn_id, response) abort
|
||||
call setbufvar(l:buffer, 'ale_tsserver_completion_names', l:names)
|
||||
|
||||
if !empty(l:names)
|
||||
let l:identifiers = []
|
||||
|
||||
for l:name in l:names
|
||||
let l:identifier = {
|
||||
\ 'name': l:name.word,
|
||||
\}
|
||||
let l:source = get(l:name, 'source', '')
|
||||
|
||||
" Empty source results in no details for the completed item
|
||||
if !empty(l:source)
|
||||
call extend(l:identifier, { 'source': l:source })
|
||||
endif
|
||||
|
||||
call add(l:identifiers, l:identifier)
|
||||
endfor
|
||||
|
||||
let b:ale_completion_info.request_id = ale#lsp#Send(
|
||||
\ b:ale_completion_info.conn_id,
|
||||
\ ale#lsp#tsserver_message#CompletionEntryDetails(
|
||||
\ l:buffer,
|
||||
\ b:ale_completion_info.line,
|
||||
\ b:ale_completion_info.column,
|
||||
\ l:names,
|
||||
\ l:identifiers,
|
||||
\ ),
|
||||
\)
|
||||
endif
|
||||
@@ -509,6 +633,7 @@ function! s:OnReady(linter, lsp_details) abort
|
||||
\ b:ale_completion_info.line,
|
||||
\ b:ale_completion_info.column,
|
||||
\ b:ale_completion_info.prefix,
|
||||
\ g:ale_completion_tsserver_autoimport,
|
||||
\)
|
||||
else
|
||||
" Send a message saying the buffer has changed first, otherwise
|
||||
@@ -553,12 +678,25 @@ endfunction
|
||||
|
||||
" This function can be used to manually trigger autocomplete, even when
|
||||
" g:ale_completion_enabled is set to false
|
||||
function! ale#completion#GetCompletions(source) abort
|
||||
function! ale#completion#GetCompletions(...) abort
|
||||
let l:source = get(a:000, 0, '')
|
||||
let l:options = get(a:000, 1, {})
|
||||
|
||||
if len(a:000) > 2
|
||||
throw 'Too many arguments!'
|
||||
endif
|
||||
|
||||
let l:CompleteCallback = get(l:options, 'callback', v:null)
|
||||
|
||||
if l:CompleteCallback isnot v:null
|
||||
let b:CompleteCallback = l:CompleteCallback
|
||||
endif
|
||||
|
||||
let [l:line, l:column] = getpos('.')[1:2]
|
||||
|
||||
let l:prefix = ale#completion#GetPrefix(&filetype, l:line, l:column)
|
||||
|
||||
if a:source is# 'ale-automatic' && empty(l:prefix)
|
||||
if l:source is# 'ale-automatic' && empty(l:prefix)
|
||||
return 0
|
||||
endif
|
||||
|
||||
@@ -571,7 +709,7 @@ function! ale#completion#GetCompletions(source) abort
|
||||
\ 'prefix': l:prefix,
|
||||
\ 'conn_id': 0,
|
||||
\ 'request_id': 0,
|
||||
\ 'source': a:source,
|
||||
\ 'source': l:source,
|
||||
\}
|
||||
unlet! b:ale_completion_result
|
||||
|
||||
@@ -663,6 +801,32 @@ function! ale#completion#Queue() abort
|
||||
let s:timer_id = timer_start(g:ale_completion_delay, function('s:TimerHandler'))
|
||||
endfunction
|
||||
|
||||
function! ale#completion#HandleUserData(completed_item) abort
|
||||
let l:source = get(get(b:, 'ale_completion_info', {}), 'source', '')
|
||||
|
||||
if l:source isnot# 'ale-automatic'
|
||||
\&& l:source isnot# 'ale-manual'
|
||||
\&& l:source isnot# 'ale-callback'
|
||||
return
|
||||
endif
|
||||
|
||||
let l:user_data_json = get(a:completed_item, 'user_data', '')
|
||||
|
||||
if empty(l:user_data_json)
|
||||
return
|
||||
endif
|
||||
|
||||
let l:user_data = json_decode(l:user_data_json)
|
||||
|
||||
if type(l:user_data) isnot v:t_dict
|
||||
return
|
||||
endif
|
||||
|
||||
for l:code_action in get(l:user_data, 'codeActions', [])
|
||||
call ale#code_action#HandleCodeAction(l:code_action, v:false)
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! ale#completion#Done() abort
|
||||
silent! pclose
|
||||
|
||||
@@ -671,6 +835,10 @@ function! ale#completion#Done() abort
|
||||
let s:last_done_pos = getpos('.')[1:2]
|
||||
endfunction
|
||||
|
||||
augroup ALECompletionActions
|
||||
autocmd CompleteDone * call ale#completion#HandleUserData(v:completed_item)
|
||||
augroup END
|
||||
|
||||
function! s:Setup(enabled) abort
|
||||
augroup ALECompletionGroup
|
||||
autocmd!
|
||||
|
||||
@@ -50,6 +50,7 @@ let s:global_variable_list = [
|
||||
\ 'ale_sign_style_error',
|
||||
\ 'ale_sign_style_warning',
|
||||
\ 'ale_sign_warning',
|
||||
\ 'ale_sign_highlight_linenrs',
|
||||
\ 'ale_statusline_format',
|
||||
\ 'ale_type_map',
|
||||
\ 'ale_use_global_executables',
|
||||
@@ -62,7 +63,7 @@ function! s:Echo(message) abort
|
||||
execute 'echo a:message'
|
||||
endfunction
|
||||
|
||||
function! s:GetLinterVariables(filetype, linter_names) abort
|
||||
function! s:GetLinterVariables(filetype, exclude_linter_names) abort
|
||||
let l:variable_list = []
|
||||
let l:filetype_parts = split(a:filetype, '\.')
|
||||
|
||||
@@ -73,7 +74,7 @@ function! s:GetLinterVariables(filetype, linter_names) abort
|
||||
" Include matching variables.
|
||||
if !empty(l:match)
|
||||
\&& index(l:filetype_parts, l:match[1]) >= 0
|
||||
\&& index(a:linter_names, l:match[2]) >= 0
|
||||
\&& index(a:exclude_linter_names, l:match[2]) == -1
|
||||
call add(l:variable_list, l:key)
|
||||
endif
|
||||
endfor
|
||||
@@ -211,10 +212,11 @@ function! ale#debugging#Info() abort
|
||||
|
||||
let l:all_names = map(copy(l:all_linters), 'v:val[''name'']')
|
||||
let l:enabled_names = map(copy(l:enabled_linters), 'v:val[''name'']')
|
||||
let l:exclude_names = filter(copy(l:all_names), 'index(l:enabled_names, v:val) == -1')
|
||||
|
||||
" Load linter variables to display
|
||||
" This must be done after linters are loaded.
|
||||
let l:variable_list = s:GetLinterVariables(l:filetype, l:enabled_names)
|
||||
let l:variable_list = s:GetLinterVariables(l:filetype, l:exclude_names)
|
||||
|
||||
let l:fixers = ale#fix#registry#SuggestedFixers(l:filetype)
|
||||
let l:fixers = uniq(sort(l:fixers[0] + l:fixers[1]))
|
||||
|
||||
@@ -5,6 +5,7 @@ let s:go_to_definition_map = {}
|
||||
|
||||
" Enable automatic updates of the tagstack
|
||||
let g:ale_update_tagstack = get(g:, 'ale_update_tagstack', 1)
|
||||
let g:ale_default_navigation = get(g:, 'ale_default_navigation', 'buffer')
|
||||
|
||||
" Used to get the definition map in tests.
|
||||
function! ale#definition#GetMap() abort
|
||||
@@ -134,6 +135,10 @@ function! s:GoToLSPDefinition(linter, options, capability) abort
|
||||
endfunction
|
||||
|
||||
function! ale#definition#GoTo(options) abort
|
||||
if !get(g:, 'ale_ignore_2_7_warnings') && has_key(a:options, 'deprecated_command')
|
||||
execute 'echom '':' . a:options.deprecated_command . ' is deprecated. Use `let g:ale_ignore_2_7_warnings = 1` to disable this message.'''
|
||||
endif
|
||||
|
||||
for l:linter in ale#linter#Get(&filetype)
|
||||
if !empty(l:linter.lsp)
|
||||
call s:GoToLSPDefinition(l:linter, a:options, 'definition')
|
||||
@@ -142,6 +147,10 @@ function! ale#definition#GoTo(options) abort
|
||||
endfunction
|
||||
|
||||
function! ale#definition#GoToType(options) abort
|
||||
if !get(g:, 'ale_ignore_2_7_warnings') && has_key(a:options, 'deprecated_command')
|
||||
execute 'echom '':' . a:options.deprecated_command . ' is deprecated. Use `let g:ale_ignore_2_7_warnings = 1` to disable this message.'''
|
||||
endif
|
||||
|
||||
for l:linter in ale#linter#Get(&filetype)
|
||||
if !empty(l:linter.lsp)
|
||||
" TODO: handle typeDefinition for tsserver if supported by the
|
||||
@@ -154,3 +163,33 @@ function! ale#definition#GoToType(options) abort
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! ale#definition#GoToCommandHandler(command, ...) abort
|
||||
let l:options = {}
|
||||
|
||||
if len(a:000) > 0
|
||||
for l:option in a:000
|
||||
if l:option is? '-tab'
|
||||
let l:options.open_in = 'tab'
|
||||
elseif l:option is? '-split'
|
||||
let l:options.open_in = 'split'
|
||||
elseif l:option is? '-vsplit'
|
||||
let l:options.open_in = 'vsplit'
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
if !has_key(l:options, 'open_in')
|
||||
let l:default_navigation = ale#Var(bufnr(''), 'default_navigation')
|
||||
|
||||
if index(['tab', 'split', 'vsplit'], l:default_navigation) >= 0
|
||||
let l:options.open_in = l:default_navigation
|
||||
endif
|
||||
endif
|
||||
|
||||
if a:command is# 'type'
|
||||
call ale#definition#GoToType(l:options)
|
||||
else
|
||||
call ale#definition#GoTo(l:options)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@@ -4,40 +4,15 @@ call ale#Set('fix_on_save_ignore', {})
|
||||
" Vim doesn't let you modify hidden buffers.
|
||||
function! ale#fix#ApplyQueuedFixes(buffer) abort
|
||||
let l:data = get(g:ale_fix_buffer_data, a:buffer, {'done': 0})
|
||||
let l:has_bufline_api = exists('*deletebufline') && exists('*setbufline')
|
||||
|
||||
if !l:data.done || (!l:has_bufline_api && a:buffer isnot bufnr(''))
|
||||
if !l:data.done || (!ale#util#HasBuflineApi() && a:buffer isnot bufnr(''))
|
||||
return
|
||||
endif
|
||||
|
||||
call remove(g:ale_fix_buffer_data, a:buffer)
|
||||
|
||||
if l:data.changes_made
|
||||
" If the file is in DOS mode, we have to remove carriage returns from
|
||||
" the ends of lines before calling setline(), or we will see them
|
||||
" twice.
|
||||
let l:new_lines = getbufvar(a:buffer, '&fileformat') is# 'dos'
|
||||
\ ? map(copy(l:data.output), 'substitute(v:val, ''\r\+$'', '''', '''')')
|
||||
\ : l:data.output
|
||||
let l:first_line_to_remove = len(l:new_lines) + 1
|
||||
|
||||
" Use a Vim API for setting lines in other buffers, if available.
|
||||
if l:has_bufline_api
|
||||
call setbufline(a:buffer, 1, l:new_lines)
|
||||
call deletebufline(a:buffer, l:first_line_to_remove, '$')
|
||||
" Fall back on setting lines the old way, for the current buffer.
|
||||
else
|
||||
let l:old_line_length = len(l:data.lines_before)
|
||||
|
||||
if l:old_line_length >= l:first_line_to_remove
|
||||
let l:save = winsaveview()
|
||||
silent execute
|
||||
\ l:first_line_to_remove . ',' . l:old_line_length . 'd_'
|
||||
call winrestview(l:save)
|
||||
endif
|
||||
|
||||
call setline(1, l:new_lines)
|
||||
endif
|
||||
let l:new_lines = ale#util#SetBufferContents(a:buffer, l:data.output)
|
||||
|
||||
if l:data.should_save
|
||||
if a:buffer is bufnr('')
|
||||
@@ -47,7 +22,7 @@ function! ale#fix#ApplyQueuedFixes(buffer) abort
|
||||
set nomodified
|
||||
endif
|
||||
else
|
||||
call writefile(l:new_lines, expand(a:buffer . ':p')) " no-custom-checks
|
||||
call writefile(l:new_lines, expand('#' . a:buffer . ':p')) " no-custom-checks
|
||||
call setbufvar(a:buffer, '&modified', 0)
|
||||
endif
|
||||
endif
|
||||
@@ -74,7 +49,7 @@ endfunction
|
||||
function! ale#fix#ApplyFixes(buffer, output) abort
|
||||
let l:data = g:ale_fix_buffer_data[a:buffer]
|
||||
let l:data.output = a:output
|
||||
let l:data.changes_made = l:data.lines_before != l:data.output
|
||||
let l:data.changes_made = l:data.lines_before !=# l:data.output " no-custom-checks
|
||||
let l:data.done = 1
|
||||
|
||||
call ale#command#RemoveManagedFiles(a:buffer)
|
||||
|
||||
@@ -27,6 +27,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['python'],
|
||||
\ 'description': 'Fix PEP8 issues with black.',
|
||||
\ },
|
||||
\ 'dfmt': {
|
||||
\ 'function': 'ale#fixers#dfmt#Fix',
|
||||
\ 'suggested_filetypes': ['d'],
|
||||
\ 'description': 'Fix D files with dfmt.',
|
||||
\ },
|
||||
\ 'fecs': {
|
||||
\ 'function': 'ale#fixers#fecs#Fix',
|
||||
\ 'suggested_filetypes': ['javascript', 'css', 'html'],
|
||||
@@ -49,6 +54,11 @@ let s:default_registry = {
|
||||
\ 'description': 'Apply elm-format to a file.',
|
||||
\ 'aliases': ['format'],
|
||||
\ },
|
||||
\ 'nimpretty': {
|
||||
\ 'function': 'ale#fixers#nimpretty#Fix',
|
||||
\ 'suggested_filetypes': ['nim'],
|
||||
\ 'description': 'Apply nimpretty to a file.',
|
||||
\ },
|
||||
\ 'eslint': {
|
||||
\ 'function': 'ale#fixers#eslint#Fix',
|
||||
\ 'suggested_filetypes': ['javascript', 'typescript'],
|
||||
@@ -115,6 +125,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['scala'],
|
||||
\ 'description': 'Fix Scala files using scalafmt',
|
||||
\ },
|
||||
\ 'sorbet': {
|
||||
\ 'function': 'ale#fixers#sorbet#Fix',
|
||||
\ 'suggested_filetypes': ['ruby'],
|
||||
\ 'description': 'Fix ruby files with srb tc --autocorrect.',
|
||||
\ },
|
||||
\ 'standard': {
|
||||
\ 'function': 'ale#fixers#standard#Fix',
|
||||
\ 'suggested_filetypes': ['javascript'],
|
||||
@@ -145,6 +160,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['php'],
|
||||
\ 'description': 'Fix PHP files with php-cs-fixer.',
|
||||
\ },
|
||||
\ 'clangtidy': {
|
||||
\ 'function': 'ale#fixers#clangtidy#Fix',
|
||||
\ 'suggested_filetypes': ['c', 'cpp', 'objc'],
|
||||
\ 'description': 'Fix C/C++ and ObjectiveC files with clang-tidy.',
|
||||
\ },
|
||||
\ 'clang-format': {
|
||||
\ 'function': 'ale#fixers#clangformat#Fix',
|
||||
\ 'suggested_filetypes': ['c', 'cpp', 'cuda'],
|
||||
@@ -205,6 +225,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['haskell'],
|
||||
\ 'description': 'Fix Haskell files with brittany.',
|
||||
\ },
|
||||
\ 'hindent': {
|
||||
\ 'function': 'ale#fixers#hindent#Fix',
|
||||
\ 'suggested_filetypes': ['haskell'],
|
||||
\ 'description': 'Fix Haskell files with hindent.',
|
||||
\ },
|
||||
\ 'hlint': {
|
||||
\ 'function': 'ale#fixers#hlint#Fix',
|
||||
\ 'suggested_filetypes': ['haskell'],
|
||||
@@ -215,6 +240,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['haskell'],
|
||||
\ 'description': 'Refactor Haskell files with stylish-haskell.',
|
||||
\ },
|
||||
\ 'purty': {
|
||||
\ 'function': 'ale#fixers#purty#Fix',
|
||||
\ 'suggested_filetypes': ['purescript'],
|
||||
\ 'description': 'Format PureScript files with purty.',
|
||||
\ },
|
||||
\ 'ocamlformat': {
|
||||
\ 'function': 'ale#fixers#ocamlformat#Fix',
|
||||
\ 'suggested_filetypes': ['ocaml'],
|
||||
@@ -240,6 +270,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['sql'],
|
||||
\ 'description': 'Fix SQL files with sqlfmt.',
|
||||
\ },
|
||||
\ 'sqlformat': {
|
||||
\ 'function': 'ale#fixers#sqlformat#Fix',
|
||||
\ 'suggested_filetypes': ['sql'],
|
||||
\ 'description': 'Fix SQL files with sqlformat.',
|
||||
\ },
|
||||
\ 'google_java_format': {
|
||||
\ 'function': 'ale#fixers#google_java_format#Fix',
|
||||
\ 'suggested_filetypes': ['java'],
|
||||
@@ -297,7 +332,7 @@ let s:default_registry = {
|
||||
\ },
|
||||
\ 'styler': {
|
||||
\ 'function': 'ale#fixers#styler#Fix',
|
||||
\ 'suggested_filetypes': ['r', 'rmarkdown'],
|
||||
\ 'suggested_filetypes': ['r', 'rmarkdown', 'rmd'],
|
||||
\ 'description': 'Fix R files with styler.',
|
||||
\ },
|
||||
\ 'latexindent': {
|
||||
@@ -315,6 +350,21 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['python'],
|
||||
\ 'description': 'Sort Python imports with reorder-python-imports.',
|
||||
\ },
|
||||
\ 'gnatpp': {
|
||||
\ 'function': 'ale#fixers#gnatpp#Fix',
|
||||
\ 'suggested_filetypes': ['ada'],
|
||||
\ 'description': 'Format Ada files with gnatpp.',
|
||||
\ },
|
||||
\ 'nixpkgs-fmt': {
|
||||
\ 'function': 'ale#fixers#nixpkgsfmt#Fix',
|
||||
\ 'suggested_filetypes': ['nix'],
|
||||
\ 'description': 'A formatter for Nix code',
|
||||
\ },
|
||||
\ 'html-beautify': {
|
||||
\ 'function': 'ale#fixers#html_beautify#Fix',
|
||||
\ 'suggested_filetypes': ['html', 'htmldjango'],
|
||||
\ 'description': 'Fix HTML files with html-beautify.',
|
||||
\ },
|
||||
\}
|
||||
|
||||
" Reset the function registry to the default entries.
|
||||
|
||||
@@ -29,6 +29,10 @@ function! ale#fixers#black#Fix(buffer) abort
|
||||
|
||||
let l:options = ale#Var(a:buffer, 'python_black_options')
|
||||
|
||||
if expand('#' . a:buffer . ':e') is? 'pyi'
|
||||
let l:options .= '--pyi'
|
||||
endif
|
||||
|
||||
return {
|
||||
\ 'command': l:cd_string . ale#Escape(l:executable) . l:exec_args
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
|
||||
@@ -13,10 +13,15 @@ function! ale#fixers#clangformat#GetExecutable(buffer) abort
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#clangformat#Fix(buffer) abort
|
||||
let l:executable = ale#Escape(ale#fixers#clangformat#GetExecutable(a:buffer))
|
||||
let l:filename = ale#Escape(bufname(a:buffer))
|
||||
let l:options = ale#Var(a:buffer, 'c_clangformat_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(ale#fixers#clangformat#GetExecutable(a:buffer))
|
||||
\ . ' ' . l:options,
|
||||
\}
|
||||
let l:command = l:executable . ' --assume-filename=' . l:filename
|
||||
|
||||
if l:options isnot# ''
|
||||
let l:command .= ' ' . l:options
|
||||
endif
|
||||
|
||||
return {'command': l:command}
|
||||
endfunction
|
||||
|
||||
52
autoload/ale/fixers/clangtidy.vim
Normal file
52
autoload/ale/fixers/clangtidy.vim
Normal file
@@ -0,0 +1,52 @@
|
||||
scriptencoding utf-8
|
||||
" Author: ObserverOfTime <chronobserver@disroot.org>
|
||||
" Description: Fixing C/C++ files with clang-tidy.
|
||||
|
||||
function! s:set_variables() abort
|
||||
let l:use_global = get(g:, 'ale_use_global_executables', 0)
|
||||
|
||||
for l:ft in ['c', 'cpp']
|
||||
call ale#Set(l:ft . '_clangtidy_executable', 'clang-tidy')
|
||||
call ale#Set(l:ft . '_clangtidy_use_global', l:use_global)
|
||||
call ale#Set(l:ft . '_clangtidy_checks', [])
|
||||
call ale#Set(l:ft . '_clangtidy_options', '')
|
||||
call ale#Set(l:ft . '_clangtidy_extra_options', '')
|
||||
call ale#Set(l:ft . '_clangtidy_fix_errors', 1)
|
||||
endfor
|
||||
|
||||
call ale#Set('c_build_dir', '')
|
||||
endfunction
|
||||
|
||||
call s:set_variables()
|
||||
|
||||
function! ale#fixers#clangtidy#Var(buffer, name) abort
|
||||
let l:ft = getbufvar(str2nr(a:buffer), '&filetype')
|
||||
let l:ft = l:ft =~# 'cpp' ? 'cpp' : 'c'
|
||||
|
||||
return ale#Var(a:buffer, l:ft . '_clangtidy_' . a:name)
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#clangtidy#GetCommand(buffer) abort
|
||||
let l:checks = join(ale#fixers#clangtidy#Var(a:buffer, 'checks'), ',')
|
||||
let l:extra_options = ale#fixers#clangtidy#Var(a:buffer, 'extra_options')
|
||||
let l:build_dir = ale#c#GetBuildDirectory(a:buffer)
|
||||
let l:options = empty(l:build_dir)
|
||||
\ ? ale#fixers#clangtidy#Var(a:buffer, 'options') : ''
|
||||
let l:fix_errors = ale#fixers#clangtidy#Var(a:buffer, 'fix_errors')
|
||||
|
||||
return ' -fix' . (l:fix_errors ? ' -fix-errors' : '')
|
||||
\ . (empty(l:checks) ? '' : ' -checks=' . ale#Escape(l:checks))
|
||||
\ . (empty(l:extra_options) ? '' : ' ' . l:extra_options)
|
||||
\ . (empty(l:build_dir) ? '' : ' -p ' . ale#Escape(l:build_dir))
|
||||
\ . ' %t' . (empty(l:options) ? '' : ' -- ' . l:options)
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#clangtidy#Fix(buffer) abort
|
||||
let l:executable = ale#fixers#clangtidy#Var(a:buffer, 'executable')
|
||||
let l:command = ale#fixers#clangtidy#GetCommand(a:buffer)
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable) . l:command,
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
||||
18
autoload/ale/fixers/dfmt.vim
Normal file
18
autoload/ale/fixers/dfmt.vim
Normal file
@@ -0,0 +1,18 @@
|
||||
" Author: theoldmoon0602
|
||||
" Description: Integration of dfmt with ALE.
|
||||
|
||||
call ale#Set('d_dfmt_executable', 'dfmt')
|
||||
call ale#Set('d_dfmt_options', '')
|
||||
|
||||
function! ale#fixers#dfmt#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'd_dfmt_executable')
|
||||
let l:options = ale#Var(a:buffer, 'd_dfmt_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . ' -i'
|
||||
\ . (empty(l:options) ? '' : ' ' . l:options)
|
||||
\ . ' %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
||||
17
autoload/ale/fixers/gnatpp.vim
Normal file
17
autoload/ale/fixers/gnatpp.vim
Normal file
@@ -0,0 +1,17 @@
|
||||
" Author: tim <tim@inept.tech>
|
||||
" Description: Fix files with gnatpp.
|
||||
|
||||
call ale#Set('ada_gnatpp_executable', 'gnatpp')
|
||||
call ale#Set('ada_gnatpp_options', '')
|
||||
|
||||
function! ale#fixers#gnatpp#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'ada_gnatpp_executable')
|
||||
let l:options = ale#Var(a:buffer, 'ada_gnatpp_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
||||
@@ -7,9 +7,10 @@ call ale#Set('go_gofmt_options', '')
|
||||
function! ale#fixers#gofmt#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'go_gofmt_executable')
|
||||
let l:options = ale#Var(a:buffer, 'go_gofmt_options')
|
||||
let l:env = ale#go#EnvString(a:buffer)
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ 'command': l:env . ale#Escape(l:executable)
|
||||
\ . ' -l -w'
|
||||
\ . (empty(l:options) ? '' : ' ' . l:options)
|
||||
\ . ' %t',
|
||||
|
||||
@@ -7,13 +7,14 @@ call ale#Set('go_goimports_options', '')
|
||||
function! ale#fixers#goimports#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'go_goimports_executable')
|
||||
let l:options = ale#Var(a:buffer, 'go_goimports_options')
|
||||
let l:env = ale#go#EnvString(a:buffer)
|
||||
|
||||
if !executable(l:executable)
|
||||
return 0
|
||||
endif
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ 'command': l:env . ale#Escape(l:executable)
|
||||
\ . ' -l -w -srcdir %s'
|
||||
\ . (empty(l:options) ? '' : ' ' . l:options)
|
||||
\ . ' %t',
|
||||
|
||||
@@ -2,9 +2,10 @@ call ale#Set('go_go_executable', 'go')
|
||||
|
||||
function! ale#fixers#gomod#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'go_go_executable')
|
||||
let l:env = ale#go#EnvString(a:buffer)
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable) . ' mod edit -fmt %t',
|
||||
\ 'command': l:env . ale#Escape(l:executable) . ' mod edit -fmt %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
||||
|
||||
20
autoload/ale/fixers/hindent.vim
Normal file
20
autoload/ale/fixers/hindent.vim
Normal file
@@ -0,0 +1,20 @@
|
||||
" Author: AlexeiDrake <drake.alexei@gmail.com>
|
||||
" Description: Integration of hindent formatting with ALE.
|
||||
"
|
||||
call ale#Set('haskell_hindent_executable', 'hindent')
|
||||
|
||||
function! ale#fixers#hindent#GetExecutable(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'haskell_hindent_executable')
|
||||
|
||||
return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'hindent')
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#hindent#Fix(buffer) abort
|
||||
let l:executable = ale#fixers#hindent#GetExecutable(a:buffer)
|
||||
|
||||
return {
|
||||
\ 'command': l:executable
|
||||
\ . ' %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
||||
21
autoload/ale/fixers/html_beautify.vim
Normal file
21
autoload/ale/fixers/html_beautify.vim
Normal file
@@ -0,0 +1,21 @@
|
||||
" Author: WhyNotHugo <hugo@barrera.io>
|
||||
" Description: Lint HTML files with html-beautify.
|
||||
"
|
||||
call ale#Set('html_beautify_executable', 'html-beautify')
|
||||
call ale#Set('html_beautify_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('html_beautify_options', '')
|
||||
call ale#Set('html_beautify_change_directory', 1)
|
||||
|
||||
function! ale#fixers#html_beautify#Fix(buffer) abort
|
||||
let l:executable = ale#python#FindExecutable(
|
||||
\ a:buffer,
|
||||
\ 'html_beautify',
|
||||
\ ['html-beautify']
|
||||
\)
|
||||
|
||||
let l:options = ale#Var(a:buffer, 'html_beautify_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable). ' ' . l:options . ' -',
|
||||
\}
|
||||
endfunction
|
||||
15
autoload/ale/fixers/nimpretty.vim
Normal file
15
autoload/ale/fixers/nimpretty.vim
Normal file
@@ -0,0 +1,15 @@
|
||||
" Author: Nhan <hi@imnhan.com>
|
||||
" Description: Integration of nimpretty with ALE.
|
||||
|
||||
call ale#Set('nim_nimpretty_executable', 'nimpretty')
|
||||
call ale#Set('nim_nimpretty_options', '--maxLineLen:80')
|
||||
|
||||
function! ale#fixers#nimpretty#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'nim_nimpretty_executable')
|
||||
let l:options = ale#Var(a:buffer, 'nim_nimpretty_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable) . ' %t' . ale#Pad(l:options),
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
||||
12
autoload/ale/fixers/nixpkgsfmt.vim
Normal file
12
autoload/ale/fixers/nixpkgsfmt.vim
Normal file
@@ -0,0 +1,12 @@
|
||||
call ale#Set('nix_nixpkgsfmt_executable', 'nixpkgs-fmt')
|
||||
call ale#Set('nix_nixpkgsfmt_options', '')
|
||||
|
||||
function! ale#fixers#nixpkgsfmt#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'nix_nixpkgsfmt_executable')
|
||||
let l:options = ale#Var(a:buffer, 'nix_nixpkgsfmt_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . (empty(l:options) ? '' : ' ' . l:options),
|
||||
\}
|
||||
endfunction
|
||||
@@ -39,9 +39,15 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort
|
||||
let l:options = ale#Var(a:buffer, 'javascript_prettier_options')
|
||||
let l:parser = ''
|
||||
|
||||
let l:filetypes = split(getbufvar(a:buffer, '&filetype'), '\.')
|
||||
|
||||
if index(l:filetypes, 'handlebars') > -1
|
||||
let l:parser = 'glimmer'
|
||||
endif
|
||||
|
||||
" Append the --parser flag depending on the current filetype (unless it's
|
||||
" already set in g:javascript_prettier_options).
|
||||
if empty(expand('#' . a:buffer . ':e')) && match(l:options, '--parser') == -1
|
||||
if empty(expand('#' . a:buffer . ':e')) && l:parser is# '' && match(l:options, '--parser') == -1
|
||||
" Mimic Prettier's defaults. In cases without a file extension or
|
||||
" filetype (scratch buffer), Prettier needs `parser` set to know how
|
||||
" to process the buffer.
|
||||
@@ -65,7 +71,7 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort
|
||||
\ 'html': 'html',
|
||||
\}
|
||||
|
||||
for l:filetype in split(getbufvar(a:buffer, '&filetype'), '\.')
|
||||
for l:filetype in l:filetypes
|
||||
if has_key(l:prettier_parsers, l:filetype)
|
||||
let l:parser = l:prettier_parsers[l:filetype]
|
||||
break
|
||||
|
||||
22
autoload/ale/fixers/purty.vim
Normal file
22
autoload/ale/fixers/purty.vim
Normal file
@@ -0,0 +1,22 @@
|
||||
" Author: iclanzan <sorin@iclanzan.com>
|
||||
" Description: Integration of purty with ALE.
|
||||
|
||||
call ale#Set('purescript_purty_executable', 'purty')
|
||||
|
||||
function! ale#fixers#purty#GetExecutable(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'purescript_purty_executable')
|
||||
|
||||
return ale#Escape(l:executable)
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#purty#Fix(buffer) abort
|
||||
let l:executable = ale#fixers#purty#GetExecutable(a:buffer)
|
||||
|
||||
return {
|
||||
\ 'command': l:executable
|
||||
\ . ' --write'
|
||||
\ . ' %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
||||
|
||||
@@ -6,7 +6,7 @@ function! ale#fixers#rubocop#GetCommand(buffer) abort
|
||||
let l:config = ale#path#FindNearestFile(a:buffer, '.rubocop.yml')
|
||||
let l:options = ale#Var(a:buffer, 'ruby_rubocop_options')
|
||||
|
||||
return ale#handlers#ruby#EscapeExecutable(l:executable, 'rubocop')
|
||||
return ale#ruby#EscapeExecutable(l:executable, 'rubocop')
|
||||
\ . (!empty(l:config) ? ' --config ' . ale#Escape(l:config) : '')
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' --auto-correct --force-exclusion %t'
|
||||
|
||||
19
autoload/ale/fixers/sorbet.vim
Normal file
19
autoload/ale/fixers/sorbet.vim
Normal file
@@ -0,0 +1,19 @@
|
||||
call ale#Set('ruby_sorbet_executable', 'srb')
|
||||
call ale#Set('ruby_sorbet_options', '')
|
||||
|
||||
function! ale#fixers#sorbet#GetCommand(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'ruby_sorbet_executable')
|
||||
let l:options = ale#Var(a:buffer, 'ruby_sorbet_options')
|
||||
|
||||
return ale#ruby#EscapeExecutable(l:executable, 'srb')
|
||||
\ . ' tc'
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' --autocorrect --file %t'
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#sorbet#Fix(buffer) abort
|
||||
return {
|
||||
\ 'command': ale#fixers#sorbet#GetCommand(a:buffer),
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
||||
16
autoload/ale/fixers/sqlformat.vim
Normal file
16
autoload/ale/fixers/sqlformat.vim
Normal file
@@ -0,0 +1,16 @@
|
||||
" Author: Cluas <Cluas@live.cn>
|
||||
" Description: Fixing files with sqlformat.
|
||||
|
||||
call ale#Set('sql_sqlformat_executable', 'sqlformat')
|
||||
call ale#Set('sql_sqlformat_options', '')
|
||||
|
||||
function! ale#fixers#sqlformat#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'sql_sqlformat_executable')
|
||||
let l:options = ale#Var(a:buffer, 'sql_sqlformat_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' -'
|
||||
\}
|
||||
endfunction
|
||||
@@ -7,6 +7,7 @@ call ale#Set('javascript_standard_options', '')
|
||||
|
||||
function! ale#fixers#standard#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'javascript_standard', [
|
||||
\ 'node_modules/standardx/bin/cmd.js',
|
||||
\ 'node_modules/standard/bin/cmd.js',
|
||||
\ 'node_modules/.bin/standard',
|
||||
\])
|
||||
@@ -14,7 +15,14 @@ endfunction
|
||||
|
||||
function! ale#fixers#standard#Fix(buffer) abort
|
||||
let l:executable = ale#fixers#standard#GetExecutable(a:buffer)
|
||||
let l:options = ale#Var(a:buffer, 'javascript_standard_options')
|
||||
let l:filetype = getbufvar(a:buffer, '&filetype')
|
||||
let l:options_type = 'javascript_standard_options'
|
||||
|
||||
if l:filetype =~# 'typescript'
|
||||
let l:options_type = 'typescript_standard_options'
|
||||
endif
|
||||
|
||||
let l:options = ale#Var(a:buffer, l:options_type)
|
||||
|
||||
return {
|
||||
\ 'command': ale#node#Executable(a:buffer, l:executable)
|
||||
|
||||
@@ -9,7 +9,7 @@ function! ale#fixers#standardrb#GetCommand(buffer) abort
|
||||
let l:config = ale#path#FindNearestFile(a:buffer, '.standard.yml')
|
||||
let l:options = ale#Var(a:buffer, 'ruby_standardrb_options')
|
||||
|
||||
return ale#handlers#ruby#EscapeExecutable(l:executable, 'standardrb')
|
||||
return ale#ruby#EscapeExecutable(l:executable, 'standardrb')
|
||||
\ . (!empty(l:config) ? ' --config ' . ale#Escape(l:config) : '')
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' --fix --force-exclusion %t'
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
call ale#Set('stylelint_executable', 'stylelint')
|
||||
call ale#Set('stylelint_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('stylelint_options', '')
|
||||
|
||||
function! ale#fixers#stylelint#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'stylelint', [
|
||||
@@ -13,10 +14,14 @@ endfunction
|
||||
|
||||
function! ale#fixers#stylelint#Fix(buffer) abort
|
||||
let l:executable = ale#fixers#stylelint#GetExecutable(a:buffer)
|
||||
let l:options = ale#Var(a:buffer, 'stylelint_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#node#Executable(a:buffer, l:executable)
|
||||
\ . ' --fix %t',
|
||||
\ 'command': ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#node#Executable(a:buffer, l:executable)
|
||||
\ . ' %t'
|
||||
\ . ale#Pad(l:options)
|
||||
\ . ' --fix',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user