mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8abe0d6a2 | ||
|
|
55757e3d78 | ||
|
|
8e7ede3be8 | ||
|
|
6f8db3e5c4 | ||
|
|
2398fd7456 | ||
|
|
c1366f8a62 | ||
|
|
5089b09b7e | ||
|
|
220ebb3a79 | ||
|
|
25b5fad15c | ||
|
|
39f15811c3 | ||
|
|
34171774eb | ||
|
|
80328fa156 | ||
|
|
1fcf6444dc | ||
|
|
e57978ddd6 |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1,7 +1,6 @@
|
||||
/init.vim
|
||||
/doc/tags
|
||||
.*
|
||||
!.editorconfig
|
||||
*.obj
|
||||
.*
|
||||
/doc/tags
|
||||
/init.vim
|
||||
/test/ale-info-test-file
|
||||
tags
|
||||
|
||||
@@ -1,28 +1,8 @@
|
||||
<!--
|
||||
This is a template for bug reports. If you want to request a new feature,
|
||||
you can clear this entire form field and write a short description of what
|
||||
you want.
|
||||
For bugs, paste output from your clipboard after running :ALEInfoToClipboard
|
||||
here. If that doesn't work for some reason, try running :ALEInfo and copying
|
||||
the output from that here instead. If everything is broken, run around in
|
||||
circles and scream.
|
||||
|
||||
Whatever the case, describe the your issue here.
|
||||
-->
|
||||
|
||||
## Information
|
||||
|
||||
**VIM version**
|
||||
|
||||
PASTE JUST THE FIRST TWO LINES OF `:version` HERE.
|
||||
|
||||
Operating System: WHAT OS WERE YOU USING?
|
||||
|
||||
### :ALEInfo
|
||||
|
||||
PASTE OUTPUT OF `:ALEInfo` HERE. YOU CAN TRY `:ALEInfoToClipboard`.
|
||||
|
||||
## What went wrong
|
||||
|
||||
WRITE WHAT WENT WRONG HERE.
|
||||
|
||||
## Reproducing the bug
|
||||
|
||||
Steps for repeating the bug:
|
||||
|
||||
1. Write a list of steps.
|
||||
2. Otherwise nobody will fix the bug.
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2016-2018, w0rp <devw0rp@gmail.com>
|
||||
Copyright (c) 2016-2017, w0rp <devw0rp@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
||||
@@ -12,8 +12,7 @@ READ THIS: Before creating a pull request, please consider the following first.
|
||||
that ALE can work with, please add Vader tests for them. Look at existing
|
||||
tests in the test/handler directory, etc.
|
||||
* If you add or modify a function for computing a command line string for
|
||||
running a command, please add Vader tests for that. Look at existing
|
||||
tests in the test/command_callback directory, etc.
|
||||
running a command, please add Vader tests for that.
|
||||
* Generally try and cover anything with Vader tests, although some things just
|
||||
can't be tested with Vader, or at least they can be hard to test. Consider
|
||||
breaking up your code so that some parts can be tested, and generally open up
|
||||
|
||||
452
README.md
452
README.md
@@ -1,10 +1,10 @@
|
||||
# Asynchronous Lint Engine [](https://travis-ci.org/w0rp/ale) [](https://ci.appveyor.com/project/w0rp/ale)
|
||||
# Asynchronous Lint Engine [](https://travis-ci.org/w0rp/ale) [](https://ci.appveyor.com/project/w0rp/ale)
|
||||
|
||||
|
||||

|
||||
|
||||
ALE (Asynchronous Lint Engine) is a plugin for providing linting in NeoVim
|
||||
0.2.0+ and Vim 8 while you edit your text files.
|
||||
and Vim 8 while you edit your text files.
|
||||
|
||||

|
||||
|
||||
@@ -16,18 +16,9 @@ back to a filesystem.
|
||||
|
||||
In other words, this plugin allows you to lint while you type.
|
||||
|
||||
ALE offers support for fixing code with command line tools in a non-blocking
|
||||
manner with the `:ALEFix` feature, supporting tools in many languages, like
|
||||
`prettier`, `eslint`, `autopep8`, and more.
|
||||
|
||||
ALE acts as a "language client" to support a variety of Language Server Protocol
|
||||
features, including:
|
||||
|
||||
* Diagnostics (via Language Server Protocol linters)
|
||||
* Go To Definition (`:ALEGoToDefinition`)
|
||||
* Completion (`let g:ale_completion_enabled = 1`)
|
||||
* Finding references (`:ALEFindReferences`)
|
||||
* Hover information (`:ALEHover`)
|
||||
In addition to linting support, ALE offers some support for fixing code with
|
||||
formatting tools, and completion via Language Server Protocol servers, or
|
||||
servers with similar enough protocols, like `tsserver`.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
@@ -36,9 +27,6 @@ features, including:
|
||||
1. [Linting](#usage-linting)
|
||||
2. [Fixing](#usage-fixing)
|
||||
3. [Completion](#usage-completion)
|
||||
4. [Go To Definition](#usage-go-to-definition)
|
||||
5. [Find References](#usage-find-references)
|
||||
6. [Hovering](#usage-hover)
|
||||
3. [Installation](#installation)
|
||||
1. [Installation with Vim package management](#standard-installation)
|
||||
2. [Installation with Pathogen](#installation-with-pathogen)
|
||||
@@ -48,19 +36,15 @@ features, including:
|
||||
1. [How do I disable particular linters?](#faq-disable-linters)
|
||||
2. [How can I keep the sign gutter open?](#faq-keep-signs)
|
||||
3. [How can I change the signs ALE uses?](#faq-change-signs)
|
||||
4. [How can I change or disable the highlights ALE uses?](#faq-change-highlights)
|
||||
5. [How can I show errors or warnings in my statusline?](#faq-statusline)
|
||||
6. [How can I show errors or warnings in my lightline?](#faq-lightline)
|
||||
7. [How can I change the format for echo messages?](#faq-echo-format)
|
||||
8. [How can I execute some code when ALE starts or stops linting?](#faq-autocmd)
|
||||
9. [How can I navigate between errors quickly?](#faq-navigation)
|
||||
10. [How can I run linters only when I save files?](#faq-lint-on-save)
|
||||
11. [How can I use the quickfix list instead of the loclist?](#faq-quickfix)
|
||||
12. [How can I check JSX files with both stylelint and eslint?](#faq-jsx-stylelint-eslint)
|
||||
13. [Will this plugin eat all of my laptop battery power?](#faq-my-battery-is-sad)
|
||||
14. [How can I configure my C or C++ project?](#faq-c-configuration)
|
||||
15. [How can I configure ALE differently for different buffers?](#faq-buffer-configuration)
|
||||
16. [How can I configure the height of the list in which ALE displays errors?](#faq-list-window-height)
|
||||
4. [How can I show errors or warnings in my statusline?](#faq-statusline)
|
||||
5. [How can I show errors or warnings in my lightline?](#faq-lightline)
|
||||
6. [How can I change the format for echo messages?](#faq-echo-format)
|
||||
7. [How can I execute some code when ALE stops linting?](#faq-autocmd)
|
||||
8. [How can I navigate between errors quickly?](#faq-navigation)
|
||||
9. [How can I run linters only when I save files?](#faq-lint-on-save)
|
||||
10. [How can I use the quickfix list instead of the loclist?](#faq-quickfix)
|
||||
11. [How can I check JSX files with both stylelint and eslint?](#faq-jsx-stylelint-eslint)
|
||||
12. [Will this plugin eat all of my laptop battery power?](#faq-my-battery-is-sad)
|
||||
|
||||
<a name="supported-languages"></a>
|
||||
|
||||
@@ -87,102 +71,83 @@ formatting.
|
||||
| -------- | ----- |
|
||||
| ASM | [gcc](https://gcc.gnu.org) |
|
||||
| Ansible | [ansible-lint](https://github.com/willthames/ansible-lint) |
|
||||
| API Blueprint | [drafter](https://github.com/apiaryio/drafter) |
|
||||
| AsciiDoc | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [redpen](http://redpen.cc/), [write-good](https://github.com/btford/write-good) |
|
||||
| AsciiDoc | [proselint](http://proselint.com/) |
|
||||
| Awk | [gawk](https://www.gnu.org/software/gawk/)|
|
||||
| Bash | shell [-n flag](https://www.gnu.org/software/bash/manual/bash.html#index-set), [shellcheck](https://www.shellcheck.net/), [shfmt](https://github.com/mvdan/sh) |
|
||||
| Bourne Shell | shell [-n flag](http://linux.die.net/man/1/sh), [shellcheck](https://www.shellcheck.net/), [shfmt](https://github.com/mvdan/sh) |
|
||||
| C | [cppcheck](http://cppcheck.sourceforge.net), [cpplint](https://github.com/google/styleguide/tree/gh-pages/cpplint), [clang](http://clang.llvm.org/), [clangtidy](http://clang.llvm.org/extra/clang-tidy/) !!, [clang-format](https://clang.llvm.org/docs/ClangFormat.html), [flawfinder](https://www.dwheeler.com/flawfinder/), [gcc](https://gcc.gnu.org/) |
|
||||
| C++ (filetype cpp) | [clang](http://clang.llvm.org/), [clangcheck](http://clang.llvm.org/docs/ClangCheck.html) !!, [clangtidy](http://clang.llvm.org/extra/clang-tidy/) !!, [clang-format](https://clang.llvm.org/docs/ClangFormat.html), [cppcheck](http://cppcheck.sourceforge.net), [cpplint](https://github.com/google/styleguide/tree/gh-pages/cpplint) !!, [flawfinder](https://www.dwheeler.com/flawfinder/), [gcc](https://gcc.gnu.org/) |
|
||||
| Bash | shell [-n flag](https://www.gnu.org/software/bash/manual/bash.html#index-set), [shellcheck](https://www.shellcheck.net/) |
|
||||
| Bourne Shell | shell [-n flag](http://linux.die.net/man/1/sh), [shellcheck](https://www.shellcheck.net/) |
|
||||
| C | [cppcheck](http://cppcheck.sourceforge.net), [cpplint](https://github.com/google/styleguide/tree/gh-pages/cpplint), [gcc](https://gcc.gnu.org/), [clang](http://clang.llvm.org/), [clangtidy](http://clang.llvm.org/extra/clang-tidy/) !!, [clang-format](https://clang.llvm.org/docs/ClangFormat.html)|
|
||||
| C++ (filetype cpp) | [clang](http://clang.llvm.org/), [clangcheck](http://clang.llvm.org/docs/ClangCheck.html) !!, [clangtidy](http://clang.llvm.org/extra/clang-tidy/) !!, [cppcheck](http://cppcheck.sourceforge.net), [cpplint](https://github.com/google/styleguide/tree/gh-pages/cpplint) !!, [gcc](https://gcc.gnu.org/), [clang-format](https://clang.llvm.org/docs/ClangFormat.html)|
|
||||
| CUDA | [nvcc](http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html) |
|
||||
| C# | [mcs](http://www.mono-project.com/docs/about-mono/languages/csharp/) see:`help ale-cs-mcs` for details, [mcsc](http://www.mono-project.com/docs/about-mono/languages/csharp/) !! see:`help ale-cs-mcsc` for details and configuration|
|
||||
| Chef | [foodcritic](http://www.foodcritic.io/) |
|
||||
| Clojure | [joker](https://github.com/candid82/joker) |
|
||||
| CMake | [cmakelint](https://github.com/richq/cmake-lint) |
|
||||
| CoffeeScript | [coffee](http://coffeescript.org/), [coffeelint](https://www.npmjs.com/package/coffeelint) |
|
||||
| Crystal | [crystal](https://crystal-lang.org/) !! |
|
||||
| CSS | [csslint](http://csslint.net/), [prettier](https://github.com/prettier/prettier), [stylelint](https://github.com/stylelint/stylelint) |
|
||||
| Cucumber | [cucumber](https://cucumber.io/) |
|
||||
| CSS | [csslint](http://csslint.net/), [stylelint](https://github.com/stylelint/stylelint), [prettier](https://github.com/prettier/prettier) |
|
||||
| Cython (pyrex filetype) | [cython](http://cython.org/) |
|
||||
| D | [dmd](https://dlang.org/dmd-linux.html) |
|
||||
| Dafny | [dafny](https://rise4fun.com/Dafny) !! |
|
||||
| Dart | [dartanalyzer](https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_cli) !!, [language_server](https://github.com/natebosch/dart_language_server) |
|
||||
| Dockerfile | [hadolint](https://github.com/hadolint/hadolint) |
|
||||
| Elixir | [credo](https://github.com/rrrene/credo), [dialyxir](https://github.com/jeremyjh/dialyxir), [dogma](https://github.com/lpil/dogma) !!|
|
||||
| Dart | [dartanalyzer](https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_cli) |
|
||||
| Dockerfile | [hadolint](https://github.com/lukasmartinelli/hadolint) |
|
||||
| Elixir | [credo](https://github.com/rrrene/credo), [dogma](https://github.com/lpil/dogma) !! |
|
||||
| Elm | [elm-format](https://github.com/avh4/elm-format), [elm-make](https://github.com/elm-lang/elm-make) |
|
||||
| Erb | [erb](https://apidock.com/ruby/ERB), [erubi](https://github.com/jeremyevans/erubi), [erubis](https://github.com/kwatch/erubis) |
|
||||
| Erb | [erb](https://github.com/jeremyevans/erubi), [erubis](https://github.com/kwatch/erubis) |
|
||||
| Erlang | [erlc](http://erlang.org/doc/man/erlc.html), [SyntaxErl](https://github.com/ten0s/syntaxerl) |
|
||||
| Fish | fish [-n flag](https://linux.die.net/man/1/fish)
|
||||
| Fortran | [gcc](https://gcc.gnu.org/) |
|
||||
| Fountain | [proselint](http://proselint.com/) |
|
||||
| FusionScript | [fusion-lint](https://github.com/RyanSquared/fusionscript) |
|
||||
| Git Commit Messages | [gitlint](https://github.com/jorisroovers/gitlint) |
|
||||
| GLSL | [glslang](https://github.com/KhronosGroup/glslang), [glslls](https://github.com/svenstaro/glsl-language-server) |
|
||||
| Go | [gofmt](https://golang.org/cmd/gofmt/), [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports), [go vet](https://golang.org/cmd/vet/) !!, [golint](https://godoc.org/github.com/golang/lint), [gotype](https://godoc.org/golang.org/x/tools/cmd/gotype) !!, [gometalinter](https://github.com/alecthomas/gometalinter) !!, [go build](https://golang.org/cmd/go/) !!, [gosimple](https://github.com/dominikh/go-tools/tree/master/cmd/gosimple) !!, [staticcheck](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck) !! |
|
||||
| GraphQL | [eslint](http://eslint.org/), [gqlint](https://github.com/happylinks/gqlint), [prettier](https://github.com/prettier/prettier) |
|
||||
| GLSL | [glslang](https://github.com/KhronosGroup/glslang) |
|
||||
| Go | [gofmt](https://golang.org/cmd/gofmt/), [go vet](https://golang.org/cmd/vet/), [golint](https://godoc.org/github.com/golang/lint), [gometalinter](https://github.com/alecthomas/gometalinter) !!, [go build](https://golang.org/cmd/go/) !!, [gosimple](https://github.com/dominikh/go-tools/tree/master/cmd/gosimple) !!, [staticcheck](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck) !! |
|
||||
| GraphQL | [gqlint](https://github.com/happylinks/gqlint) |
|
||||
| Haml | [haml-lint](https://github.com/brigade/haml-lint) |
|
||||
| Handlebars | [ember-template-lint](https://github.com/rwjblue/ember-template-lint) |
|
||||
| Haskell | [brittany](https://github.com/lspitzner/brittany), [ghc](https://www.haskell.org/ghc/), [stack-ghc](https://haskellstack.org/), [stack-build](https://haskellstack.org/) !!, [ghc-mod](https://github.com/DanielG/ghc-mod), [stack-ghc-mod](https://github.com/DanielG/ghc-mod), [hlint](https://hackage.haskell.org/package/hlint), [hdevtools](https://hackage.haskell.org/package/hdevtools), [hfmt](https://github.com/danstiner/hfmt) |
|
||||
| HTML | [alex](https://github.com/wooorm/alex) !!, [HTMLHint](http://htmlhint.com/), [proselint](http://proselint.com/), [tidy](http://www.html-tidy.org/), [write-good](https://github.com/btford/write-good) |
|
||||
| Haskell | [ghc](https://www.haskell.org/ghc/), [stack-ghc](https://haskellstack.org/), [stack-build](https://haskellstack.org/) !!, [ghc-mod](https://github.com/DanielG/ghc-mod), [stack-ghc-mod](https://github.com/DanielG/ghc-mod), [hlint](https://hackage.haskell.org/package/hlint), [hdevtools](https://hackage.haskell.org/package/hdevtools) |
|
||||
| HTML | [HTMLHint](http://htmlhint.com/), [proselint](http://proselint.com/), [tidy](http://www.html-tidy.org/) |
|
||||
| Idris | [idris](http://www.idris-lang.org/) |
|
||||
| Java | [checkstyle](http://checkstyle.sourceforge.net), [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html), [google-java-format](https://github.com/google/google-java-format), [PMD](https://pmd.github.io/) |
|
||||
| JavaScript | [eslint](http://eslint.org/), [flow](https://flowtype.org/), [jscs](http://jscs.info/), [jshint](http://jshint.com/), [prettier](https://github.com/prettier/prettier), [prettier-eslint](https://github.com/prettier/prettier-eslint-cli), [prettier-standard](https://github.com/sheerun/prettier-standard), [standard](http://standardjs.com/), [xo](https://github.com/sindresorhus/xo)
|
||||
| JSON | [fixjson](https://github.com/rhysd/fixjson), [jsonlint](http://zaa.ch/jsonlint/), [jq](https://stedolan.github.io/jq/), [prettier](https://github.com/prettier/prettier) |
|
||||
| Java | [checkstyle](http://checkstyle.sourceforge.net), [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html) |
|
||||
| JavaScript | [eslint](http://eslint.org/), [jscs](http://jscs.info/), [jshint](http://jshint.com/), [flow](https://flowtype.org/), [prettier](https://github.com/prettier/prettier), prettier-eslint >= 4.2.0, prettier-standard, [standard](http://standardjs.com/), [xo](https://github.com/sindresorhus/xo)
|
||||
| JSON | [jsonlint](http://zaa.ch/jsonlint/), [prettier](https://github.com/prettier/prettier) |
|
||||
| Kotlin | [kotlinc](https://kotlinlang.org) !!, [ktlint](https://ktlint.github.io) !! see `:help ale-integration-kotlin` for configuration instructions |
|
||||
| LaTeX | [alex](https://github.com/wooorm/alex) !!, [chktex](http://www.nongnu.org/chktex/), [lacheck](https://www.ctan.org/pkg/lacheck), [proselint](http://proselint.com/), [redpen](http://redpen.cc/), [vale](https://github.com/ValeLint/vale), [write-good](https://github.com/btford/write-good) |
|
||||
| Less | [lessc](https://www.npmjs.com/package/less), [prettier](https://github.com/prettier/prettier), [stylelint](https://github.com/stylelint/stylelint) |
|
||||
| LaTeX | [chktex](http://www.nongnu.org/chktex/), [lacheck](https://www.ctan.org/pkg/lacheck), [proselint](http://proselint.com/) |
|
||||
| LLVM | [llc](https://llvm.org/docs/CommandGuide/llc.html) |
|
||||
| Lua | [luac](https://www.lua.org/manual/5.1/luac.html), [luacheck](https://github.com/mpeterv/luacheck) |
|
||||
| Mail | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [vale](https://github.com/ValeLint/vale) |
|
||||
| Make | [checkmake](https://github.com/mrtazz/checkmake) |
|
||||
| Markdown | [alex](https://github.com/wooorm/alex) !!, [markdownlint](https://github.com/DavidAnson/markdownlint) !!, [mdl](https://github.com/mivok/markdownlint), [prettier](https://github.com/prettier/prettier), [proselint](http://proselint.com/), [redpen](http://redpen.cc/), [remark-lint](https://github.com/wooorm/remark-lint) !!, [textlint](https://textlint.github.io/), [vale](https://github.com/ValeLint/vale), [write-good](https://github.com/btford/write-good) |
|
||||
| Lua | [luacheck](https://github.com/mpeterv/luacheck) |
|
||||
| Markdown | [mdl](https://github.com/mivok/markdownlint), [proselint](http://proselint.com/), [vale](https://github.com/ValeLint/vale), [remark-lint](https://github.com/wooorm/remark-lint) !! |
|
||||
| MATLAB | [mlint](https://www.mathworks.com/help/matlab/ref/mlint.html) |
|
||||
| Mercury | [mmc](http://mercurylang.org) !! |
|
||||
| NASM | [nasm](https://www.nasm.us/) !! |
|
||||
| Nim | [nim check](https://nim-lang.org/docs/nimc.html) !! |
|
||||
| nix | [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate) |
|
||||
| nroff | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good)|
|
||||
| nroff | [proselint](http://proselint.com/)|
|
||||
| Objective-C | [clang](http://clang.llvm.org/) |
|
||||
| Objective-C++ | [clang](http://clang.llvm.org/) |
|
||||
| OCaml | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-ocaml-merlin` for configuration instructions, [ols](https://github.com/freebroccolo/ocaml-language-server) |
|
||||
| Perl | [perl -c](https://perl.org/), [perl-critic](https://metacpan.org/pod/Perl::Critic), [perltidy](https://metacpan.org/pod/distribution/Perl-Tidy/bin/perltidy) |
|
||||
| PHP | [hack](http://hacklang.org/), [hackfmt](https://github.com/facebook/flow/tree/master/hack/hackfmt), [langserver](https://github.com/felixfbecker/php-language-server), [phan](https://github.com/phan/phan) see `:help ale-php-phan` to instructions, [php -l](https://secure.php.net/), [phpcs](https://github.com/squizlabs/PHP_CodeSniffer), [phpmd](https://phpmd.org), [phpstan](https://github.com/phpstan/phpstan), [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer), [php-cs-fixer](http://cs.sensiolabs.org/) |
|
||||
| PO | [alex](https://github.com/wooorm/alex) !!, [msgfmt](https://www.gnu.org/software/gettext/manual/html_node/msgfmt-Invocation.html), [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good) |
|
||||
| Pod | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good) |
|
||||
| Pony | [ponyc](https://github.com/ponylang/ponyc) |
|
||||
| proto | [protoc-gen-lint](https://github.com/ckaznocha/protoc-gen-lint) |
|
||||
| OCaml | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-ocaml-merlin` for configuration instructions |
|
||||
| Perl | [perl -c](https://perl.org/), [perl-critic](https://metacpan.org/pod/Perl::Critic) |
|
||||
| PHP | [hack](http://hacklang.org/), [langserver](https://github.com/felixfbecker/php-language-server), [php -l](https://secure.php.net/), [phpcs](https://github.com/squizlabs/PHP_CodeSniffer), [phpmd](https://phpmd.org), [phpstan](https://github.com/phpstan/phpstan), [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer) |
|
||||
| Pod | [proselint](http://proselint.com/)|
|
||||
| Pug | [pug-lint](https://github.com/pugjs/pug-lint) |
|
||||
| Puppet | [puppet](https://puppet.com), [puppet-lint](https://puppet-lint.com) |
|
||||
| Python | [autopep8](https://github.com/hhatto/autopep8), [black](https://github.com/ambv/black), [flake8](http://flake8.pycqa.org/en/latest/), [isort](https://github.com/timothycrosley/isort), [mypy](http://mypy-lang.org/), [prospector](http://github.com/landscapeio/prospector), [pycodestyle](https://github.com/PyCQA/pycodestyle), [pyls](https://github.com/palantir/python-language-server), [pylint](https://www.pylint.org/) !!, [yapf](https://github.com/google/yapf) |
|
||||
| QML | [qmlfmt](https://github.com/jesperhh/qmlfmt), [qmllint](https://github.com/qt/qtdeclarative/tree/5.11/tools/qmllint) |
|
||||
| Python | [autopep8](https://github.com/hhatto/autopep8), [flake8](http://flake8.pycqa.org/en/latest/), [isort](https://github.com/timothycrosley/isort), [mypy](http://mypy-lang.org/), [pycodestyle](https://github.com/PyCQA/pycodestyle), [pylint](https://www.pylint.org/) !!, [yapf](https://github.com/google/yapf) |
|
||||
| R | [lintr](https://github.com/jimhester/lintr) |
|
||||
| ReasonML | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-reasonml-ols` for configuration instructions, [ols](https://github.com/freebroccolo/ocaml-language-server), [refmt](https://github.com/reasonml/reason-cli) |
|
||||
| reStructuredText | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [redpen](http://redpen.cc/), [rstcheck](https://github.com/myint/rstcheck), [vale](https://github.com/ValeLint/vale), [write-good](https://github.com/btford/write-good) |
|
||||
| Re:VIEW | [redpen](http://redpen.cc/) |
|
||||
| ReasonML | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-integration-reason-merlin` for configuration instructions |
|
||||
| reStructuredText | [proselint](http://proselint.com/) |
|
||||
| RPM spec | [rpmlint](https://github.com/rpm-software-management/rpmlint) (disabled by default; see `:help ale-integration-spec`) |
|
||||
| Ruby | [brakeman](http://brakemanscanner.org/) !!, [rails_best_practices](https://github.com/flyerhzm/rails_best_practices) !!, [reek](https://github.com/troessner/reek), [rubocop](https://github.com/bbatsov/rubocop), [ruby](https://www.ruby-lang.org), [rufo](https://github.com/ruby-formatter/rufo) |
|
||||
| Rust | cargo !! (see `:help ale-integration-rust` for configuration instructions), [rls](https://github.com/rust-lang-nursery/rls), [rustc](https://www.rust-lang.org/), [rustfmt](https://github.com/rust-lang-nursery/rustfmt) |
|
||||
| Ruby | [brakeman](http://brakemanscanner.org/) !!, [rails_best_practices](https://github.com/flyerhzm/rails_best_practices) !!, [reek](https://github.com/troessner/reek), [rubocop](https://github.com/bbatsov/rubocop), [ruby](https://www.ruby-lang.org) |
|
||||
| Rust | cargo !! (see `:help ale-integration-rust` for configuration instructions), [rls](https://github.com/rust-lang-nursery/rls), [rustc](https://www.rust-lang.org/) |
|
||||
| SASS | [sass-lint](https://www.npmjs.com/package/sass-lint), [stylelint](https://github.com/stylelint/stylelint) |
|
||||
| SCSS | [prettier](https://github.com/prettier/prettier), [sass-lint](https://www.npmjs.com/package/sass-lint), [scss-lint](https://github.com/brigade/scss-lint), [stylelint](https://github.com/stylelint/stylelint) |
|
||||
| Scala | [fsc](https://www.scala-lang.org/old/sites/default/files/linuxsoft_archives/docu/files/tools/fsc.html), [scalac](http://scala-lang.org), [scalastyle](http://www.scalastyle.org) |
|
||||
| SCSS | [sass-lint](https://www.npmjs.com/package/sass-lint), [scss-lint](https://github.com/brigade/scss-lint), [stylelint](https://github.com/stylelint/stylelint), [prettier](https://github.com/prettier/prettier) |
|
||||
| Scala | [scalac](http://scala-lang.org), [scalastyle](http://www.scalastyle.org) |
|
||||
| Slim | [slim-lint](https://github.com/sds/slim-lint) |
|
||||
| SML | [smlnj](http://www.smlnj.org/) |
|
||||
| Solidity | [solhint](https://github.com/protofire/solhint), [solium](https://github.com/duaraghav8/Solium) |
|
||||
| Solidity | [solium](https://github.com/duaraghav8/Solium) |
|
||||
| Stylus | [stylelint](https://github.com/stylelint/stylelint) |
|
||||
| SQL | [sqlint](https://github.com/purcell/sqlint) |
|
||||
| Swift | [swiftlint](https://github.com/realm/SwiftLint), [swiftformat](https://github.com/nicklockwood/SwiftFormat) |
|
||||
| Tcl | [nagelfar](http://nagelfar.sourceforge.net) !! |
|
||||
| Terraform | [tflint](https://github.com/wata727/tflint) |
|
||||
| Texinfo | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good)|
|
||||
| Text^ | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [redpen](http://redpen.cc/), [textlint](https://textlint.github.io/), [vale](https://github.com/ValeLint/vale), [write-good](https://github.com/btford/write-good) |
|
||||
| Texinfo | [proselint](http://proselint.com/)|
|
||||
| Text^ | [proselint](http://proselint.com/), [vale](https://github.com/ValeLint/vale) |
|
||||
| Thrift | [thrift](http://thrift.apache.org/) |
|
||||
| TypeScript | [eslint](http://eslint.org/), [prettier](https://github.com/prettier/prettier), [tslint](https://github.com/palantir/tslint), tsserver, typecheck |
|
||||
| TypeScript | [eslint](http://eslint.org/), [tslint](https://github.com/palantir/tslint), tsserver, typecheck, [prettier](https://github.com/prettier/prettier) |
|
||||
| Verilog | [iverilog](https://github.com/steveicarus/iverilog), [verilator](http://www.veripool.org/projects/verilator/wiki/Intro) |
|
||||
| Vim | [vint](https://github.com/Kuniwak/vint) |
|
||||
| Vim help^ | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good) |
|
||||
| Vue | [prettier](https://github.com/prettier/prettier) |
|
||||
| XHTML | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good) |
|
||||
| XML | [xmllint](http://xmlsoft.org/xmllint.html) |
|
||||
| Vim help^ | [proselint](http://proselint.com/)|
|
||||
| XHTML | [proselint](http://proselint.com/)|
|
||||
| XML | [xmllint](http://xmlsoft.org/xmllint.html)|
|
||||
| YAML | [swaglint](https://github.com/byCedric/swaglint), [yamllint](https://yamllint.readthedocs.io/) |
|
||||
|
||||
<a name="usage"></a>
|
||||
@@ -210,42 +175,24 @@ ale-linter-options` for options specified to particular linters.
|
||||
### 2.ii Fixing
|
||||
|
||||
ALE can fix files with the `ALEFix` command. Functions need to be configured
|
||||
either in each buffer with a `b:ale_fixers`, or globally with `g:ale_fixers`.
|
||||
|
||||
The recommended way to configure fixers is to define a List in an ftplugin file.
|
||||
for different filetypes with the `g:ale_fixers` variable. For example, the
|
||||
following code can be used to fix JavaScript code with ESLint:
|
||||
|
||||
```vim
|
||||
" In ~/.vim/ftplugin/javascript.vim, or somewhere similar.
|
||||
|
||||
" Fix files with prettier, and then ESLint.
|
||||
let b:ale_fixers = ['prettier', 'eslint']
|
||||
" Equivalent to the above.
|
||||
let b:ale_fixers = {'javascript': ['prettier', 'eslint']}
|
||||
```
|
||||
|
||||
You can also configure your fixers from vimrc using `g:ale_fixers`, before
|
||||
or after ALE has been loaded.
|
||||
|
||||
```vim
|
||||
" In ~/.vim/vimrc, or somewhere similar.
|
||||
" Put this in vimrc or a plugin file of your own.
|
||||
" After this is configured, :ALEFix will try and fix your JS code with ESLint.
|
||||
let g:ale_fixers = {
|
||||
\ 'javascript': ['eslint'],
|
||||
\}
|
||||
```
|
||||
|
||||
If you want to automatically fix files when you save them, you need to turn
|
||||
a setting on in vimrc.
|
||||
|
||||
```vim
|
||||
" Set this variable to 1 to fix files when you save them.
|
||||
" Set this setting in vimrc if you want to fix files automatically on save.
|
||||
" This is off by default.
|
||||
let g:ale_fix_on_save = 1
|
||||
```
|
||||
|
||||
The `:ALEFixSuggest` command will suggest some supported tools for fixing code.
|
||||
Both `g:ale_fixers` and `b:ale_fixers` can also accept functions, including
|
||||
lambda functions, as fixers, for fixing files with custom tools.
|
||||
|
||||
See `:help ale-fix` for complete information on how to fix files with ALE.
|
||||
The `:ALEFixSuggest` command will suggest some supported tools for fixing code,
|
||||
but fixers can be also implemented with functions, including lambda functions
|
||||
too. See `:help ale-fix` for detailed information.
|
||||
|
||||
<a name="usage-completion"></a>
|
||||
|
||||
@@ -253,7 +200,9 @@ See `:help ale-fix` for complete information on how to fix files with ALE.
|
||||
|
||||
ALE offers some support for completion via hijacking of omnicompletion while you
|
||||
type. All of ALE's completion information must come from Language Server
|
||||
Protocol linters, or from `tsserver` for TypeSript.
|
||||
Protocol linters, or similar protocols. At the moment, completion is only
|
||||
supported for TypeScript code with `tsserver`, when `tsserver` is enabled. You
|
||||
can enable completion like so:
|
||||
|
||||
```vim
|
||||
" Enable completion where available.
|
||||
@@ -262,39 +211,6 @@ let g:ale_completion_enabled = 1
|
||||
|
||||
See `:help ale-completion` for more information.
|
||||
|
||||
<a name="usage-go-to-definition"></a>
|
||||
|
||||
### 2.iv Go To Definition
|
||||
|
||||
ALE supports jumping to the definition of words under your cursor with the
|
||||
`:ALEGoToDefinition` command using any enabled Language Server Protocol linters
|
||||
and `tsserver`.
|
||||
|
||||
See `:help ale-go-to-definition` for more information.
|
||||
|
||||
<a name="usage-find-references"></a>
|
||||
|
||||
### 2.v Find References
|
||||
|
||||
ALE supports finding references for words under your cursor with the
|
||||
`:ALEFindReferences` command using any enabled Language Server Protocol linters
|
||||
and `tsserver`.
|
||||
|
||||
See `:help ale-find-references` for more information.
|
||||
|
||||
<a name="usage-hover"></a>
|
||||
|
||||
### 2.vi Hovering
|
||||
|
||||
ALE supports "hover" information for printing brief information about symbols at
|
||||
the cursor taken from Language Server Protocol linters and `tsserver` with the
|
||||
`ALEHover` command.
|
||||
|
||||
On vim/gvim with `balloon` support you can see the information in a tooltip
|
||||
that appears under the mouse when you mouseover a symbol.
|
||||
|
||||
See `:help ale-hover` for more information.
|
||||
|
||||
<a name="installation"></a>
|
||||
|
||||
## 3. Installation
|
||||
@@ -403,28 +319,12 @@ on Freenode. Web chat is available [here](https://webchat.freenode.net/?channels
|
||||
|
||||
### 5.i. How do I disable particular linters?
|
||||
|
||||
By default, all available tools for all supported languages will be run. If you
|
||||
want to only select a subset of the tools, you can define `b:ale_linters` for a
|
||||
single buffer, or `g:ale_linters` globally.
|
||||
|
||||
The recommended way to configure linters is to define a List in an ftplugin
|
||||
file.
|
||||
By default, all available tools for all supported languages will be run.
|
||||
If you want to only select a subset of the tools, simply create a
|
||||
`g:ale_linters` dictionary in your vimrc file mapping filetypes
|
||||
to lists of linters to run.
|
||||
|
||||
```vim
|
||||
" In ~/.vim/ftplugin/javascript.vim, or somewhere similar.
|
||||
|
||||
" Enable ESLint only for JavaScript.
|
||||
let b:ale_linters = ['eslint']
|
||||
|
||||
" Equivalent to the above.
|
||||
let b:ale_linters = {'javascript': ['eslint']}
|
||||
```
|
||||
|
||||
You can also declare which linters you want to run in your vimrc file, before or
|
||||
after ALE has been loaded.
|
||||
|
||||
```vim
|
||||
" In ~/.vim/vimrc, or somewhere similar.
|
||||
let g:ale_linters = {
|
||||
\ 'javascript': ['eslint'],
|
||||
\}
|
||||
@@ -435,14 +335,6 @@ be run for those languages, just as when the dictionary is not defined.
|
||||
Running many linters should not typically obstruct editing in Vim,
|
||||
as they will all be executed in separate processes simultaneously.
|
||||
|
||||
If you don't want ALE to run anything other than what you've explicitly asked
|
||||
for, you can set `g:ale_linters_explicit` to `1`.
|
||||
|
||||
```vim
|
||||
" Only run linters named in ale_linters settings.
|
||||
let g:ale_linters_explicit = 1
|
||||
```
|
||||
|
||||
This plugin will look for linters in the [`ale_linters`](ale_linters) directory.
|
||||
Each directory within corresponds to a particular filetype in Vim, and each file
|
||||
in each directory corresponds to the name of a particular linter.
|
||||
@@ -478,35 +370,9 @@ highlight clear ALEErrorSign
|
||||
highlight clear ALEWarningSign
|
||||
```
|
||||
|
||||
<a name="faq-change-highlights"></a>
|
||||
|
||||
### 5.iv. How can I change or disable the highlights ALE uses?
|
||||
|
||||
ALE's highlights problems with highlight groups which link to `SpellBad`,
|
||||
`SpellCap`, `error`, and `todo` groups by default. The characters that are
|
||||
highlighted depend on the linters being used, and the information provided to
|
||||
ALE.
|
||||
|
||||
Highlighting can be disabled completely by setting `g:ale_set_highlights` to
|
||||
`0`.
|
||||
|
||||
```vim
|
||||
" Set this in your vimrc file to disabling highlighting
|
||||
let g:ale_set_highlights = 0
|
||||
```
|
||||
|
||||
You can control all of the highlights ALE uses, say if you are using a different
|
||||
color scheme which produces ugly highlights. For example:
|
||||
|
||||
```vim
|
||||
highlight ALEWarning ctermbg=DarkMagenta
|
||||
```
|
||||
|
||||
See `:help ale-highlights` for more information.
|
||||
|
||||
<a name="faq-statusline"></a>
|
||||
|
||||
### 5.v. How can I show errors or warnings in my statusline?
|
||||
### 5.iv. How can I show errors or warnings in my statusline?
|
||||
|
||||
[vim-airline](https://github.com/vim-airline/vim-airline) integrates with ALE
|
||||
for displaying error information in the status bar. If you want to see the
|
||||
@@ -546,23 +412,73 @@ See `:help ale#statusline#Count()` for more information.
|
||||
|
||||
<a name="faq-lightline"></a>
|
||||
|
||||
### 5.vi. How can I show errors or warnings in my lightline?
|
||||
### 5.v. How can I show errors or warnings in my lightline?
|
||||
|
||||
[lightline](https://github.com/itchyny/lightline.vim) does not have built-in
|
||||
support for ALE, nevertheless there is a plugin that adds this functionality: [maximbaz/lightline-ale](https://github.com/maximbaz/lightline-ale).
|
||||
support for ALE, nevertheless it's easy to do it yourself:
|
||||
|
||||
For more information, check out the sources of that plugin, `:help ale#statusline#Count()` and [lightline documentation](https://github.com/itchyny/lightline.vim#advanced-configuration).
|
||||
```vim
|
||||
" This is regular lightline configuration, we just added
|
||||
" 'linter_warnings', 'linter_errors' and 'linter_ok' to
|
||||
" the active right panel. Feel free to move it anywhere.
|
||||
" `component_expand' and `component_type' are required.
|
||||
"
|
||||
" For more info on how this works, see lightline documentation.
|
||||
let g:lightline = {
|
||||
\ 'active': {
|
||||
\ 'right': [ [ 'lineinfo' ],
|
||||
\ [ 'percent' ],
|
||||
\ [ 'linter_warnings', 'linter_errors', 'linter_ok' ],
|
||||
\ [ 'fileformat', 'fileencoding', 'filetype' ] ]
|
||||
\ },
|
||||
\ 'component_expand': {
|
||||
\ 'linter_warnings': 'LightlineLinterWarnings',
|
||||
\ 'linter_errors': 'LightlineLinterErrors',
|
||||
\ 'linter_ok': 'LightlineLinterOK'
|
||||
\ },
|
||||
\ 'component_type': {
|
||||
\ 'linter_warnings': 'warning',
|
||||
\ 'linter_errors': 'error',
|
||||
\ 'linter_ok': 'ok'
|
||||
\ },
|
||||
\ }
|
||||
|
||||
autocmd User ALELint call lightline#update()
|
||||
|
||||
" ale + lightline
|
||||
function! LightlineLinterWarnings() abort
|
||||
let l:counts = ale#statusline#Count(bufnr(''))
|
||||
let l:all_errors = l:counts.error + l:counts.style_error
|
||||
let l:all_non_errors = l:counts.total - l:all_errors
|
||||
return l:counts.total == 0 ? '' : printf('%d --', all_non_errors)
|
||||
endfunction
|
||||
|
||||
function! LightlineLinterErrors() abort
|
||||
let l:counts = ale#statusline#Count(bufnr(''))
|
||||
let l:all_errors = l:counts.error + l:counts.style_error
|
||||
let l:all_non_errors = l:counts.total - l:all_errors
|
||||
return l:counts.total == 0 ? '' : printf('%d >>', all_errors)
|
||||
endfunction
|
||||
|
||||
function! LightlineLinterOK() abort
|
||||
let l:counts = ale#statusline#Count(bufnr(''))
|
||||
let l:all_errors = l:counts.error + l:counts.style_error
|
||||
let l:all_non_errors = l:counts.total - l:all_errors
|
||||
return l:counts.total == 0 ? '✓' : ''
|
||||
endfunction
|
||||
```
|
||||
|
||||
See `:help ale#statusline#Count()` and [lightline documentation](https://github.com/itchyny/lightline.vim#advanced-configuration)
|
||||
for more information.
|
||||
|
||||
<a name="faq-echo-format"></a>
|
||||
|
||||
### 5.vii. How can I change the format for echo messages?
|
||||
### 5.vi. How can I change the format for echo messages?
|
||||
|
||||
There are 3 global options that allow customizing the echoed message.
|
||||
|
||||
- `g:ale_echo_msg_format` where:
|
||||
* `%s` is the error message itself
|
||||
* `%...code...%` is an optional error code, and most characters can be
|
||||
written between the `%` characters.
|
||||
* `%linter%` is the linter name
|
||||
* `%severity` is the severity type
|
||||
- `g:ale_echo_msg_error_str` is the string used for error severity.
|
||||
@@ -580,34 +496,24 @@ Will give you:
|
||||
|
||||

|
||||
|
||||
See `:help g:ale_echo_msg_format` for more information.
|
||||
|
||||
<a name="faq-autocmd"></a>
|
||||
|
||||
### 5.viii. How can I execute some code when ALE starts or stops linting?
|
||||
### 5.vii. How can I execute some code when ALE stops linting?
|
||||
|
||||
ALE runs its own [autocmd](http://vimdoc.sourceforge.net/htmldoc/autocmd.html)
|
||||
events when a lint or fix cycle are started and stopped. There is also an event
|
||||
that runs when a linter job has been successfully started. These events can be
|
||||
used to call arbitrary functions during these respective parts of the ALE's
|
||||
operation.
|
||||
event whenever has a linter has been successfully executed and processed. This
|
||||
autocmd event can be used to call arbitrary functions after ALE stops linting.
|
||||
|
||||
```vim
|
||||
augroup YourGroup
|
||||
autocmd!
|
||||
autocmd User ALELintPre call YourFunction()
|
||||
autocmd User ALELintPost call YourFunction()
|
||||
|
||||
autocmd User ALEJobStarted call YourFunction()
|
||||
|
||||
autocmd User ALEFixPre call YourFunction()
|
||||
autocmd User ALEFixPost call YourFunction()
|
||||
autocmd User ALELint call YourFunction()
|
||||
augroup END
|
||||
```
|
||||
|
||||
<a name="faq-navigation"></a>
|
||||
|
||||
### 5.ix. How can I navigate between errors quickly?
|
||||
### 5.viii. How can I navigate between errors quickly?
|
||||
|
||||
ALE offers some commands with `<Plug>` keybinds for moving between warnings and
|
||||
errors quickly. You can map the keys Ctrl+j and Ctrl+k to moving between errors
|
||||
@@ -623,7 +529,7 @@ For more information, consult the online documentation with
|
||||
|
||||
<a name="faq-lint-on-save"></a>
|
||||
|
||||
### 5.x. How can I run linters only when I save files?
|
||||
### 5.ix. How can I run linters only when I save files?
|
||||
|
||||
ALE offers an option `g:ale_lint_on_save` for enabling running the linters
|
||||
when files are saved. This option is enabled by default. If you only
|
||||
@@ -643,7 +549,7 @@ files, you can set `g:ale_lint_on_save` to `0`.
|
||||
|
||||
<a name="faq-quickfix"></a>
|
||||
|
||||
### 5.xi. How can I use the quickfix list instead of the loclist?
|
||||
### 5.x. How can I use the quickfix list instead of the loclist?
|
||||
|
||||
The quickfix list can be enabled by turning the `g:ale_set_quickfix`
|
||||
option on. If you wish to also disable the loclist, you can disable
|
||||
@@ -668,12 +574,9 @@ let g:ale_open_list = 1
|
||||
let g:ale_keep_list_window_open = 1
|
||||
```
|
||||
|
||||
You can also set `let g:ale_list_vertical = 1` to open the windows vertically
|
||||
instead of the default horizontally.
|
||||
|
||||
<a name="faq-jsx-stylelint-eslint"></a>
|
||||
|
||||
### 5.xii. How can I check JSX files with both stylelint and eslint?
|
||||
### 5.xi. How can I check JSX files with both stylelint and eslint?
|
||||
|
||||
If you configure ALE options correctly in your vimrc file, and install
|
||||
the right tools, you can check JSX files with stylelint and eslint.
|
||||
@@ -692,18 +595,9 @@ augroup END
|
||||
```
|
||||
|
||||
Supposing the filetype has been set correctly, you can set the following
|
||||
options in a jsx.vim ftplugin file.
|
||||
options in your vimrc file:
|
||||
|
||||
```vim
|
||||
" In ~/.vim/ftplugin/jsx.vim, or somewhere similar.
|
||||
let b:ale_linters = ['stylelint', 'eslint']
|
||||
let b:ale_linter_aliases = ['css']
|
||||
```
|
||||
|
||||
Or if you want, you can configure the linters from your vimrc file.
|
||||
|
||||
```vim
|
||||
" In ~/.vim/vimrc, or somewhere similar.
|
||||
let g:ale_linters = {'jsx': ['stylelint', 'eslint']}
|
||||
let g:ale_linter_aliases = {'jsx': 'css'}
|
||||
```
|
||||
@@ -715,7 +609,7 @@ no linter will be run twice for the same file.
|
||||
|
||||
<a name="faq-my-battery-is-sad"></a>
|
||||
|
||||
### 5.xiii. Will this plugin eat all of my laptop battery power?
|
||||
### 5.xii. Will this plugin eat all of my laptop battery power?
|
||||
|
||||
ALE takes advantage of the power of various tools to check your code. This of
|
||||
course means that CPU time will be used to continuously check your code. If you
|
||||
@@ -737,75 +631,3 @@ still be an advantage.
|
||||
If you are still concerned, you can turn the automatic linting off altogether,
|
||||
including the option `g:ale_lint_on_enter`, and you can run ALE manually with
|
||||
`:ALELint`.
|
||||
|
||||
<a name="faq-c-configuration"></a>
|
||||
|
||||
### 5.xiv. How can I configure my C or C++ project?
|
||||
|
||||
The structure of C and C++ projects varies wildly from project to project, with
|
||||
many different build tools being used for building them, and many different
|
||||
formats for project configuration files. ALE can run compilers easily, but
|
||||
ALE cannot easily detect which compiler flags to use.
|
||||
|
||||
Some tools and build configurations can generate
|
||||
[compile_commands.json](https://clang.llvm.org/docs/JSONCompilationDatabase.html)
|
||||
files. The `cppcheck`, `clangcheck` and `clangtidy` linters can read these
|
||||
files for automatically determining the appropriate compiler flags to use.
|
||||
|
||||
For linting with compilers like `gcc` and `clang`, and with other tools, you
|
||||
will need to tell ALE which compiler flags to use yourself. You can use
|
||||
different options for different projects with the `g:ale_pattern_options`
|
||||
setting. Consult the documentation for that setting for more information.
|
||||
`b:ale_linters` can be used to select which tools you want to run, say if you
|
||||
want to use only `gcc` for one project, and only `clang` for another.
|
||||
|
||||
You may also configure buffer-local settings for linters with project-specific
|
||||
vimrc files. [local_vimrc](https://github.com/LucHermitte/local_vimrc) can be
|
||||
used for executing local vimrc files which can be shared in your project.
|
||||
|
||||
<a name="faq-buffer-configuration"></a>
|
||||
|
||||
### 5.xv. How can I configure ALE differently for different buffers?
|
||||
|
||||
ALE offers various ways to configure which linters or fixers are run, and
|
||||
other settings. For the majority of ALE's settings, they can either be
|
||||
configured globally with a `g:` variable prefix, or for a specific buffer
|
||||
with a `b:` variable prefix. For example, you can configure a Python ftplugin
|
||||
file like so.
|
||||
|
||||
```vim
|
||||
" In ~/.vim/ftplugin/python.vim
|
||||
|
||||
" Check Python files with flake8 and pylint.
|
||||
let b:ale_linters = ['flake8', 'pylint']
|
||||
" Fix Python files with autopep8 and yapf.
|
||||
let b:ale_fixers = ['autopep8', 'yapf']
|
||||
" Disable warnings about trailing whitespace for Python files.
|
||||
let b:ale_warn_about_trailing_whitespace = 0
|
||||
```
|
||||
|
||||
For configuring files based on regular expression patterns matched against the
|
||||
absolute path to a file, you can use `g:ale_pattern_options`.
|
||||
|
||||
```vim
|
||||
" Do not lint or fix minified files.
|
||||
let g:ale_pattern_options = {
|
||||
\ '\.min\.js$': {'ale_linters': [], 'ale_fixers': []},
|
||||
\ '\.min\.css$': {'ale_linters': [], 'ale_fixers': []},
|
||||
\}
|
||||
" If you configure g:ale_pattern_options outside of vimrc, you need this.
|
||||
let g:ale_pattern_options_enabled = 1
|
||||
```
|
||||
|
||||
Buffer-local variables for settings always override the global settings.
|
||||
|
||||
<a name="faq-list-window-height"></a>
|
||||
|
||||
### 5.xvi. How can I configure the height of the list in which ALE displays errors?
|
||||
|
||||
To set a default height for the error list, use the `g:ale_list_window_size` variable.
|
||||
|
||||
```vim
|
||||
" Show 5 lines of errors (default: 10)
|
||||
let g:ale_list_window_size = 5
|
||||
```
|
||||
|
||||
37
after/plugin/ale.vim
Normal file
37
after/plugin/ale.vim
Normal file
@@ -0,0 +1,37 @@
|
||||
" Author: w0rp <devw0rp@gmail.com>
|
||||
" Description: Follow-up checks for the plugin: warn about conflicting plugins.
|
||||
|
||||
" A flag for ensuring that this is not run more than one time.
|
||||
if exists('g:loaded_ale_after')
|
||||
finish
|
||||
endif
|
||||
|
||||
" Set the flag so this file is not run more than one time.
|
||||
let g:loaded_ale_after = 1
|
||||
|
||||
" Check if the flag is available and set to 0 to disable checking for and
|
||||
" emitting conflicting plugin warnings.
|
||||
if exists('g:ale_emit_conflict_warnings') && !g:ale_emit_conflict_warnings
|
||||
finish
|
||||
endif
|
||||
|
||||
" Conflicting Plugins Checks
|
||||
|
||||
function! s:GetConflictingPluginWarning(plugin_name) abort
|
||||
return 'ALE conflicts with ' . a:plugin_name
|
||||
\ . '. Uninstall it, or disable this warning with '
|
||||
\ . '`let g:ale_emit_conflict_warnings = 0` in your vimrc file, '
|
||||
\ . '*before* plugins are loaded.'
|
||||
endfunction
|
||||
|
||||
if exists('g:loaded_syntastic_plugin')
|
||||
throw s:GetConflictingPluginWarning('Syntastic')
|
||||
endif
|
||||
|
||||
if exists('g:loaded_neomake')
|
||||
throw s:GetConflictingPluginWarning('Neomake')
|
||||
endif
|
||||
|
||||
if exists('g:loaded_validator_plugin')
|
||||
throw s:GetConflictingPluginWarning('Validator')
|
||||
endif
|
||||
@@ -21,7 +21,7 @@ function! ale_linters#ansible#ansible_lint#Handle(buffer, lines) abort
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:code = l:match[4]
|
||||
|
||||
if l:code is# 'EANSIBLE0002'
|
||||
if l:code is# 'EANSIBLE002'
|
||||
\&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
|
||||
" Skip warnings for trailing whitespace if the option is off.
|
||||
continue
|
||||
@@ -31,8 +31,7 @@ function! ale_linters#ansible#ansible_lint#Handle(buffer, lines) abort
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'col': l:match[3] + 0,
|
||||
\ 'text': l:match[5],
|
||||
\ 'code': l:code,
|
||||
\ 'text': l:code . ': ' . l:match[5],
|
||||
\ 'type': l:code[:0] is# 'E' ? 'E' : 'W',
|
||||
\})
|
||||
endif
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
" Author: nametake https://nametake.github.io
|
||||
" Description: apiblueprint parser
|
||||
|
||||
function! ale_linters#apiblueprint#drafter#HandleErrors(buffer, lines) abort
|
||||
" Matches patterns line the following:
|
||||
"
|
||||
" warning: (3) unable to parse response signature, expected 'response [<HTTP status code>] [(<media type>)]'; line 4, column 3k - line 4, column 22
|
||||
" warning: (10) message-body asset is expected to be a pre-formatted code block, separate it by a newline and indent every of its line by 12 spaces or 3 tabs; line 30, column 5 - line 30, column 9; line 31, column 9 - line 31, column 14; line 32, column 9 - line 32, column 14
|
||||
let l:pattern = '\(^.*\): (\d\+) \(.\{-\}\); line \(\d\+\), column \(\d\+\) - line \d\+, column \d\+\(.*; line \d\+, column \d\+ - line \(\d\+\), column \(\d\+\)\)\{-\}$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines[2:], l:pattern)
|
||||
let l:item = {
|
||||
\ 'type': l:match[1] is# 'warning' ? 'W' : 'E',
|
||||
\ 'text': l:match[2],
|
||||
\ 'lnum': l:match[3] + 0,
|
||||
\ 'col': l:match[4] + 0,
|
||||
\}
|
||||
if l:match[5] isnot# ''
|
||||
let l:item.end_lnum = l:match[6] + 0
|
||||
let l:item.end_col = l:match[7] + 0
|
||||
endif
|
||||
call add(l:output, l:item)
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
|
||||
call ale#linter#Define('apiblueprint', {
|
||||
\ 'name': 'drafter',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': 'drafter',
|
||||
\ 'command': 'drafter --use-line-num --validate %t',
|
||||
\ 'callback': 'ale_linters#apiblueprint#drafter#HandleErrors',
|
||||
\})
|
||||
@@ -1,11 +0,0 @@
|
||||
" Author: Johannes Wienke <languitar@semipol.de>
|
||||
" Description: alex for asciidoc files
|
||||
|
||||
call ale#linter#Define('help', {
|
||||
\ 'name': 'alex',
|
||||
\ 'executable': 'alex',
|
||||
\ 'command': 'alex %s -t',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'callback': 'ale#handlers#alex#Handle',
|
||||
\ 'lint_file': 1,
|
||||
\})
|
||||
@@ -1,9 +0,0 @@
|
||||
" Author: rhysd https://rhysd.github.io
|
||||
" Description: Redpen, a proofreading tool (http://redpen.cc)
|
||||
|
||||
call ale#linter#Define('asciidoc', {
|
||||
\ 'name': 'redpen',
|
||||
\ 'executable': 'redpen',
|
||||
\ 'command': 'redpen -f asciidoc -r json %t',
|
||||
\ 'callback': 'ale#handlers#redpen#HandleRedpenOutput',
|
||||
\})
|
||||
@@ -1,9 +0,0 @@
|
||||
" Author: Sumner Evans <sumner.evans98@gmail.com>
|
||||
" Description: write-good for AsciiDoc files
|
||||
|
||||
call ale#linter#Define('asciidoc', {
|
||||
\ 'name': 'write-good',
|
||||
\ 'executable_callback': 'ale#handlers#writegood#GetExecutable',
|
||||
\ 'command_callback': 'ale#handlers#writegood#GetCommand',
|
||||
\ 'callback': 'ale#handlers#writegood#Handle',
|
||||
\})
|
||||
@@ -1,16 +1,10 @@
|
||||
" Author: Lucas Kolstad <lkolstad@uw.edu>
|
||||
" Description: gcc linter for asm files
|
||||
|
||||
call ale#Set('asm_gcc_executable', 'gcc')
|
||||
call ale#Set('asm_gcc_options', '-Wall')
|
||||
|
||||
function! ale_linters#asm#gcc#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'asm_gcc_executable')
|
||||
endfunction
|
||||
let g:ale_asm_gcc_options = get(g:, 'ale_asm_gcc_options', '-Wall')
|
||||
|
||||
function! ale_linters#asm#gcc#GetCommand(buffer) abort
|
||||
return ale#Escape(ale_linters#asm#gcc#GetExecutable(a:buffer))
|
||||
\ . ' -x assembler -fsyntax-only '
|
||||
return 'gcc -x assembler -fsyntax-only '
|
||||
\ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
|
||||
\ . ' ' . ale#Var(a:buffer, 'asm_gcc_options') . ' -'
|
||||
endfunction
|
||||
@@ -33,7 +27,7 @@ endfunction
|
||||
call ale#linter#Define('asm', {
|
||||
\ 'name': 'gcc',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable_callback': 'ale_linters#asm#gcc#GetExecutable',
|
||||
\ 'executable': 'gcc',
|
||||
\ 'command_callback': 'ale_linters#asm#gcc#GetCommand',
|
||||
\ 'callback': 'ale_linters#asm#gcc#Handle',
|
||||
\})
|
||||
|
||||
@@ -12,11 +12,7 @@ function! ale_linters#awk#gawk#GetExecutable(buffer) abort
|
||||
endfunction
|
||||
|
||||
function! ale_linters#awk#gawk#GetCommand(buffer) abort
|
||||
" note the --source 'BEGIN ...' is to prevent
|
||||
" gawk from attempting to execute the body of the script
|
||||
" it is linting.
|
||||
return ale_linters#awk#gawk#GetExecutable(a:buffer)
|
||||
\ . " --source 'BEGIN { exit } END { exit 1 }'"
|
||||
\ . ' ' . ale#Var(a:buffer, 'awk_gawk_options')
|
||||
\ . ' ' . '-f %t --lint /dev/null'
|
||||
endfunction
|
||||
@@ -25,6 +21,6 @@ call ale#linter#Define('awk', {
|
||||
\ 'name': 'gawk',
|
||||
\ 'executable_callback': 'ale_linters#awk#gawk#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#awk#gawk#GetCommand',
|
||||
\ 'callback': 'ale#handlers#gawk#HandleGawkFormat',
|
||||
\ 'callback': 'ale#handlers#cpplint#HandleCppLintFormat',
|
||||
\ 'output_stream': 'both'
|
||||
\})
|
||||
|
||||
@@ -8,15 +8,15 @@ function! ale_linters#c#clang#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'c_clang_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#c#clang#GetCommand(buffer, output) abort
|
||||
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
|
||||
function! ale_linters#c#clang#GetCommand(buffer) abort
|
||||
let l:paths = ale#c#FindLocalHeaderPaths(a:buffer)
|
||||
|
||||
" -iquote with the directory the file is in makes #include work for
|
||||
" headers in the same directory.
|
||||
return ale#Escape(ale_linters#c#clang#GetExecutable(a:buffer))
|
||||
\ . ' -S -x c -fsyntax-only '
|
||||
\ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) . ' '
|
||||
\ . l:cflags
|
||||
\ . ale#c#IncludeOptions(l:paths)
|
||||
\ . ale#Var(a:buffer, 'c_clang_options') . ' -'
|
||||
endfunction
|
||||
|
||||
@@ -24,9 +24,6 @@ call ale#linter#Define('c', {
|
||||
\ 'name': 'clang',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable_callback': 'ale_linters#c#clang#GetExecutable',
|
||||
\ 'command_chain': [
|
||||
\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
|
||||
\ {'callback': 'ale_linters#c#clang#GetCommand'}
|
||||
\ ],
|
||||
\ 'command_callback': 'ale_linters#c#clang#GetCommand',
|
||||
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
||||
\})
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
" Author: Christian Gibbons <cgibbons@gmu.edu>
|
||||
" Description: flawfinder linter for c files
|
||||
|
||||
call ale#Set('c_flawfinder_executable', 'flawfinder')
|
||||
call ale#Set('c_flawfinder_options', '')
|
||||
call ale#Set('c_flawfinder_minlevel', 1)
|
||||
call ale#Set('c_flawfinder_error_severity', 6)
|
||||
|
||||
function! ale_linters#c#flawfinder#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'c_flawfinder_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#c#flawfinder#GetCommand(buffer) abort
|
||||
|
||||
" Set the minimum vulnerability level for flawfinder to bother with
|
||||
let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'c_flawfinder_minlevel')
|
||||
|
||||
return ale#Escape(ale_linters#c#flawfinder#GetExecutable(a:buffer))
|
||||
\ . ' -CDQS'
|
||||
\ . ale#Var(a:buffer, 'c_flawfinder_options')
|
||||
\ . l:minlevel
|
||||
\ . ' %t'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('c', {
|
||||
\ 'name': 'flawfinder',
|
||||
\ 'output_stream': 'stdout',
|
||||
\ 'executable_callback': 'ale_linters#c#flawfinder#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#c#flawfinder#GetCommand',
|
||||
\ 'callback': 'ale#handlers#flawfinder#HandleFlawfinderFormat',
|
||||
\})
|
||||
@@ -8,15 +8,15 @@ function! ale_linters#c#gcc#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'c_gcc_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#c#gcc#GetCommand(buffer, output) abort
|
||||
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
|
||||
function! ale_linters#c#gcc#GetCommand(buffer) abort
|
||||
let l:paths = ale#c#FindLocalHeaderPaths(a:buffer)
|
||||
|
||||
" -iquote with the directory the file is in makes #include work for
|
||||
" headers in the same directory.
|
||||
return ale#Escape(ale_linters#c#gcc#GetExecutable(a:buffer))
|
||||
\ . ' -S -x c -fsyntax-only '
|
||||
\ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) . ' '
|
||||
\ . l:cflags
|
||||
\ . ale#c#IncludeOptions(l:paths)
|
||||
\ . ale#Var(a:buffer, 'c_gcc_options') . ' -'
|
||||
endfunction
|
||||
|
||||
@@ -24,9 +24,6 @@ call ale#linter#Define('c', {
|
||||
\ 'name': 'gcc',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable_callback': 'ale_linters#c#gcc#GetExecutable',
|
||||
\ 'command_chain': [
|
||||
\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
|
||||
\ {'callback': 'ale_linters#c#gcc#GetCommand'}
|
||||
\ ],
|
||||
\ 'command_callback': 'ale_linters#c#gcc#GetCommand',
|
||||
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
||||
\})
|
||||
|
||||
@@ -1,37 +1,24 @@
|
||||
" Author: Edward Larkey <edwlarkey@mac.com>
|
||||
" Author: Jose Junior <jose.junior@gmail.com>
|
||||
" Author: w0rp <devw0rp@gmail.com>
|
||||
" Description: This file adds the foodcritic linter for Chef files.
|
||||
|
||||
call ale#Set('chef_foodcritic_executable', 'foodcritic')
|
||||
call ale#Set('chef_foodcritic_options', '')
|
||||
|
||||
function! ale_linters#chef#foodcritic#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'chef_foodcritic_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#chef#foodcritic#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#chef#foodcritic#GetExecutable(a:buffer)
|
||||
let l:options = ale#Var(a:buffer, 'chef_foodcritic_options')
|
||||
|
||||
return ale#Escape(l:executable)
|
||||
\ . (!empty(l:options) ? ' ' . escape(l:options, '~') : '')
|
||||
\ . ' %s'
|
||||
endfunction
|
||||
" Support options!
|
||||
let g:ale_chef_foodcritic_options = get(g:, 'ale_chef_foodcritic_options', '')
|
||||
let g:ale_chef_foodcritic_executable = get(g:, 'ale_chef_foodcritic_executable', 'foodcritic')
|
||||
|
||||
function! ale_linters#chef#foodcritic#Handle(buffer, lines) abort
|
||||
" Matches patterns line the following:
|
||||
"
|
||||
" FC002: Avoid string interpolation where not required: httpd.rb:13
|
||||
let l:pattern = '\v([^:]+): (.+): ([a-zA-Z]?:?[^:]+):(\d+)$'
|
||||
let l:pattern = '^\(.\+:\s.\+\):\s\(.\+\):\(\d\+\)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:text = l:match[1]
|
||||
|
||||
call add(l:output, {
|
||||
\ 'code': l:match[1],
|
||||
\ 'text': l:match[2],
|
||||
\ 'filename': l:match[3],
|
||||
\ 'lnum': l:match[4] + 0,
|
||||
\ 'lnum': l:match[3] + 0,
|
||||
\ 'text': l:text,
|
||||
\ 'type': 'W',
|
||||
\})
|
||||
endfor
|
||||
@@ -39,10 +26,17 @@ function! ale_linters#chef#foodcritic#Handle(buffer, lines) abort
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
function! ale_linters#chef#foodcritic#GetCommand(buffer) abort
|
||||
return printf('%s %s %%t',
|
||||
\ ale#Var(a:buffer, 'chef_foodcritic_executable'),
|
||||
\ escape(ale#Var(a:buffer, 'chef_foodcritic_options'), '~')
|
||||
\)
|
||||
endfunction
|
||||
|
||||
|
||||
call ale#linter#Define('chef', {
|
||||
\ 'name': 'foodcritic',
|
||||
\ 'executable_callback': 'ale_linters#chef#foodcritic#GetExecutable',
|
||||
\ 'executable': 'foodcritic',
|
||||
\ 'command_callback': 'ale_linters#chef#foodcritic#GetCommand',
|
||||
\ 'callback': 'ale_linters#chef#foodcritic#Handle',
|
||||
\ 'lint_file': 1,
|
||||
\})
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
" Author: Nic West <nicwest@mailbox.org>
|
||||
" Description: linter for clojure using joker https://github.com/candid82/joker
|
||||
|
||||
function! ale_linters#clojure#joker#HandleJokerFormat(buffer, lines) abort
|
||||
" output format
|
||||
" <filename>:<line>:<column>: <issue type>: <message>
|
||||
let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+):? ((Read error|Parse error|Parse warning|Exception): ?(.+))$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:type = 'E'
|
||||
if l:match[4] is? 'Parse warning'
|
||||
let l:type = 'W'
|
||||
endif
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'col': l:match[2] + 0,
|
||||
\ 'text': l:match[3],
|
||||
\ 'type': l:type,
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('clojure', {
|
||||
\ 'name': 'joker',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': 'joker',
|
||||
\ 'command': 'joker --lint %t',
|
||||
\ 'callback': 'ale_linters#clojure#joker#HandleJokerFormat',
|
||||
\})
|
||||
@@ -8,15 +8,15 @@ function! ale_linters#cpp#clang#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'cpp_clang_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#cpp#clang#GetCommand(buffer, output) abort
|
||||
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
|
||||
function! ale_linters#cpp#clang#GetCommand(buffer) abort
|
||||
let l:paths = ale#c#FindLocalHeaderPaths(a:buffer)
|
||||
|
||||
" -iquote with the directory the file is in makes #include work for
|
||||
" headers in the same directory.
|
||||
return ale#Escape(ale_linters#cpp#clang#GetExecutable(a:buffer))
|
||||
\ . ' -S -x c++ -fsyntax-only '
|
||||
\ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) . ' '
|
||||
\ . l:cflags
|
||||
\ . ale#c#IncludeOptions(l:paths)
|
||||
\ . ale#Var(a:buffer, 'cpp_clang_options') . ' -'
|
||||
endfunction
|
||||
|
||||
@@ -24,9 +24,6 @@ call ale#linter#Define('cpp', {
|
||||
\ 'name': 'clang',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable_callback': 'ale_linters#cpp#clang#GetExecutable',
|
||||
\ 'command_chain': [
|
||||
\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
|
||||
\ {'callback': 'ale_linters#cpp#clang#GetCommand'},
|
||||
\ ],
|
||||
\ 'command_callback': 'ale_linters#cpp#clang#GetCommand',
|
||||
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
||||
\})
|
||||
|
||||
@@ -24,9 +24,9 @@ function! ale_linters#cpp#clangcheck#GetCommand(buffer) abort
|
||||
" detected.
|
||||
return ale#Escape(ale_linters#cpp#clangcheck#GetExecutable(a:buffer))
|
||||
\ . ' -analyze %s'
|
||||
\ . (empty(l:build_dir) ? ' -extra-arg -Xclang -extra-arg -analyzer-output=text' : '')
|
||||
\ . (!empty(l:user_options) ? ' ' . l:user_options : '')
|
||||
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
|
||||
\ . (empty(l:build_dir) ? ' -extra-arg -Xanalyzer -extra-arg -analyzer-output=text' : '')
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('cpp', {
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
" Author: Christian Gibbons <cgibbons@gmu.edu>
|
||||
" Description: flawfinder linter for c++ files
|
||||
|
||||
call ale#Set('cpp_flawfinder_executable', 'flawfinder')
|
||||
call ale#Set('cpp_flawfinder_options', '')
|
||||
call ale#Set('cpp_flawfinder_minlevel', 1)
|
||||
call ale#Set('c_flawfinder_error_severity', 6)
|
||||
|
||||
function! ale_linters#cpp#flawfinder#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'cpp_flawfinder_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#cpp#flawfinder#GetCommand(buffer) abort
|
||||
|
||||
" Set the minimum vulnerability level for flawfinder to bother with
|
||||
let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'cpp_flawfinder_minlevel')
|
||||
|
||||
return ale#Escape(ale_linters#cpp#flawfinder#GetExecutable(a:buffer))
|
||||
\ . ' -CDQS'
|
||||
\ . ale#Var(a:buffer, 'cpp_flawfinder_options')
|
||||
\ . l:minlevel
|
||||
\ . ' %t'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('cpp', {
|
||||
\ 'name': 'flawfinder',
|
||||
\ 'output_stream': 'stdout',
|
||||
\ 'executable_callback': 'ale_linters#cpp#flawfinder#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#cpp#flawfinder#GetCommand',
|
||||
\ 'callback': 'ale#handlers#flawfinder#HandleFlawfinderFormat',
|
||||
\})
|
||||
@@ -8,26 +8,22 @@ function! ale_linters#cpp#gcc#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'cpp_gcc_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#cpp#gcc#GetCommand(buffer, output) abort
|
||||
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
|
||||
function! ale_linters#cpp#gcc#GetCommand(buffer) abort
|
||||
let l:paths = ale#c#FindLocalHeaderPaths(a:buffer)
|
||||
|
||||
" -iquote with the directory the file is in makes #include work for
|
||||
" headers in the same directory.
|
||||
return ale#Escape(ale_linters#cpp#gcc#GetExecutable(a:buffer))
|
||||
\ . ' -S -x c++ -fsyntax-only '
|
||||
\ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) . ' '
|
||||
\ . l:cflags
|
||||
\ . ale#c#IncludeOptions(l:paths)
|
||||
\ . ale#Var(a:buffer, 'cpp_gcc_options') . ' -'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('cpp', {
|
||||
\ 'name': 'gcc',
|
||||
\ 'aliases': ['g++'],
|
||||
\ 'name': 'g++',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable_callback': 'ale_linters#cpp#gcc#GetExecutable',
|
||||
\ 'command_chain': [
|
||||
\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
|
||||
\ {'callback': 'ale_linters#cpp#gcc#GetCommand'},
|
||||
\ ],
|
||||
\ 'command_callback': 'ale_linters#cpp#gcc#GetCommand',
|
||||
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
||||
\})
|
||||
|
||||
@@ -8,16 +8,15 @@ function! ale_linters#cs#mcs#Handle(buffer, lines) abort
|
||||
" Look for lines like the following.
|
||||
"
|
||||
" Tests.cs(12,29): error CSXXXX: ; expected
|
||||
let l:pattern = '^\v(.+\.cs)\((\d+),(\d+)\)\: ([^ ]+) ([^ ]+): (.+)$'
|
||||
let l:pattern = '^.\+.cs(\(\d\+\),\(\d\+\)): \(.\+\): \(.\+\)'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'col': l:match[3] + 0,
|
||||
\ 'type': l:match[4] is# 'error' ? 'E' : 'W',
|
||||
\ 'code': l:match[5],
|
||||
\ 'text': l:match[6],
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'col': l:match[2] + 0,
|
||||
\ 'text': l:match[3] . ': ' . l:match[4],
|
||||
\ 'type': l:match[3] =~# '^error' ? 'E' : 'W',
|
||||
\})
|
||||
endfor
|
||||
|
||||
|
||||
@@ -1,47 +1,55 @@
|
||||
call ale#Set('cs_mcsc_options', '')
|
||||
call ale#Set('cs_mcsc_source', '')
|
||||
call ale#Set('cs_mcsc_assembly_path', [])
|
||||
call ale#Set('cs_mcsc_assemblies', [])
|
||||
" general mcs options which are likely to stay constant across
|
||||
" source trees like -pkg:dotnet
|
||||
let g:ale_cs_mcsc_options = get(g:, 'ale_cs_mcsc_options', '')
|
||||
|
||||
function! s:GetWorkingDirectory(buffer) abort
|
||||
let l:working_directory = ale#Var(a:buffer, 'cs_mcsc_source')
|
||||
" path string pointing the linter to the base path of the
|
||||
" source tree to check
|
||||
let g:ale_cs_mcsc_source = get(g:, 'ale_cs_mcsc_source','.')
|
||||
|
||||
if !empty(l:working_directory)
|
||||
return l:working_directory
|
||||
" list of search paths for additional assemblies to consider
|
||||
let g:ale_cs_mcsc_assembly_path = get(g:, 'ale_cs_mcsc_assembly_path',[])
|
||||
|
||||
" list of assemblies to consider
|
||||
let g:ale_cs_mcsc_assemblies = get(g:, 'ale_cs_mcsc_assemblies',[])
|
||||
function! ale_linters#cs#mcsc#GetCommand(buffer) abort
|
||||
|
||||
" if list of assembly search paths is not empty convert it to
|
||||
" appropriate -lib: parameter of mcs
|
||||
let l:path = ale#Var(a:buffer, 'cs_mcsc_assembly_path')
|
||||
|
||||
if !empty(l:path)
|
||||
let l:path = '-lib:"' . join(l:path, '","') .'"'
|
||||
else
|
||||
let l:path =''
|
||||
endif
|
||||
|
||||
return expand('#' . a:buffer . ':p:h')
|
||||
endfunction
|
||||
" if list of assemblies to link is not empty convert it to the
|
||||
" appropriate -r: parameter of mcs
|
||||
let l:assemblies = ale#Var(a:buffer, 'cs_mcsc_assemblies')
|
||||
|
||||
function! ale_linters#cs#mcsc#GetCommand(buffer) abort
|
||||
" Pass assembly paths via the -lib: parameter.
|
||||
let l:path_list = ale#Var(a:buffer, 'cs_mcsc_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_mcsc_assemblies')
|
||||
|
||||
let l:r_option = !empty(l:assembly_list)
|
||||
\ ? '-r:' . join(map(copy(l:assembly_list), 'ale#Escape(v:val)'), ',')
|
||||
\ : ''
|
||||
if !empty(l:assemblies)
|
||||
let l:assemblies = '-r:"' . join(l:assemblies, '","') . '"'
|
||||
else
|
||||
let l:assemblies =''
|
||||
endif
|
||||
|
||||
" register temporary module target file with ale
|
||||
let l:out = tempname()
|
||||
call ale#engine#ManageFile(a:buffer, l:out)
|
||||
|
||||
" The code is compiled as a module and the output is redirected to a
|
||||
" temporary file.
|
||||
return ale#path#CdString(s:GetWorkingDirectory(a:buffer))
|
||||
" assemble linter command string to be executed by ale
|
||||
" implicitly set -unsafe mcs flag set compilation
|
||||
" target to module (-t:module), direct mcs output to
|
||||
" temporary file (-out)
|
||||
"
|
||||
return 'cd "' . ale#Var(a:buffer, 'cs_mcsc_source') . '";'
|
||||
\ . 'mcs -unsafe'
|
||||
\ . ' ' . ale#Var(a:buffer, 'cs_mcsc_options')
|
||||
\ . ' ' . l:lib_option
|
||||
\ . ' ' . l:r_option
|
||||
\ . ' ' . l:path
|
||||
\ . ' ' . l:assemblies
|
||||
\ . ' -out:' . l:out
|
||||
\ . ' -t:module'
|
||||
\ . ' -recurse:' . ale#Escape('*.cs')
|
||||
\ . ' -recurse:"*.cs"'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#cs#mcsc#Handle(buffer, lines) abort
|
||||
@@ -52,19 +60,17 @@ 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:pattern = '^\(.\+\.cs\)(\(\d\+\),\(\d\+\)): \(.\+\): \(.\+\)'
|
||||
let l:output = []
|
||||
|
||||
let l:dir = s:GetWorkingDirectory(a:buffer)
|
||||
let l:source = ale#Var(a:buffer, 'cs_mcsc_source')
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
|
||||
\ 'filename': fnamemodify(l:source . '/' . l:match[1], ':p'),
|
||||
\ '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[4] . ': ' . l:match[5],
|
||||
\ 'type': l:match[4] =~# '^error' ? 'E' : 'W',
|
||||
\})
|
||||
endfor
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
call ale#Set('css_stylelint_executable', 'stylelint')
|
||||
call ale#Set('css_stylelint_options', '')
|
||||
call ale#Set('css_stylelint_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('css_stylelint_use_global', 0)
|
||||
|
||||
function! ale_linters#css#stylelint#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'css_stylelint', [
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
" Author: Eddie Lebow https://github.com/elebow
|
||||
" Description: Cucumber, a BDD test tool
|
||||
|
||||
function! ale_linters#cucumber#cucumber#GetCommand(buffer) abort
|
||||
let l:features_dir = ale#path#FindNearestDirectory(a:buffer, 'features')
|
||||
|
||||
if !empty(l:features_dir)
|
||||
let l:features_arg = '-r ' . ale#Escape(l:features_dir)
|
||||
else
|
||||
let l:features_arg = ''
|
||||
endif
|
||||
|
||||
return 'cucumber --dry-run --quiet --strict --format=json '
|
||||
\ . l:features_arg . ' %t'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#cucumber#cucumber#Handle(buffer, lines) abort
|
||||
try
|
||||
let l:json = ale#util#FuzzyJSONDecode(a:lines, {})[0]
|
||||
catch
|
||||
return []
|
||||
endtry
|
||||
|
||||
let l:output = []
|
||||
for l:element in get(l:json, 'elements', [])
|
||||
for l:step in l:element['steps']
|
||||
if l:step['result']['status'] is# 'undefined'
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:step['line'],
|
||||
\ 'code': 'E',
|
||||
\ 'text': 'Undefined step'
|
||||
\})
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('cucumber', {
|
||||
\ 'name': 'cucumber',
|
||||
\ 'executable': 'cucumber',
|
||||
\ 'command_callback': 'ale_linters#cucumber#cucumber#GetCommand',
|
||||
\ 'callback': 'ale_linters#cucumber#cucumber#Handle'
|
||||
\})
|
||||
@@ -46,7 +46,7 @@ function! ale_linters#d#dmd#DMDCommand(buffer, dub_output) abort
|
||||
endif
|
||||
endfor
|
||||
|
||||
return 'dmd '. join(l:import_list) . ' -o- -wi -vcolumns -c %t'
|
||||
return 'dmd '. join(l:import_list) . ' -o- -vcolumns -c %t'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#d#dmd#Handle(buffer, lines) abort
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
" Author: Taylor Blau <me@ttaylorr.com>
|
||||
|
||||
function! ale_linters#dafny#dafny#Handle(buffer, lines) abort
|
||||
let l:pattern = '\v(.*)\((\d+),(\d+)\): (.*): (.*)'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'bufnr': a:buffer,
|
||||
\ 'col': l:match[3] + 0,
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'text': l:match[5],
|
||||
\ 'type': l:match[4] =~# '^Error' ? 'E' : 'W'
|
||||
\ })
|
||||
endfor
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('dafny', {
|
||||
\ 'name': 'dafny',
|
||||
\ 'executable': 'dafny',
|
||||
\ 'command': 'dafny %s /compile:0',
|
||||
\ 'callback': 'ale_linters#dafny#dafny#Handle',
|
||||
\ 'lint_file': 1,
|
||||
\ })
|
||||
@@ -13,7 +13,7 @@ function! ale_linters#dart#dartanalyzer#GetCommand(buffer) abort
|
||||
|
||||
return ale#Escape(l:executable)
|
||||
\ . (!empty(l:path) ? ' --packages ' . ale#Escape(l:path) : '')
|
||||
\ . ' %s'
|
||||
\ . ' %t'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#dart#dartanalyzer#Handle(buffer, lines) abort
|
||||
@@ -37,5 +37,4 @@ call ale#linter#Define('dart', {
|
||||
\ 'executable_callback': 'ale_linters#dart#dartanalyzer#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#dart#dartanalyzer#GetCommand',
|
||||
\ 'callback': 'ale_linters#dart#dartanalyzer#Handle',
|
||||
\ 'lint_file': 1,
|
||||
\})
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
" Author: aurieh <me@aurieh.me>
|
||||
" Description: A language server for dart
|
||||
|
||||
call ale#Set('dart_language_server_executable', 'dart_language_server')
|
||||
|
||||
function! ale_linters#dart#language_server#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'dart_language_server_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#dart#language_server#GetProjectRoot(buffer) abort
|
||||
" Note: pub only looks for pubspec.yaml, there's no point in adding
|
||||
" support for pubspec.yml
|
||||
let l:pubspec = ale#path#FindNearestFile(a:buffer, 'pubspec.yaml')
|
||||
|
||||
return !empty(l:pubspec) ? fnamemodify(l:pubspec, ':h:h') : ''
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('dart', {
|
||||
\ 'name': 'language_server',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable_callback': 'ale_linters#dart#language_server#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#dart#language_server#GetExecutable',
|
||||
\ 'language': 'dart',
|
||||
\ 'project_root_callback': 'ale_linters#dart#language_server#GetProjectRoot',
|
||||
\})
|
||||
@@ -2,51 +2,31 @@
|
||||
|
||||
" always, yes, never
|
||||
call ale#Set('dockerfile_hadolint_use_docker', 'never')
|
||||
call ale#Set('dockerfile_hadolint_docker_image', 'hadolint/hadolint')
|
||||
call ale#Set('dockerfile_hadolint_docker_image', 'lukasmartinelli/hadolint')
|
||||
|
||||
function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort
|
||||
" Matches patterns line the following:
|
||||
"
|
||||
" /dev/stdin:19 DL3001 Pipe chain should start with a raw value.
|
||||
" /dev/stdin:19:3 unexpected thing
|
||||
let l:pattern = '\v^/dev/stdin:(\d+):?(\d+)? ((DL|SC)(\d+) )?(.+)$'
|
||||
" stdin:19: F: Pipe chain should start with a raw value.
|
||||
let l:pattern = '\v^/dev/stdin:?(\d+)? (\S+) (.+)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:lnum = 0
|
||||
let l:colnum = 0
|
||||
|
||||
if l:match[1] isnot# ''
|
||||
let l:lnum = l:match[1] + 0
|
||||
endif
|
||||
|
||||
if l:match[2] isnot# ''
|
||||
let l:colnum = l:match[2] + 0
|
||||
endif
|
||||
|
||||
let l:type = 'W'
|
||||
let l:text = l:match[6]
|
||||
let l:detail = l:match[6]
|
||||
let l:domain = 'https://github.com/hadolint/hadolint/wiki/'
|
||||
|
||||
if l:match[4] is# 'SC'
|
||||
let l:domain = 'https://github.com/koalaman/shellcheck/wiki/'
|
||||
endif
|
||||
|
||||
if l:match[5] isnot# ''
|
||||
let l:code = l:match[4] . l:match[5]
|
||||
let l:link = ' ( ' . l:domain . l:code . ' )'
|
||||
let l:detail = l:code . l:link . "\n\n" . l:detail
|
||||
else
|
||||
let l:type = 'E'
|
||||
endif
|
||||
let l:text = l:match[3]
|
||||
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:lnum,
|
||||
\ 'col': l:colnum,
|
||||
\ 'col': 0,
|
||||
\ 'type': l:type,
|
||||
\ 'text': l:text,
|
||||
\ 'detail': l:detail
|
||||
\ 'nr': l:match[2],
|
||||
\})
|
||||
endfor
|
||||
|
||||
|
||||
@@ -32,6 +32,6 @@ endfunction
|
||||
call ale#linter#Define('elixir', {
|
||||
\ 'name': 'credo',
|
||||
\ 'executable': 'mix',
|
||||
\ 'command': 'mix help credo && mix credo suggest --format=flycheck --read-from-stdin %s',
|
||||
\ 'command': 'mix credo suggest --format=flycheck --read-from-stdin %s',
|
||||
\ 'callback': 'ale_linters#elixir#credo#Handle',
|
||||
\})
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
" Author: Fran C. - https://github.com/franciscoj
|
||||
" Description: Add dialyzer support for elixir through dialyxir
|
||||
" https://github.com/jeremyjh/dialyxir
|
||||
|
||||
function! ale_linters#elixir#dialyxir#Handle(buffer, lines) abort
|
||||
" Matches patterns line the following:
|
||||
"
|
||||
" lib/filename.ex:19: Function fname/1 has no local return
|
||||
let l:pattern = '\v(.+):(\d+): (.+)$'
|
||||
let l:output = []
|
||||
let l:type = 'W'
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
if bufname(a:buffer) == l:match[1]
|
||||
call add(l:output, {
|
||||
\ 'bufnr': a:buffer,
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'col': 0,
|
||||
\ 'type': l:type,
|
||||
\ 'text': l:match[3],
|
||||
\})
|
||||
endif
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('elixir', {
|
||||
\ 'name': 'dialyxir',
|
||||
\ 'executable': 'mix',
|
||||
\ 'command': 'mix dialyzer',
|
||||
\ 'callback': 'ale_linters#elixir#dialyxir#Handle',
|
||||
\})
|
||||
|
||||
@@ -32,7 +32,7 @@ endfunction
|
||||
call ale#linter#Define('elixir', {
|
||||
\ 'name': 'dogma',
|
||||
\ 'executable': 'mix',
|
||||
\ 'command': 'mix help dogma && mix dogma %s --format=flycheck',
|
||||
\ 'command': 'mix dogma %s --format=flycheck',
|
||||
\ 'lint_file': 1,
|
||||
\ 'callback': 'ale_linters#elixir#dogma#Handle',
|
||||
\})
|
||||
|
||||
@@ -1,26 +1,45 @@
|
||||
" Author: buffalocoder - https://github.com/buffalocoder, soywod - https://github.com/soywod, hecrj - https://github.com/hecrj
|
||||
" Author: buffalocoder - https://github.com/buffalocoder, soywod - https://github.com/soywod
|
||||
" Description: Elm linting in Ale. Closely follows the Syntastic checker in https://github.com/ElmCast/elm-vim.
|
||||
|
||||
call ale#Set('elm_make_executable', 'elm')
|
||||
call ale#Set('elm_make_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('elm_make_executable', 'elm-make')
|
||||
call ale#Set('elm_make_use_global', 0)
|
||||
|
||||
function! ale_linters#elm#make#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'elm_make', [
|
||||
\ 'node_modules/.bin/elm',
|
||||
\ 'node_modules/.bin/elm-make',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#elm#make#Handle(buffer, lines) abort
|
||||
let l:output = []
|
||||
let l:is_windows = has('win32')
|
||||
let l:temp_dir = l:is_windows ? $TMP : $TMPDIR
|
||||
let l:unparsed_lines = []
|
||||
|
||||
for l:line in a:lines
|
||||
if l:line[0] is# '{'
|
||||
" Elm 0.19
|
||||
call ale_linters#elm#make#HandleElm019Line(l:line, l:output)
|
||||
elseif l:line[0] is# '['
|
||||
" Elm 0.18
|
||||
call ale_linters#elm#make#HandleElm018Line(l:line, l:output)
|
||||
if l:line[0] is# '['
|
||||
let l:errors = json_decode(l:line)
|
||||
|
||||
for l:error in l:errors
|
||||
" Check if file is from the temp directory.
|
||||
" Filters out any errors not related to the buffer.
|
||||
if l:is_windows
|
||||
let l:file_is_buffer = l:error.file[0:len(l:temp_dir) - 1] is? l:temp_dir
|
||||
else
|
||||
let l:file_is_buffer = l:error.file[0:len(l:temp_dir) - 1] is# l:temp_dir
|
||||
endif
|
||||
|
||||
if l:file_is_buffer
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:error.region.start.line,
|
||||
\ 'col': l:error.region.start.column,
|
||||
\ 'end_lnum': l:error.region.end.line,
|
||||
\ 'end_col': l:error.region.end.column,
|
||||
\ 'type': (l:error.type is? 'error') ? 'E' : 'W',
|
||||
\ 'text': l:error.overview,
|
||||
\ 'detail': l:error.overview . "\n\n" . l:error.details
|
||||
\})
|
||||
endif
|
||||
endfor
|
||||
elseif l:line isnot# 'Successfully generated /dev/null'
|
||||
call add(l:unparsed_lines, l:line)
|
||||
endif
|
||||
@@ -38,142 +57,23 @@ function! ale_linters#elm#make#Handle(buffer, lines) abort
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
function! ale_linters#elm#make#HandleElm019Line(line, output) abort
|
||||
let l:report = json_decode(a:line)
|
||||
|
||||
if l:report.type is? 'error'
|
||||
" General problem
|
||||
let l:details = ale_linters#elm#make#ParseMessage(l:report.message)
|
||||
|
||||
if empty(l:report.path)
|
||||
let l:report.path = 'Elm'
|
||||
endif
|
||||
|
||||
if ale_linters#elm#make#FileIsBuffer(l:report.path)
|
||||
call add(a:output, {
|
||||
\ 'lnum': 1,
|
||||
\ 'type': 'E',
|
||||
\ 'text': l:details,
|
||||
\})
|
||||
else
|
||||
call add(a:output, {
|
||||
\ 'lnum': 1,
|
||||
\ 'type': 'E',
|
||||
\ 'text': l:report.path .' - '. l:details,
|
||||
\ 'detail': l:report.path ." ----------\n\n". l:details,
|
||||
\})
|
||||
endif
|
||||
else
|
||||
" Compilation errors
|
||||
for l:error in l:report.errors
|
||||
let l:file_is_buffer = ale_linters#elm#make#FileIsBuffer(l:error.path)
|
||||
|
||||
for l:problem in l:error.problems
|
||||
let l:details = ale_linters#elm#make#ParseMessage(l:problem.message)
|
||||
|
||||
if l:file_is_buffer
|
||||
" Buffer module has problems
|
||||
call add(a:output, {
|
||||
\ 'lnum': l:problem.region.start.line,
|
||||
\ 'col': l:problem.region.start.column,
|
||||
\ 'end_lnum': l:problem.region.end.line,
|
||||
\ 'end_col': l:problem.region.end.column,
|
||||
\ 'type': 'E',
|
||||
\ 'text': l:details,
|
||||
\})
|
||||
else
|
||||
" Imported module has problems
|
||||
let l:location = l:error.path .':'. l:problem.region.start.line
|
||||
call add(a:output, {
|
||||
\ 'lnum': 1,
|
||||
\ 'type': 'E',
|
||||
\ 'text': l:location .' - '. l:details,
|
||||
\ 'detail': l:location ." ----------\n\n". l:details,
|
||||
\})
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! ale_linters#elm#make#HandleElm018Line(line, output) abort
|
||||
let l:errors = json_decode(a:line)
|
||||
|
||||
for l:error in l:errors
|
||||
let l:file_is_buffer = ale_linters#elm#make#FileIsBuffer(l:error.file)
|
||||
|
||||
if l:file_is_buffer
|
||||
" Current buffer has problems
|
||||
call add(a:output, {
|
||||
\ 'lnum': l:error.region.start.line,
|
||||
\ 'col': l:error.region.start.column,
|
||||
\ 'end_lnum': l:error.region.end.line,
|
||||
\ 'end_col': l:error.region.end.column,
|
||||
\ 'type': (l:error.type is? 'error') ? 'E' : 'W',
|
||||
\ 'text': l:error.overview,
|
||||
\ 'detail': l:error.overview . "\n\n" . l:error.details
|
||||
\})
|
||||
elseif l:error.type is? 'error'
|
||||
" Imported module has errors
|
||||
let l:location = l:error.file .':'. l:error.region.start.line
|
||||
|
||||
call add(a:output, {
|
||||
\ 'lnum': 1,
|
||||
\ 'type': 'E',
|
||||
\ 'text': l:location .' - '. l:error.overview,
|
||||
\ 'detail': l:location ." ----------\n\n". l:error.overview . "\n\n" . l:error.details
|
||||
\})
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! ale_linters#elm#make#FileIsBuffer(path) abort
|
||||
let l:is_windows = has('win32')
|
||||
let l:temp_dir = l:is_windows ? $TMP : $TMPDIR
|
||||
|
||||
if has('win32')
|
||||
return a:path[0:len(l:temp_dir) - 1] is? l:temp_dir
|
||||
else
|
||||
return a:path[0:len(l:temp_dir) - 1] is# l:temp_dir
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! ale_linters#elm#make#ParseMessage(message) abort
|
||||
return join(map(copy(a:message), 'ale_linters#elm#make#ParseMessageItem(v:val)'), '')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#elm#make#ParseMessageItem(item) abort
|
||||
if type(a:item) == type('')
|
||||
return a:item
|
||||
else
|
||||
return a:item.string
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Return the command to execute the linter in the projects directory.
|
||||
" If it doesn't, then this will fail when imports are needed.
|
||||
function! ale_linters#elm#make#GetCommand(buffer) abort
|
||||
let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm.json')
|
||||
let l:elm_package = ale#path#FindNearestFile(a:buffer, 'elm-package.json')
|
||||
let l:elm_exe = ale_linters#elm#make#GetExecutable(a:buffer)
|
||||
|
||||
if empty(l:elm_json)
|
||||
" Fallback to Elm 0.18
|
||||
let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm-package.json')
|
||||
endif
|
||||
|
||||
if empty(l:elm_json)
|
||||
if empty(l:elm_package)
|
||||
let l:dir_set_cmd = ''
|
||||
else
|
||||
let l:root_dir = fnamemodify(l:elm_json, ':p:h')
|
||||
let l:root_dir = fnamemodify(l:elm_package, ':p:h')
|
||||
let l:dir_set_cmd = 'cd ' . ale#Escape(l:root_dir) . ' && '
|
||||
endif
|
||||
|
||||
" The elm compiler, at the time of this writing, uses '/dev/null' as
|
||||
" The elm-make compiler, at the time of this writing, uses '/dev/null' as
|
||||
" a sort of flag to tell the compiler not to generate an output file,
|
||||
" which is why this is hard coded here.
|
||||
" Source: https://github.com/elm-lang/elm-compiler/blob/19d5a769b30ec0b2fc4475985abb4cd94cd1d6c3/builder/src/Generate/Output.hs#L253
|
||||
" which is why this is hard coded here. It does not use NUL on Windows.
|
||||
" Source: https://github.com/elm-lang/elm-make/blob/master/src/Flags.hs
|
||||
let l:elm_cmd = ale#Escape(l:elm_exe)
|
||||
\ . ' make'
|
||||
\ . ' --report=json'
|
||||
\ . ' --output=/dev/null'
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
" Author: Matthias Guenther - https://wikimatze.de, Eddie Lebow https://github.com/elebow
|
||||
" Description: ERB from the Ruby standard library, for eruby/erb files
|
||||
|
||||
function! ale_linters#eruby#erb#GetCommand(buffer) abort
|
||||
let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
|
||||
|
||||
if empty(l:rails_root)
|
||||
return 'erb -P -T - -x %t | ruby -c'
|
||||
endif
|
||||
|
||||
" Rails-flavored eRuby does not comply with the standard as understood by
|
||||
" ERB, so we'll have to do some substitution. This does not reduce the
|
||||
" effectiveness of the linter—the translated code is still evaluated.
|
||||
return 'ruby -r erb -e ' . ale#Escape('puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . '< %t | ruby -c'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('eruby', {
|
||||
\ 'name': 'erb',
|
||||
\ 'aliases': ['erubylint'],
|
||||
\ 'executable': 'erb',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'command_callback': 'ale_linters#eruby#erb#GetCommand',
|
||||
\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
|
||||
\})
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
" Author: Eddie Lebow https://github.com/elebow
|
||||
" Description: eruby checker using `erubi`
|
||||
|
||||
function! ale_linters#eruby#erubi#CheckErubi(buffer) abort
|
||||
return 'ruby -r erubi/capture_end -e ' . ale#Escape('""')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#eruby#erubi#GetCommand(buffer, check_erubi_output) abort
|
||||
let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
|
||||
|
||||
if (!empty(a:check_erubi_output))
|
||||
" The empty command in CheckErubi returns nothing if erubi runs and
|
||||
" emits an error if erubi is not present
|
||||
return ''
|
||||
endif
|
||||
|
||||
if empty(l:rails_root)
|
||||
return 'ruby -r erubi/capture_end -e ' . ale#Escape('puts Erubi::CaptureEndEngine.new($stdin.read).src') . '< %t | ruby -c'
|
||||
endif
|
||||
|
||||
" Rails-flavored eRuby does not comply with the standard as understood by
|
||||
" Erubi, so we'll have to do some substitution. This does not reduce the
|
||||
" effectiveness of the linter---the translated code is still evaluated.
|
||||
return 'ruby -r erubi/capture_end -e ' . ale#Escape('puts Erubi::CaptureEndEngine.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . '< %t | ruby -c'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('eruby', {
|
||||
\ 'name': 'erubi',
|
||||
\ 'executable': 'ruby',
|
||||
\ 'command_chain': [
|
||||
\ {'callback': 'ale_linters#eruby#erubi#CheckErubi'},
|
||||
\ {'callback': 'ale_linters#eruby#erubi#GetCommand', 'output_stream': 'stderr'},
|
||||
\ ],
|
||||
\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
|
||||
\})
|
||||
@@ -1,23 +1,11 @@
|
||||
" Author: Jake Zimmerman <jake@zimmerman.io>, Eddie Lebow https://github.com/elebow
|
||||
" Author: Jake Zimmerman <jake@zimmerman.io>
|
||||
" Description: eruby checker using `erubis`, instead of `erb`
|
||||
|
||||
function! ale_linters#eruby#erubis#GetCommand(buffer) abort
|
||||
let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
|
||||
|
||||
if empty(l:rails_root)
|
||||
return 'erubis -x %t | ruby -c'
|
||||
endif
|
||||
|
||||
" Rails-flavored eRuby does not comply with the standard as understood by
|
||||
" Erubis, so we'll have to do some substitution. This does not reduce the
|
||||
" effectiveness of the linter - the translated code is still evaluated.
|
||||
return 'ruby -r erubis -e ' . ale#Escape('puts Erubis::Eruby.new($stdin.read.gsub(%{<%=},%{<%})).src') . '< %t | ruby -c'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('eruby', {
|
||||
\ 'name': 'erubis',
|
||||
\ 'executable': 'erubis',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'command_callback': 'ale_linters#eruby#erubis#GetCommand',
|
||||
\ 'command': 'erubis -x %t | ruby -c',
|
||||
\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
|
||||
\})
|
||||
|
||||
|
||||
11
ale_linters/eruby/erubylint.vim
Normal file
11
ale_linters/eruby/erubylint.vim
Normal file
@@ -0,0 +1,11 @@
|
||||
" Author: Matthias Guenther - https://wikimatze.de
|
||||
" Description: erb-lint for eruby/erb files
|
||||
|
||||
call ale#linter#Define('eruby', {
|
||||
\ 'name': 'erubylint',
|
||||
\ 'executable': 'erb',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'command': 'erb -P -x %t | ruby -c',
|
||||
\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
|
||||
\})
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
" Author: Niraj Thapaliya - https://github.com/nthapaliya
|
||||
" Description: Lints fish files using fish -n
|
||||
|
||||
function! ale_linters#fish#fish#Handle(buffer, lines) abort
|
||||
" Matches patterns such as:
|
||||
"
|
||||
" home/.config/fish/functions/foo.fish (line 1): Missing end to balance this function definition
|
||||
" function foo
|
||||
" ^
|
||||
"
|
||||
" OR, patterns such as:
|
||||
"
|
||||
" Unsupported use of '||'. In fish, please use 'COMMAND; or COMMAND'.
|
||||
" /tmp/vLz620o/258/test.fish (line 2): if set -q SSH_CLIENT || set -q SSH_TTY
|
||||
" ^
|
||||
"
|
||||
" fish -n can return errors in either format.
|
||||
let l:pattern = '^\(.* (line \(\d\+\)): \)\(.*\)$'
|
||||
let l:column_pattern = '^ *\^'
|
||||
let l:output = []
|
||||
let l:column_offset = 0
|
||||
let l:last_line_with_message = ''
|
||||
|
||||
for l:line in a:lines
|
||||
" Look for error lines first.
|
||||
let l:match = matchlist(l:line, l:pattern)
|
||||
|
||||
if !empty(l:match)
|
||||
if !empty(l:last_line_with_message)
|
||||
let l:text = l:last_line_with_message
|
||||
else
|
||||
let l:text = l:match[3]
|
||||
endif
|
||||
|
||||
let l:column_offset = len(l:match[1])
|
||||
|
||||
let l:last_line_with_message = ''
|
||||
call add(l:output, {
|
||||
\ 'col': 0,
|
||||
\ 'lnum': str2nr(l:match[2]),
|
||||
\ 'text': l:text,
|
||||
\})
|
||||
else
|
||||
" Look for column markers like ' ^' second.
|
||||
" The column index will be set according to how long the line is.
|
||||
let l:column_match = matchstr(l:line, l:column_pattern)
|
||||
|
||||
if !empty(l:column_match) && !empty(l:output)
|
||||
let l:output[-1].col = len(l:column_match) - l:column_offset
|
||||
let l:last_line_with_message = ''
|
||||
else
|
||||
let l:last_line_with_message = l:line
|
||||
let l:column_offset = 0
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('fish', {
|
||||
\ 'name': 'fish',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': 'fish',
|
||||
\ 'command': 'fish -n %t',
|
||||
\ 'callback': 'ale_linters#fish#fish#Handle',
|
||||
\})
|
||||
@@ -1,9 +0,0 @@
|
||||
" Author: Jansen Mitchell https://github.com/JansenMitchell
|
||||
" Description: proselint for Fountain files
|
||||
|
||||
call ale#linter#Define('fountain', {
|
||||
\ 'name': 'proselint',
|
||||
\ 'executable': 'proselint',
|
||||
\ 'command': 'proselint %t',
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\})
|
||||
@@ -1,52 +0,0 @@
|
||||
" Author: Nick Yamane <nick.diego@gmail.com>
|
||||
" Description: gitlint for git commit message files
|
||||
|
||||
let g:ale_gitcommit_gitlint_executable =
|
||||
\ get(g:, 'ale_gitcommit_gitlint_executable', 'gitlint')
|
||||
let g:ale_gitcommit_gitlint_options = get(g:, 'ale_gitcommit_gitlint_options', '')
|
||||
let g:ale_gitcommit_gitlint_use_global = get(g:, 'ale_gitcommit_gitlint_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
|
||||
|
||||
function! ale_linters#gitcommit#gitlint#GetExecutable(buffer) abort
|
||||
return ale#python#FindExecutable(a:buffer, 'gitcommit_gitlint', ['gitlint'])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#gitcommit#gitlint#GetCommand(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'gitcommit_gitlint_options')
|
||||
let l:executable = ale_linters#gitcommit#gitlint#GetExecutable(a:buffer)
|
||||
return ale#Escape(l:executable)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' lint'
|
||||
endfunction
|
||||
|
||||
|
||||
function! ale_linters#gitcommit#gitlint#Handle(buffer, lines) abort
|
||||
" Matches patterns line the following:
|
||||
let l:pattern = '\v^(\d+): (\w+) (.*)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:code = l:match[2]
|
||||
|
||||
let l:item = {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'text': l:match[3],
|
||||
\ 'code': l:code,
|
||||
\ 'type': 'E',
|
||||
\}
|
||||
|
||||
call add(l:output, l:item)
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
|
||||
call ale#linter#Define('gitcommit', {
|
||||
\ 'name': 'gitlint',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable_callback': 'ale_linters#gitcommit#gitlint#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#gitcommit#gitlint#GetCommand',
|
||||
\ 'callback': 'ale_linters#gitcommit#gitlint#Handle',
|
||||
\})
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
" Author: Sven-Hendrik Haase <svenstaro@gmail.com>
|
||||
" Description: A language server for glsl
|
||||
|
||||
call ale#Set('glsl_glslls_executable', 'glslls')
|
||||
call ale#Set('glsl_glslls_logfile', '')
|
||||
|
||||
function! ale_linters#glsl#glslls#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'glsl_glslls_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#glsl#glslls#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#glsl#glslls#GetExecutable(a:buffer)
|
||||
let l:logfile = ale#Var(a:buffer, 'glsl_glslls_logfile')
|
||||
let l:logfile_args = ''
|
||||
if l:logfile isnot# ''
|
||||
let l:logfile_args = ' --verbose -l ' . l:logfile
|
||||
endif
|
||||
return ale#Escape(l:executable) . l:logfile_args . ' --stdin'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#glsl#glslls#GetProjectRoot(buffer) abort
|
||||
let l:project_root = ale#c#FindProjectRoot(a:buffer)
|
||||
|
||||
return !empty(l:project_root) ? fnamemodify(l:project_root, ':h:h') : ''
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('glsl', {
|
||||
\ 'name': 'glslls',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable_callback': 'ale_linters#glsl#glslls#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#glsl#glslls#GetCommand',
|
||||
\ 'language': 'glsl',
|
||||
\ 'project_root_callback': 'ale_linters#glsl#glslls#GetProjectRoot',
|
||||
\})
|
||||
@@ -1,14 +1,8 @@
|
||||
" Author: Joshua Rubin <joshua@rubixconsulting.com>, Ben Reedy <https://github.com/breed808>,
|
||||
" Jeff Willette <jrwillette88@gmail.com>
|
||||
" Author: Joshua Rubin <joshua@rubixconsulting.com>, Ben Reedy <https://github.com/breed808>
|
||||
" Description: go build for Go files
|
||||
|
||||
" inspired by work from dzhou121 <dzhou121@gmail.com>
|
||||
|
||||
call ale#Set('go_gobuild_options', '')
|
||||
|
||||
function! ale_linters#go#gobuild#ResetEnv() abort
|
||||
unlet! s:go_env
|
||||
endfunction
|
||||
|
||||
function! ale_linters#go#gobuild#GoEnv(buffer) abort
|
||||
if exists('s:go_env')
|
||||
return ''
|
||||
@@ -18,8 +12,6 @@ function! ale_linters#go#gobuild#GoEnv(buffer) abort
|
||||
endfunction
|
||||
|
||||
function! ale_linters#go#gobuild#GetCommand(buffer, goenv_output) abort
|
||||
let l:options = ale#Var(a:buffer, 'go_gobuild_options')
|
||||
|
||||
if !exists('s:go_env')
|
||||
let s:go_env = {
|
||||
\ 'GOPATH': a:goenv_output[0],
|
||||
@@ -27,16 +19,10 @@ function! ale_linters#go#gobuild#GetCommand(buffer, goenv_output) abort
|
||||
\}
|
||||
endif
|
||||
|
||||
let l:gopath_env_command = has('win32')
|
||||
\ ? 'set GOPATH=' . ale#Escape(s:go_env.GOPATH) . ' && '
|
||||
\ : 'GOPATH=' . ale#Escape(s:go_env.GOPATH) . ' '
|
||||
|
||||
" Run go test in local directory with relative path
|
||||
return l:gopath_env_command
|
||||
\ . ale#path#BufferCdString(a:buffer)
|
||||
\ . 'go test'
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' -c -o /dev/null ./'
|
||||
return 'GOPATH=' . s:go_env.GOPATH
|
||||
\ . ' cd ' . fnamemodify(bufname(a:buffer), ':.:h')
|
||||
\ . ' && go test -c -o /dev/null ./'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#go#gobuild#GetMatches(lines) abort
|
||||
@@ -53,12 +39,15 @@ function! ale_linters#go#gobuild#GetMatches(lines) abort
|
||||
endfunction
|
||||
|
||||
function! ale_linters#go#gobuild#Handler(buffer, lines) abort
|
||||
let l:dir = expand('#' . a:buffer . ':p:h')
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale_linters#go#gobuild#GetMatches(a:lines)
|
||||
" Omit errors from imported go packages
|
||||
if !ale#path#IsBufferPath(a:buffer, l:match[1])
|
||||
continue
|
||||
endif
|
||||
|
||||
call add(l:output, {
|
||||
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'col': l:match[3] + 0,
|
||||
\ 'text': l:match[4],
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
call ale#linter#Define('go', {
|
||||
\ 'name': 'golint',
|
||||
\ 'output_stream': 'both',
|
||||
\ 'executable': 'golint',
|
||||
\ 'command': 'golint %t',
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
" Author: Ben Reedy <https://github.com/breed808>, Jeff Willette <jrwillette88@gmail.com>
|
||||
" Author: Ben Reedy <https://github.com/breed808>
|
||||
" Description: Adds support for the gometalinter suite for Go files
|
||||
|
||||
call ale#Set('go_gometalinter_options', '')
|
||||
call ale#Set('go_gometalinter_executable', 'gometalinter')
|
||||
call ale#Set('go_gometalinter_lint_package', 0)
|
||||
|
||||
function! ale_linters#go#gometalinter#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'go_gometalinter_executable')
|
||||
@@ -11,22 +10,13 @@ endfunction
|
||||
|
||||
function! ale_linters#go#gometalinter#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#go#gometalinter#GetExecutable(a:buffer)
|
||||
let l:filename = expand('#' . a:buffer . ':t')
|
||||
let l:filename = expand('#' . a:buffer)
|
||||
let l:options = ale#Var(a:buffer, 'go_gometalinter_options')
|
||||
let l:lint_package = ale#Var(a:buffer, 'go_gometalinter_lint_package')
|
||||
|
||||
" BufferCdString is used so that we can be sure the paths output from gometalinter can
|
||||
" be calculated to absolute paths in the Handler
|
||||
if l:lint_package
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#Escape(l:executable)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
|
||||
endif
|
||||
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#Escape(l:executable)
|
||||
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(l:filename))
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
|
||||
return ale#Escape(l:executable)
|
||||
\ . ' --include=' . ale#Escape('^' . ale#util#EscapePCRE(l:filename))
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' ' . ale#Escape(fnamemodify(l:filename, ':h'))
|
||||
endfunction
|
||||
|
||||
function! ale_linters#go#gometalinter#GetMatches(lines) abort
|
||||
@@ -36,13 +26,10 @@ function! ale_linters#go#gometalinter#GetMatches(lines) abort
|
||||
endfunction
|
||||
|
||||
function! ale_linters#go#gometalinter#Handler(buffer, lines) abort
|
||||
let l:dir = expand('#' . a:buffer . ':p:h')
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale_linters#go#gometalinter#GetMatches(a:lines)
|
||||
" l:match[1] will already be an absolute path, output from gometalinter
|
||||
call add(l:output, {
|
||||
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'col': l:match[3] + 0,
|
||||
\ 'type': tolower(l:match[4]) is# 'warning' ? 'W' : 'E',
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
" Author: Ben Reedy <https://github.com/breed808>
|
||||
" Description: gosimple for Go files
|
||||
|
||||
function! ale_linters#go#gosimple#GetCommand(buffer) abort
|
||||
return ale#path#BufferCdString(a:buffer) . ' gosimple .'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('go', {
|
||||
\ 'name': 'gosimple',
|
||||
\ 'executable': 'gosimple',
|
||||
\ 'command_callback': 'ale_linters#go#gosimple#GetCommand',
|
||||
\ 'callback': 'ale#handlers#go#Handler',
|
||||
\ 'command': 'gosimple %s',
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\ 'output_stream': 'both',
|
||||
\ 'lint_file': 1,
|
||||
\})
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
" Author: Jelte Fennema <github-public@jeltef.nl>
|
||||
" Description: gotype for Go files
|
||||
|
||||
function! ale_linters#go#gotype#GetCommand(buffer) abort
|
||||
if expand('#' . a:buffer . ':p') =~# '_test\.go$'
|
||||
return
|
||||
endif
|
||||
|
||||
|
||||
return ale#path#BufferCdString(a:buffer) . ' gotype .'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('go', {
|
||||
\ 'name': 'gotype',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': 'gotype',
|
||||
\ 'command_callback': 'ale_linters#go#gotype#GetCommand',
|
||||
\ 'callback': 'ale#handlers#go#Handler',
|
||||
\ 'lint_file': 1,
|
||||
\})
|
||||
@@ -1,18 +1,10 @@
|
||||
" Author: neersighted <bjorn@neersighted.com>
|
||||
" Description: go vet for Go files
|
||||
"
|
||||
" Author: John Eikenberry <jae@zhar.net>
|
||||
" Description: updated to work with go1.10
|
||||
|
||||
function! ale_linters#go#govet#GetCommand(buffer) abort
|
||||
return ale#path#BufferCdString(a:buffer) . ' go vet .'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('go', {
|
||||
\ 'name': 'go vet',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': 'go',
|
||||
\ 'command_callback': 'ale_linters#go#govet#GetCommand',
|
||||
\ 'callback': 'ale#handlers#go#Handler',
|
||||
\ 'lint_file': 1,
|
||||
\ 'command': 'go vet %t',
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsError',
|
||||
\})
|
||||
|
||||
@@ -1,33 +1,11 @@
|
||||
" Author: Ben Reedy <https://github.com/breed808>
|
||||
" Description: staticcheck for Go files
|
||||
|
||||
call ale#Set('go_staticcheck_options', '')
|
||||
call ale#Set('go_staticcheck_lint_package', 0)
|
||||
|
||||
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')
|
||||
|
||||
" 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'
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
|
||||
endif
|
||||
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . 'staticcheck'
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' ' . ale#Escape(l:filename)
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('go', {
|
||||
\ 'name': 'staticcheck',
|
||||
\ 'executable': 'staticcheck',
|
||||
\ 'command_callback': 'ale_linters#go#staticcheck#GetCommand',
|
||||
\ 'callback': 'ale#handlers#go#Handler',
|
||||
\ 'command': 'staticcheck %s',
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\ 'output_stream': 'both',
|
||||
\ 'lint_file': 1,
|
||||
\})
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
" Author: Benjie Gillam <code@benjiegillam.com>
|
||||
" Description: eslint for GraphQL files
|
||||
|
||||
call ale#linter#Define('graphql', {
|
||||
\ 'name': 'eslint',
|
||||
\ 'executable_callback': 'ale#handlers#eslint#GetExecutable',
|
||||
\ 'command_callback': 'ale#handlers#eslint#GetCommand',
|
||||
\ 'callback': 'ale#handlers#eslint#Handle',
|
||||
\})
|
||||
@@ -1,31 +1,6 @@
|
||||
" Author: Patrick Lewis - https://github.com/patricklewis, thenoseman - https://github.com/thenoseman
|
||||
" Author: Patrick Lewis - https://github.com/patricklewis
|
||||
" Description: haml-lint for Haml files
|
||||
|
||||
function! ale_linters#haml#hamllint#GetCommand(buffer) abort
|
||||
let l:prefix = ''
|
||||
|
||||
let l:rubocop_config_file_path = ale#path#FindNearestFile(a:buffer, '.rubocop.yml')
|
||||
let l:hamllint_config_file_path = ale#path#FindNearestFile(a:buffer, '.haml-lint.yml')
|
||||
|
||||
" Set HAML_LINT_RUBOCOP_CONF variable as it is needed for haml-lint to
|
||||
" pick up the rubocop config.
|
||||
"
|
||||
" See https://github.com/brigade/haml-lint/blob/master/lib/haml_lint/linter/rubocop.rb#L89
|
||||
" HamlLint::Linter::RuboCop#rubocop_flags
|
||||
if !empty(l:rubocop_config_file_path)
|
||||
if ale#Has('win32')
|
||||
let l:prefix = 'set HAML_LINT_RUBOCOP_CONF=' . ale#Escape(l:rubocop_config_file_path) . ' &&'
|
||||
else
|
||||
let l:prefix = 'HAML_LINT_RUBOCOP_CONF=' . ale#Escape(l:rubocop_config_file_path)
|
||||
endif
|
||||
endif
|
||||
|
||||
return (!empty(l:prefix) ? l:prefix . ' ' : '')
|
||||
\ . 'haml-lint'
|
||||
\ . (!empty(l:hamllint_config_file_path) ? ' --config ' . ale#Escape(l:hamllint_config_file_path) : '')
|
||||
\ . ' %t'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#haml#hamllint#Handle(buffer, lines) abort
|
||||
" Matches patterns like the following:
|
||||
" <path>:51 [W] RuboCop: Use the new Ruby 1.9 hash syntax.
|
||||
@@ -46,6 +21,6 @@ endfunction
|
||||
call ale#linter#Define('haml', {
|
||||
\ 'name': 'hamllint',
|
||||
\ 'executable': 'haml-lint',
|
||||
\ 'command_callback': 'ale_linters#haml#hamllint#GetCommand',
|
||||
\ 'command': 'haml-lint %t',
|
||||
\ 'callback': 'ale_linters#haml#hamllint#Handle'
|
||||
\})
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
" Description: Ember-template-lint for checking Handlebars files
|
||||
|
||||
call ale#Set('handlebars_embertemplatelint_executable', 'ember-template-lint')
|
||||
call ale#Set('handlebars_embertemplatelint_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('handlebars_embertemplatelint_use_global', 0)
|
||||
|
||||
function! ale_linters#handlebars#embertemplatelint#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'handlebars_embertemplatelint', [
|
||||
@@ -22,13 +22,15 @@ function! ale_linters#handlebars#embertemplatelint#Handle(buffer, lines) abort
|
||||
for l:error in get(values(l:json), 0, [])
|
||||
if has_key(l:error, 'fatal')
|
||||
call add(l:output, {
|
||||
\ 'lnum': get(l:error, 'line', 1),
|
||||
\ 'col': get(l:error, 'column', 1),
|
||||
\ 'bufnr': a:buffer,
|
||||
\ 'lnum': 1,
|
||||
\ 'col': 1,
|
||||
\ 'text': l:error.message,
|
||||
\ 'type': l:error.severity == 1 ? 'W' : 'E',
|
||||
\})
|
||||
else
|
||||
call add(l:output, {
|
||||
\ 'bufnr': a:buffer,
|
||||
\ 'lnum': l:error.line,
|
||||
\ 'col': l:error.column,
|
||||
\ 'text': l:error.rule . ': ' . l:error.message,
|
||||
|
||||
@@ -1,18 +1,10 @@
|
||||
" Author: w0rp <devw0rp@gmail.com>
|
||||
" Description: ghc for Haskell files
|
||||
|
||||
call ale#Set('haskell_ghc_options', '-fno-code -v0')
|
||||
|
||||
function! ale_linters#haskell#ghc#GetCommand(buffer) abort
|
||||
return 'ghc '
|
||||
\ . ale#Var(a:buffer, 'haskell_ghc_options')
|
||||
\ . ' %t'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('haskell', {
|
||||
\ 'name': 'ghc',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': 'ghc',
|
||||
\ 'command_callback': 'ale_linters#haskell#ghc#GetCommand',
|
||||
\ 'command': 'ghc -fno-code -v0 %t',
|
||||
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
|
||||
\})
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
" Description: hdevtools for Haskell files
|
||||
|
||||
call ale#Set('haskell_hdevtools_executable', 'hdevtools')
|
||||
call ale#Set('haskell_hdevtools_options', get(g:, 'hdevtools_options', '-g -Wall'))
|
||||
call ale#Set('haskell_hdevtools_options', '-g -Wall')
|
||||
|
||||
function! ale_linters#haskell#hdevtools#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'haskell_hdevtools_executable')
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
" Author: Johannes Wienke <languitar@semipol.de>
|
||||
" Description: alex for help files
|
||||
|
||||
call ale#linter#Define('help', {
|
||||
\ 'name': 'alex',
|
||||
\ 'executable': 'alex',
|
||||
\ 'command': 'alex %s -t',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'callback': 'ale#handlers#alex#Handle',
|
||||
\ 'lint_file': 1,
|
||||
\})
|
||||
@@ -1,9 +0,0 @@
|
||||
" Author: Sumner Evans <sumner.evans98@gmail.com>
|
||||
" Description: write-good for vim Help files
|
||||
|
||||
call ale#linter#Define('help', {
|
||||
\ 'name': 'write-good',
|
||||
\ 'executable_callback': 'ale#handlers#writegood#GetExecutable',
|
||||
\ 'command_callback': 'ale#handlers#writegood#GetCommand',
|
||||
\ 'callback': 'ale#handlers#writegood#Handle',
|
||||
\})
|
||||
@@ -1,11 +0,0 @@
|
||||
" Author: Johannes Wienke <languitar@semipol.de>
|
||||
" Description: alex for HTML files
|
||||
|
||||
call ale#linter#Define('html', {
|
||||
\ 'name': 'alex',
|
||||
\ 'executable': 'alex',
|
||||
\ 'command': 'alex %s -t',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'callback': 'ale#handlers#alex#Handle',
|
||||
\ 'lint_file': 1,
|
||||
\})
|
||||
@@ -1,9 +1,9 @@
|
||||
" Author: KabbAmine <amine.kabb@gmail.com>, deathmaz <00maz1987@gmail.com>, diartyz <diartyz@gmail.com>
|
||||
" Description: HTMLHint for checking html files
|
||||
|
||||
call ale#Set('html_htmlhint_options', '')
|
||||
call ale#Set('html_htmlhint_options', '--format=unix')
|
||||
call ale#Set('html_htmlhint_executable', 'htmlhint')
|
||||
call ale#Set('html_htmlhint_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('html_htmlhint_use_global', 0)
|
||||
|
||||
function! ale_linters#html#htmlhint#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'html_htmlhint', [
|
||||
@@ -12,22 +12,9 @@ function! ale_linters#html#htmlhint#GetExecutable(buffer) abort
|
||||
endfunction
|
||||
|
||||
function! ale_linters#html#htmlhint#GetCommand(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'html_htmlhint_options')
|
||||
let l:config = l:options !~# '--config'
|
||||
\ ? ale#path#FindNearestFile(a:buffer, '.htmlhintrc')
|
||||
\ : ''
|
||||
|
||||
if !empty(l:config)
|
||||
let l:options .= ' --config ' . ale#Escape(l:config)
|
||||
endif
|
||||
|
||||
if !empty(l:options)
|
||||
let l:options = substitute(l:options, '--format=unix', '', '')
|
||||
endif
|
||||
|
||||
return ale#Escape(ale_linters#html#htmlhint#GetExecutable(a:buffer))
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' --format=unix %t'
|
||||
return ale_linters#html#htmlhint#GetExecutable(a:buffer)
|
||||
\ . ' ' . ale#Var(a:buffer, 'html_htmlhint_options')
|
||||
\ . ' %t'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('html', {
|
||||
|
||||
@@ -3,19 +3,11 @@
|
||||
|
||||
" CLI options
|
||||
let g:ale_html_tidy_executable = get(g:, 'ale_html_tidy_executable', 'tidy')
|
||||
" remove in 2.0
|
||||
" Look for the old _args variable first.
|
||||
let s:deprecation_warning_echoed = 0
|
||||
let s:default_options = get(g:, 'ale_html_tidy_args', '-q -e -language en')
|
||||
let g:ale_html_tidy_options = get(g:, 'ale_html_tidy_options', s:default_options)
|
||||
|
||||
function! ale_linters#html#tidy#GetCommand(buffer) abort
|
||||
" remove in 2.0
|
||||
if exists('g:ale_html_tidy_args') && !s:deprecation_warning_echoed
|
||||
execute 'echom ''Rename your g:ale_html_tidy_args setting to g:ale_html_tidy_options instead. Support for this will removed in ALE 2.0.'''
|
||||
let s:deprecation_warning_echoed = 1
|
||||
endif
|
||||
|
||||
" Specify file encoding in options
|
||||
" (Idea taken from https://github.com/scrooloose/syntastic/blob/master/syntax_checkers/html/tidy.vim)
|
||||
let l:file_encoding = get({
|
||||
@@ -33,16 +25,8 @@ function! ale_linters#html#tidy#GetCommand(buffer) abort
|
||||
\ 'utf-8': '-utf8',
|
||||
\ }, &fileencoding, '-utf8')
|
||||
|
||||
" On macOS, old tidy (released on 31 Oct 2006) is installed. It does not
|
||||
" consider HTML5 so we should avoid it.
|
||||
let l:executable = ale#Var(a:buffer, 'html_tidy_executable')
|
||||
if has('mac') && l:executable is# 'tidy' && exists('*exepath')
|
||||
\ && exepath(l:executable) is# '/usr/bin/tidy'
|
||||
return ''
|
||||
endif
|
||||
|
||||
return printf('%s %s %s -',
|
||||
\ l:executable,
|
||||
\ ale#Var(a:buffer, 'html_tidy_executable'),
|
||||
\ ale#Var(a:buffer, 'html_tidy_options'),
|
||||
\ l:file_encoding
|
||||
\)
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
" Author: Sumner Evans <sumner.evans98@gmail.com>
|
||||
" Description: write-good for nroff files
|
||||
|
||||
call ale#linter#Define('html', {
|
||||
\ 'name': 'write-good',
|
||||
\ 'executable_callback': 'ale#handlers#writegood#GetExecutable',
|
||||
\ 'command_callback': 'ale#handlers#writegood#GetCommand',
|
||||
\ 'callback': 'ale#handlers#writegood#Handle',
|
||||
\})
|
||||
@@ -2,17 +2,27 @@
|
||||
" Description: checkstyle for Java files
|
||||
|
||||
function! ale_linters#java#checkstyle#Handle(buffer, lines) abort
|
||||
let l:pattern = '\v\[(WARN|ERROR)\] [a-zA-Z]?:?[^:]+:(\d+):(\d+)?:? (.*) \[(.+)\]$'
|
||||
let l:patterns = [
|
||||
\ '\v\[(WARN|ERROR)\] .*:(\d+):(\d+): (.*)',
|
||||
\ '\v\[(WARN|ERROR)\] .*:(\d+): (.*)',
|
||||
\]
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'type': l:match[1] is? 'WARN' ? 'W' : 'E',
|
||||
for l:match in ale#util#GetMatches(a:lines, l:patterns)
|
||||
let l:args = {
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'col': l:match[3] + 0,
|
||||
\ 'text': l:match[4],
|
||||
\ 'code': l:match[5],
|
||||
\})
|
||||
\ 'type': l:match[1] =~? 'WARN' ? 'W' : 'E'
|
||||
\ }
|
||||
|
||||
let l:col = l:match[3] + 0
|
||||
if l:col > 0
|
||||
let l:args['col'] = l:col
|
||||
let l:args['text'] = l:match[4]
|
||||
else
|
||||
let l:args['text'] = l:match[3]
|
||||
endif
|
||||
|
||||
call add(l:output, l:args)
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
|
||||
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', '')
|
||||
let g:ale_java_javac_options = get(g:, 'ale_java_javac_options', '')
|
||||
let g:ale_java_javac_classpath = get(g:, 'ale_java_javac_classpath', '')
|
||||
|
||||
function! ale_linters#java#javac#GetImportPaths(buffer) abort
|
||||
let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml')
|
||||
@@ -36,54 +35,24 @@ function! s:BuildClassPathOption(buffer, import_paths) abort
|
||||
\ : ''
|
||||
endfunction
|
||||
|
||||
function! ale_linters#java#javac#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'java_javac_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#java#javac#GetCommand(buffer, import_paths) abort
|
||||
let l:cp_option = s:BuildClassPathOption(a:buffer, a:import_paths)
|
||||
let l:sp_option = ''
|
||||
|
||||
" Find the src directory, for files in this project.
|
||||
let l:src_dir = ale#path#FindNearestDirectory(a:buffer, 'src/main/java')
|
||||
let l:sp_dirs = []
|
||||
|
||||
if !empty(l:src_dir)
|
||||
call add(l:sp_dirs, l:src_dir)
|
||||
|
||||
" Automatically include the jaxb directory too, if it's there.
|
||||
let l:jaxb_dir = fnamemodify(l:src_dir, ':h:h')
|
||||
\ . (has('win32') ? '\jaxb\' : '/jaxb/')
|
||||
|
||||
if isdirectory(l:jaxb_dir)
|
||||
call add(l:sp_dirs, l:jaxb_dir)
|
||||
endif
|
||||
|
||||
" Automatically include the test directory, but only for test code.
|
||||
if expand('#' . a:buffer . ':p') =~? '\vsrc[/\\]test[/\\]java'
|
||||
let l:test_dir = fnamemodify(l:src_dir, ':h:h:h')
|
||||
\ . (has('win32') ? '\test\java\' : '/test/java/')
|
||||
|
||||
if isdirectory(l:test_dir)
|
||||
call add(l:sp_dirs, l:test_dir)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if !empty(l:sp_dirs)
|
||||
let l:sp_option = '-sourcepath '
|
||||
\ . ale#Escape(join(l:sp_dirs, s:classpath_sep))
|
||||
let l:sp_option = '-sourcepath ' . ale#Escape(l:src_dir)
|
||||
endif
|
||||
|
||||
" Create .class files in a temporary directory, which we will delete later.
|
||||
let l:class_file_directory = ale#engine#CreateDirectory(a:buffer)
|
||||
let l:executable = ale_linters#java#javac#GetExecutable(a:buffer)
|
||||
|
||||
" Always run javac from the directory the file is in, so we can resolve
|
||||
" relative paths correctly.
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#Escape(l:executable)
|
||||
\ . ' -Xlint'
|
||||
\ . 'javac -Xlint'
|
||||
\ . ' ' . l:cp_option
|
||||
\ . ' ' . l:sp_option
|
||||
\ . ' -d ' . ale#Escape(l:class_file_directory)
|
||||
@@ -126,7 +95,7 @@ endfunction
|
||||
|
||||
call ale#linter#Define('java', {
|
||||
\ 'name': 'javac',
|
||||
\ 'executable_callback': 'ale_linters#java#javac#GetExecutable',
|
||||
\ 'executable': 'javac',
|
||||
\ 'command_chain': [
|
||||
\ {'callback': 'ale_linters#java#javac#GetImportPaths', 'output_stream': 'stdout'},
|
||||
\ {'callback': 'ale_linters#java#javac#GetCommand', 'output_stream': 'stderr'},
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
" Author: Johannes Wienke <languitar@semipol.de>
|
||||
" Description: PMD for Java files
|
||||
|
||||
function! ale_linters#java#pmd#Handle(buffer, lines) abort
|
||||
let l:pattern = '"\(\d\+\)",".\+","\(.\+\)","\(\d\+\)","\(\d\+\)","\(.\+\)","\(.\+\)","\(.\+\)"$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'type': 'W',
|
||||
\ 'lnum': l:match[4] + 0,
|
||||
\ 'text': l:match[5],
|
||||
\ 'code': l:match[6] . ' - ' . l:match[7],
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
function! ale_linters#java#pmd#GetCommand(buffer) abort
|
||||
return 'pmd '
|
||||
\ . ale#Var(a:buffer, 'java_pmd_options')
|
||||
\ . ' -f csv'
|
||||
\ . ' -d %t'
|
||||
endfunction
|
||||
|
||||
if !exists('g:ale_java_pmd_options')
|
||||
let g:ale_java_pmd_options = '-R category/java/bestpractices.xml'
|
||||
endif
|
||||
|
||||
call ale#linter#Define('java', {
|
||||
\ 'name': 'pmd',
|
||||
\ 'executable': 'pmd',
|
||||
\ 'command_callback': 'ale_linters#java#pmd#GetCommand',
|
||||
\ 'callback': 'ale_linters#java#pmd#Handle',
|
||||
\})
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
call ale#linter#Define('javascript', {
|
||||
\ 'name': 'eslint',
|
||||
\ 'output_stream': 'both',
|
||||
\ 'executable_callback': 'ale#handlers#eslint#GetExecutable',
|
||||
\ 'command_callback': 'ale#handlers#eslint#GetCommand',
|
||||
\ 'callback': 'ale#handlers#eslint#Handle',
|
||||
|
||||
108
ale_linters/javascript/flow.vim
Executable file → Normal file
108
ale_linters/javascript/flow.vim
Executable file → Normal file
@@ -1,13 +1,21 @@
|
||||
" Author: Zach Perrault -- @zperrault
|
||||
" Author: Florian Beeres <yuuki@protonmail.com>
|
||||
" Description: FlowType checking for JavaScript files
|
||||
|
||||
call ale#Set('javascript_flow_executable', 'flow')
|
||||
call ale#Set('javascript_flow_use_home_config', 0)
|
||||
call ale#Set('javascript_flow_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('javascript_flow_use_respect_pragma', 1)
|
||||
call ale#Set('javascript_flow_use_global', 0)
|
||||
|
||||
function! ale_linters#javascript#flow#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'javascript_flow', [
|
||||
\ 'node_modules/.bin/flow',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#javascript#flow#VersionCheck(buffer) abort
|
||||
return ale#Escape(ale_linters#javascript#flow#GetExecutable(a:buffer))
|
||||
\ . ' --version'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#javascript#flow#GetCommand(buffer, version_lines) abort
|
||||
let l:flow_config = ale#path#FindNearestFile(a:buffer, '.flowconfig')
|
||||
|
||||
if empty(l:flow_config)
|
||||
@@ -15,43 +23,18 @@ function! ale_linters#javascript#flow#GetExecutable(buffer) abort
|
||||
return ''
|
||||
endif
|
||||
|
||||
" Don't run Flow with a configuration file from the home directory by
|
||||
" default, which can eat all of your RAM.
|
||||
if fnamemodify(l:flow_config, ':h') is? $HOME
|
||||
\&& !ale#Var(a:buffer, 'javascript_flow_use_home_config')
|
||||
return ''
|
||||
endif
|
||||
|
||||
return ale#node#FindExecutable(a:buffer, 'javascript_flow', [
|
||||
\ 'node_modules/.bin/flow',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#javascript#flow#VersionCheck(buffer) abort
|
||||
let l:executable = ale_linters#javascript#flow#GetExecutable(a:buffer)
|
||||
|
||||
if empty(l:executable)
|
||||
return ''
|
||||
endif
|
||||
|
||||
return ale#Escape(l:executable) . ' --version'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#javascript#flow#GetCommand(buffer, version_lines) abort
|
||||
let l:executable = ale_linters#javascript#flow#GetExecutable(a:buffer)
|
||||
|
||||
if empty(l:executable)
|
||||
return ''
|
||||
endif
|
||||
|
||||
let l:version = ale#semver#GetVersion(l:executable, a:version_lines)
|
||||
let l:use_respect_pragma = 1
|
||||
|
||||
" If we can parse the version number, then only use --respect-pragma
|
||||
" if the version is >= 0.36.0, which added the argument.
|
||||
let l:use_respect_pragma = ale#Var(a:buffer, 'javascript_flow_use_respect_pragma')
|
||||
\ && (empty(l:version) || ale#semver#GTE(l:version, [0, 36]))
|
||||
for l:match in ale#util#GetMatches(a:version_lines, '\v\d+\.\d+\.\d+$')
|
||||
let l:use_respect_pragma = ale#semver#GreaterOrEqual(
|
||||
\ ale#semver#Parse(l:match[0]),
|
||||
\ [0, 36, 0]
|
||||
\)
|
||||
endfor
|
||||
|
||||
return ale#Escape(l:executable)
|
||||
return ale#Escape(ale_linters#javascript#flow#GetExecutable(a:buffer))
|
||||
\ . ' check-contents'
|
||||
\ . (l:use_respect_pragma ? ' --respect-pragma': '')
|
||||
\ . ' --json --from ale %s'
|
||||
@@ -73,44 +56,6 @@ function! s:GetJSONLines(lines) abort
|
||||
return a:lines[l:start_index :]
|
||||
endfunction
|
||||
|
||||
function! s:ExtraErrorMsg(current, new) abort
|
||||
let l:newMsg = ''
|
||||
|
||||
if a:current is# ''
|
||||
" extra messages appear to already have a :
|
||||
let l:newMsg = a:new
|
||||
else
|
||||
let l:newMsg = a:current . ' ' . a:new
|
||||
endif
|
||||
|
||||
return l:newMsg
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:GetDetails(error) abort
|
||||
let l:detail = ''
|
||||
|
||||
for l:extra_error in a:error.extra
|
||||
|
||||
if has_key(l:extra_error, 'message')
|
||||
for l:extra_message in l:extra_error.message
|
||||
let l:detail = s:ExtraErrorMsg(l:detail, l:extra_message.descr)
|
||||
endfor
|
||||
endif
|
||||
|
||||
if has_key(l:extra_error, 'children')
|
||||
for l:child in l:extra_error.children
|
||||
for l:child_message in l:child.message
|
||||
let l:detail = l:detail . ' ' . l:child_message.descr
|
||||
endfor
|
||||
endfor
|
||||
endif
|
||||
|
||||
endfor
|
||||
|
||||
return l:detail
|
||||
endfunction
|
||||
|
||||
function! ale_linters#javascript#flow#Handle(buffer, lines) abort
|
||||
let l:str = join(s:GetJSONLines(a:lines), '')
|
||||
|
||||
@@ -149,19 +94,12 @@ function! ale_linters#javascript#flow#Handle(buffer, lines) abort
|
||||
let l:text = l:text . ' See also: ' . l:error.operation.descr
|
||||
endif
|
||||
|
||||
let l:errorToAdd = {
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:line,
|
||||
\ 'col': l:col,
|
||||
\ 'text': l:text,
|
||||
\ 'type': has_key(l:error, 'level') && l:error.level is# 'error' ? 'E' : 'W',
|
||||
\}
|
||||
|
||||
if has_key(l:error, 'extra')
|
||||
let l:errorToAdd.detail = s:GetDetails(l:error)
|
||||
endif
|
||||
|
||||
call add(l:output, l:errorToAdd)
|
||||
|
||||
\ 'type': l:error.level is# 'error' ? 'E' : 'W',
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
" Description: jscs for JavaScript files
|
||||
|
||||
call ale#Set('javascript_jscs_executable', 'jscs')
|
||||
call ale#Set('javascript_jscs_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('javascript_jscs_use_global', 0)
|
||||
|
||||
function! ale_linters#javascript#jscs#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'javascript_jscs', [
|
||||
@@ -35,23 +35,19 @@ function! ale_linters#javascript#jscs#Handle(buffer, lines) abort
|
||||
"
|
||||
" foobar.js: line 2, col 1, Expected indentation of 1 characters
|
||||
"
|
||||
let l:pattern = '\v^.*:\s+line (\d+),\s+col\s+(\d+),\s+(.*)$'
|
||||
let l:pattern = '^.*:\s\+line \(\d\+\),\s\+col\s\+\(\d\+\),\s\+\(.*\)$'
|
||||
let l:output = []
|
||||
let l:m = ale#util#GetMatches(a:lines, [l:pattern])
|
||||
|
||||
for l:match in l:m
|
||||
let l:text = l:match[3]
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:obj = {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'col': l:match[2] + 0,
|
||||
\ 'text': l:match[3]
|
||||
\}
|
||||
|
||||
let l:code_match = matchlist(l:match[3], '\v([^ :]+): (.+)$')
|
||||
|
||||
if !empty(l:code_match)
|
||||
let l:obj.code = l:code_match[1]
|
||||
let l:obj.text = l:code_match[2]
|
||||
endif
|
||||
|
||||
call add(l:output, l:obj)
|
||||
endfor
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
" Description: JSHint for Javascript files
|
||||
|
||||
call ale#Set('javascript_jshint_executable', 'jshint')
|
||||
call ale#Set('javascript_jshint_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('javascript_jshint_use_global', 0)
|
||||
|
||||
function! ale_linters#javascript#jshint#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'javascript_jshint', [
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
" Description: standardjs for JavaScript files
|
||||
|
||||
call ale#Set('javascript_standard_executable', 'standard')
|
||||
call ale#Set('javascript_standard_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('javascript_standard_use_global', 0)
|
||||
call ale#Set('javascript_standard_options', '')
|
||||
|
||||
function! ale_linters#javascript#standard#GetExecutable(buffer) abort
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
" Description: xo for JavaScript files
|
||||
|
||||
call ale#Set('javascript_xo_executable', 'xo')
|
||||
call ale#Set('javascript_xo_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('javascript_xo_use_global', 0)
|
||||
call ale#Set('javascript_xo_options', '')
|
||||
|
||||
function! ale_linters#javascript#xo#GetExecutable(buffer) abort
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
" Author: zanona <https://github.com/zanona>, w0rp <devw0rp@gmail.com>
|
||||
" Description: This file adds support for checking Less code with lessc.
|
||||
|
||||
call ale#Set('less_lessc_executable', 'lessc')
|
||||
call ale#Set('less_lessc_options', '')
|
||||
call ale#Set('less_lessc_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
|
||||
function! ale_linters#less#lessc#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'less_lessc', [
|
||||
\ 'node_modules/.bin/lessc',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#less#lessc#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#less#lessc#GetExecutable(a:buffer)
|
||||
let l:dir = expand('#' . a:buffer . ':p:h')
|
||||
let l:options = ale#Var(a:buffer, 'less_lessc_options')
|
||||
|
||||
return ale#Escape(l:executable)
|
||||
\ . ' --no-color --lint'
|
||||
\ . ' --include-path=' . ale#Escape(l:dir)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' -'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#less#lessc#Handle(buffer, lines) abort
|
||||
let l:dir = expand('#' . a:buffer . ':p:h')
|
||||
" Matches patterns like the following:
|
||||
let l:pattern = '^\(\w\+\): \(.\{-}\) in \(.\{-}\) on line \(\d\+\), column \(\d\+\):$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:item = {
|
||||
\ 'lnum': l:match[4] + 0,
|
||||
\ 'col': l:match[5] + 0,
|
||||
\ 'text': l:match[2],
|
||||
\ 'type': 'E',
|
||||
\}
|
||||
|
||||
if l:match[3] isnot# '-'
|
||||
let l:item.filename = ale#path#GetAbsPath(l:dir, l:match[3])
|
||||
endif
|
||||
|
||||
call add(l:output, l:item)
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('less', {
|
||||
\ 'name': 'lessc',
|
||||
\ 'executable_callback': 'ale_linters#less#lessc#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#less#lessc#GetCommand',
|
||||
\ 'callback': 'ale_linters#less#lessc#Handle',
|
||||
\ 'output_stream': 'stderr',
|
||||
\})
|
||||
@@ -1,27 +0,0 @@
|
||||
" Author: diartyz <diartyz@gmail.com>, w0rp <devw0rp@gmail.com>
|
||||
|
||||
call ale#Set('less_stylelint_executable', 'stylelint')
|
||||
call ale#Set('less_stylelint_options', '')
|
||||
call ale#Set('less_stylelint_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
|
||||
function! ale_linters#less#stylelint#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'less_stylelint', [
|
||||
\ 'node_modules/.bin/stylelint',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#less#stylelint#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#less#stylelint#GetExecutable(a:buffer)
|
||||
let l:options = ale#Var(a:buffer, 'less_stylelint_options')
|
||||
|
||||
return ale#Escape(l:executable)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' --stdin-filename %s'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('less', {
|
||||
\ 'name': 'stylelint',
|
||||
\ 'executable_callback': 'ale_linters#less#stylelint#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#less#stylelint#GetCommand',
|
||||
\ 'callback': 'ale#handlers#css#HandleStyleLintFormat',
|
||||
\})
|
||||
@@ -1,40 +0,0 @@
|
||||
" Author: Jon Xie https://github.com/xiejiangzhi
|
||||
" Description: luac linter for lua files
|
||||
|
||||
call ale#Set('lua_luac_executable', 'luac')
|
||||
|
||||
function! ale_linters#lua#luac#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'lua_luac_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#lua#luac#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#lua#luac#GetExecutable(a:buffer)
|
||||
return ale#Escape(l:executable) . ' -p - '
|
||||
endfunction
|
||||
|
||||
function! ale_linters#lua#luac#Handle(buffer, lines) abort
|
||||
" Matches patterns line the following:
|
||||
"
|
||||
" luac: stdin:5: '=' expected near ')'
|
||||
" luac: stdin:8: ')' expected (to close '(' at line 6) near '123'
|
||||
let l:pattern = '\v^.*:(\d+): (.+)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'type': 'E',
|
||||
\ 'text': l:match[2],
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('lua', {
|
||||
\ 'name': 'luac',
|
||||
\ 'executable_callback': 'ale_linters#lua#luac#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#lua#luac#GetCommand',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'callback': 'ale_linters#lua#luac#Handle',
|
||||
\})
|
||||
@@ -35,9 +35,8 @@ function! ale_linters#lua#luacheck#Handle(buffer, lines) abort
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'col': l:match[2] + 0,
|
||||
\ 'text': l:match[3] . l:match[4] . ': ' . l:match[5],
|
||||
\ 'type': l:match[3],
|
||||
\ 'code': l:match[3] . l:match[4],
|
||||
\ 'text': l:match[5],
|
||||
\})
|
||||
endfor
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
" Author: Johannes Wienke <languitar@semipol.de>
|
||||
" Description: alex for HTML files
|
||||
|
||||
call ale#linter#Define('mail', {
|
||||
\ 'name': 'alex',
|
||||
\ 'executable': 'alex',
|
||||
\ 'command': 'alex %s -t',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'callback': 'ale#handlers#alex#Handle',
|
||||
\ 'lint_file': 1,
|
||||
\})
|
||||
@@ -1,9 +0,0 @@
|
||||
" Author: Daniel M. Capella https://github.com/polyzen
|
||||
" Description: proselint for mail files
|
||||
|
||||
call ale#linter#Define('mail', {
|
||||
\ 'name': 'proselint',
|
||||
\ 'executable': 'proselint',
|
||||
\ 'command': 'proselint %t',
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\})
|
||||
@@ -1,9 +0,0 @@
|
||||
" Author: chew-z https://github.com/chew-z
|
||||
" Description: vale for Markdown files
|
||||
|
||||
call ale#linter#Define('mail', {
|
||||
\ 'name': 'vale',
|
||||
\ 'executable': 'vale',
|
||||
\ 'command': 'vale --output=JSON %t',
|
||||
\ 'callback': 'ale#handlers#vale#Handle',
|
||||
\})
|
||||
@@ -1,24 +0,0 @@
|
||||
" Author: aurieh - https://github.com/aurieh
|
||||
|
||||
function! ale_linters#make#checkmake#Handle(buffer, lines) abort
|
||||
let l:pattern = '\v^(\d+):(.+):(.+)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'bufnr': a:buffer,
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'type': 'E',
|
||||
\ 'code': l:match[2],
|
||||
\ 'text': l:match[3],
|
||||
\})
|
||||
endfor
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('make', {
|
||||
\ 'name': 'checkmake',
|
||||
\ 'executable': 'checkmake',
|
||||
\ 'command': 'checkmake %s --format="{{.LineNumber}}:{{.Rule}}:{{.Violation}}"',
|
||||
\ 'callback': 'ale_linters#make#checkmake#Handle',
|
||||
\})
|
||||
@@ -1,11 +0,0 @@
|
||||
" Author: Johannes Wienke <languitar@semipol.de>
|
||||
" Description: alex for markdown files
|
||||
|
||||
call ale#linter#Define('markdown', {
|
||||
\ 'name': 'alex',
|
||||
\ 'executable': 'alex',
|
||||
\ 'command': 'alex %s -t',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'callback': 'ale#handlers#alex#Handle',
|
||||
\ 'lint_file': 1,
|
||||
\})
|
||||
@@ -1,11 +0,0 @@
|
||||
" Author: Ty-Lucas Kelley <tylucaskelley@gmail.com>
|
||||
" Description: Adds support for markdownlint
|
||||
|
||||
call ale#linter#Define('markdown', {
|
||||
\ 'name': 'markdownlint',
|
||||
\ 'executable': 'markdownlint',
|
||||
\ 'lint_file': 1,
|
||||
\ 'output_stream': 'both',
|
||||
\ 'command': 'markdownlint %s',
|
||||
\ 'callback': 'ale#handlers#markdownlint#Handle'
|
||||
\ })
|
||||
@@ -1,24 +1,5 @@
|
||||
" Author: Steve Dignam <steve@dignam.xyz>, Josh Leeb-du Toit <joshleeb.com>
|
||||
" Description: Support for mdl, a markdown linter.
|
||||
|
||||
call ale#Set('markdown_mdl_executable', 'mdl')
|
||||
call ale#Set('markdown_mdl_options', '')
|
||||
|
||||
function! ale_linters#markdown#mdl#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'markdown_mdl_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#markdown#mdl#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#markdown#mdl#GetExecutable(a:buffer)
|
||||
let l:exec_args = l:executable =~? 'bundle$'
|
||||
\ ? ' exec mdl'
|
||||
\ : ''
|
||||
|
||||
let l:options = ale#Var(a:buffer, 'markdown_mdl_options')
|
||||
|
||||
return ale#Escape(l:executable) . l:exec_args
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
endfunction
|
||||
" Author: Steve Dignam <steve@dignam.xyz>
|
||||
" Description: Support for mdl, a markdown linter
|
||||
|
||||
function! ale_linters#markdown#mdl#Handle(buffer, lines) abort
|
||||
" matches: '(stdin):173: MD004 Unordered list style'
|
||||
@@ -38,7 +19,7 @@ endfunction
|
||||
|
||||
call ale#linter#Define('markdown', {
|
||||
\ 'name': 'mdl',
|
||||
\ 'executable_callback': 'ale_linters#markdown#mdl#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#markdown#mdl#GetCommand',
|
||||
\ 'executable': 'mdl',
|
||||
\ 'command': 'mdl',
|
||||
\ 'callback': 'ale_linters#markdown#mdl#Handle'
|
||||
\})
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
" Author: rhysd https://rhysd.github.io
|
||||
" Description: Redpen, a proofreading tool (http://redpen.cc)
|
||||
|
||||
call ale#linter#Define('markdown', {
|
||||
\ 'name': 'redpen',
|
||||
\ 'executable': 'redpen',
|
||||
\ 'command': 'redpen -f markdown -r json %t',
|
||||
\ 'callback': 'ale#handlers#redpen#HandleRedpenOutput',
|
||||
\})
|
||||
@@ -1,24 +1,18 @@
|
||||
" Author rhysd https://rhysd.github.io/, Dirk Roorda (dirkroorda), Adrián González Rus (@adrigzr)
|
||||
" Author rhysd https://rhysd.github.io/
|
||||
" Description: remark-lint for Markdown files
|
||||
|
||||
function! ale_linters#markdown#remark_lint#Handle(buffer, lines) abort
|
||||
" matches: ' 1:4 warning Incorrect list-item indent: add 1 space list-item-indent remark-lint'
|
||||
" matches: ' 18:71-19:1 error Missing new line after list item list-item-spacing remark-lint',
|
||||
let l:pattern = '^ \+\(\d\+\):\(\d\+\)\(-\(\d\+\):\(\d\+\)\)\? \(warning\|error\) \(.\+\)$'
|
||||
let l:pattern = '^ \+\(\d\+\):\(\d\+\) \(warning\|error\) \(.\+\)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:item = {
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'col': l:match[2] + 0,
|
||||
\ 'type': l:match[6] is# 'error' ? 'E' : 'W',
|
||||
\ 'text': l:match[7],
|
||||
\}
|
||||
if l:match[3] isnot# ''
|
||||
let l:item.end_lnum = l:match[4] + 0
|
||||
let l:item.end_col = l:match[5] + 0
|
||||
endif
|
||||
call add(l:output, l:item)
|
||||
\ 'type': l:match[3] is# 'error' ? 'E' : 'W',
|
||||
\ 'text': l:match[4],
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
" Author: tokida https://rouger.info, Yasuhiro Kiyota <yasuhiroki.duck@gmail.com>
|
||||
" Description: textlint, a proofreading tool (https://textlint.github.io/)
|
||||
|
||||
call ale#linter#Define('markdown', {
|
||||
\ 'name': 'textlint',
|
||||
\ 'executable_callback': 'ale#handlers#textlint#GetExecutable',
|
||||
\ 'command_callback': 'ale#handlers#textlint#GetCommand',
|
||||
\ 'callback': 'ale#handlers#textlint#HandleTextlintOutput',
|
||||
\})
|
||||
@@ -4,6 +4,6 @@
|
||||
call ale#linter#Define('markdown', {
|
||||
\ 'name': 'vale',
|
||||
\ 'executable': 'vale',
|
||||
\ 'command': 'vale --output=JSON %t',
|
||||
\ 'callback': 'ale#handlers#vale#Handle',
|
||||
\ 'command': 'vale --output=line %t',
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\})
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
" Author: Sumner Evans <sumner.evans98@gmail.com>
|
||||
" Description: write-good for Markdown files
|
||||
|
||||
call ale#linter#Define('markdown', {
|
||||
\ 'name': 'write-good',
|
||||
\ 'executable_callback': 'ale#handlers#writegood#GetExecutable',
|
||||
\ 'command_callback': 'ale#handlers#writegood#GetCommand',
|
||||
\ 'callback': 'ale#handlers#writegood#Handle',
|
||||
\})
|
||||
@@ -1,45 +0,0 @@
|
||||
" Author: stewy33 <slocumstewy@gmail.com>
|
||||
" Description: Lints mercury files using mmc
|
||||
|
||||
call ale#Set('mercury_mmc_executable', 'mmc')
|
||||
call ale#Set('mercury_mmc_options', '--make --output-compile-error-lines 100')
|
||||
|
||||
function! ale_linters#mercury#mmc#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'mercury_mmc_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#mercury#mmc#GetCommand(buffer) abort
|
||||
let l:module_name = expand('#' . a:buffer . ':t:r')
|
||||
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . ale_linters#mercury#mmc#GetExecutable(a:buffer)
|
||||
\ . ' --errorcheck-only '
|
||||
\ . ale#Var(a:buffer, 'mercury_mmc_options')
|
||||
\ . ' ' . l:module_name
|
||||
endfunction
|
||||
|
||||
function! ale_linters#mercury#mmc#Handle(buffer, lines) abort
|
||||
" output format
|
||||
" <filename>:<line>: <issue type>: <message>
|
||||
let l:pattern = '\v^\w+\.m:(\d+):\s+([W|w]arning|.*[E|e]rror.*): (.*)'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'lnum': substitute(l:match[1], '\v^0*', '', '') + 0,
|
||||
\ 'type': l:match[2][0] =~? 'W' ? 'W' : 'E',
|
||||
\ 'text': l:match[2] . ': ' . l:match[3]
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('mercury', {
|
||||
\ 'name': 'mmc',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable_callback': 'ale_linters#mercury#mmc#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#mercury#mmc#GetCommand',
|
||||
\ 'callback': 'ale_linters#mercury#mmc#Handle',
|
||||
\ 'lint_file': 1,
|
||||
\})
|
||||
@@ -1,50 +0,0 @@
|
||||
" Author: Oyvind Ingvaldsen <oyvind.ingvaldsen@gmail.com>
|
||||
" Description: NASM linter for asmsyntax nasm.
|
||||
|
||||
call ale#Set('nasm_nasm_executable', 'nasm')
|
||||
call ale#Set('nasm_nasm_options', '')
|
||||
|
||||
function! ale_linters#nasm#nasm#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'nasm_nasm_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#nasm#nasm#GetOptions(buffer) abort
|
||||
return ale#Var(a:buffer, 'nasm_nasm_options')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#nasm#nasm#GetCommand(buffer) abort
|
||||
" Note that NASM require a trailing slash to the -I option.
|
||||
let l:executable = ale#Escape(ale_linters#nasm#nasm#GetExecutable(a:buffer))
|
||||
let l:separator = has('win32') ? '\' : '/'
|
||||
let l:path = ale#Escape(fnamemodify(bufname(a:buffer), ':p:h') . l:separator)
|
||||
let l:options = ale_linters#nasm#nasm#GetOptions(a:buffer)
|
||||
|
||||
return l:executable
|
||||
\ . ' -X gnu'
|
||||
\ . ' -I ' . l:path
|
||||
\ . ' ' . l:options
|
||||
\ . ' %s'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#nasm#nasm#Handle(buffer, lines) abort
|
||||
" Note that we treat 'fatal' as errors.
|
||||
let l:pattern = '^.\+:\(\d\+\): \([^:]\+\): \(.\+\)$'
|
||||
let l:output = []
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'type': l:match[2] =~? 'error\|fatal' ? 'E' : 'W',
|
||||
\ 'text': l:match[3],
|
||||
\})
|
||||
endfor
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('nasm', {
|
||||
\ 'name': 'nasm',
|
||||
\ 'executable': 'nasm',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'lint_file': 1,
|
||||
\ 'command_callback': 'ale_linters#nasm#nasm#GetCommand',
|
||||
\ 'callback': 'ale_linters#nasm#nasm#Handle',
|
||||
\})
|
||||
@@ -10,40 +10,33 @@ function! ale_linters#nim#nimcheck#Handle(buffer, lines) abort
|
||||
" Only show errors of the current buffer
|
||||
" NOTE: Checking filename only is OK because nim enforces unique
|
||||
" module names.
|
||||
let l:temp_buffer_filename = fnamemodify(l:match[1], ':p:t')
|
||||
|
||||
let l:temp_buffer_filename = fnamemodify(l:match[1], ':p:t')
|
||||
if l:buffer_filename isnot# '' && l:temp_buffer_filename isnot# l:buffer_filename
|
||||
continue
|
||||
endif
|
||||
|
||||
let l:item = {
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'col': l:match[3] + 0,
|
||||
\ 'text': l:match[4],
|
||||
\ 'type': 'W',
|
||||
\}
|
||||
let l:line = l:match[2] + 0
|
||||
let l:column = l:match[3] + 0
|
||||
let l:text = l:match[4]
|
||||
let l:type = 'W'
|
||||
|
||||
" Extract error type from message of type 'Error: Some error message'
|
||||
let l:error_match = matchlist(l:item.text, '^\(.\{-}\): \(.\+\)$')
|
||||
let l:textmatch = matchlist(l:match[4], '^\(.\{-}\): .\+$')
|
||||
|
||||
if !empty(l:error_match)
|
||||
if l:error_match[1] is# 'Error'
|
||||
let l:item.type = 'E'
|
||||
let l:item.text = l:error_match[2]
|
||||
elseif l:error_match[1] is# 'Warning'
|
||||
\|| l:error_match[1] is# 'Hint'
|
||||
let l:item.text = l:error_match[2]
|
||||
if len(l:textmatch) > 0
|
||||
let l:errortype = l:textmatch[1]
|
||||
if l:errortype is# 'Error'
|
||||
let l:type = 'E'
|
||||
endif
|
||||
endif
|
||||
|
||||
let l:code_match = matchlist(l:item.text, '\v^(.+) \[([^ \[]+)\]$')
|
||||
|
||||
if !empty(l:code_match)
|
||||
let l:item.text = l:code_match[1]
|
||||
let l:item.code = l:code_match[2]
|
||||
endif
|
||||
|
||||
call add(l:output, l:item)
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:line,
|
||||
\ 'col': l:column,
|
||||
\ 'text': l:text,
|
||||
\ 'type': l:type,
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
" Author: Johannes Wienke <languitar@semipol.de>
|
||||
" Description: alex for nroff files
|
||||
|
||||
call ale#linter#Define('nroff', {
|
||||
\ 'name': 'alex',
|
||||
\ 'executable': 'alex',
|
||||
\ 'command': 'alex %s -t',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'callback': 'ale#handlers#alex#Handle',
|
||||
\ 'lint_file': 1,
|
||||
\})
|
||||
@@ -1,9 +0,0 @@
|
||||
" Author: Sumner Evans <sumner.evans98@gmail.com>
|
||||
" Description: write-good for nroff files
|
||||
|
||||
call ale#linter#Define('nroff', {
|
||||
\ 'name': 'write-good',
|
||||
\ 'executable_callback': 'ale#handlers#writegood#GetExecutable',
|
||||
\ 'command_callback': 'ale#handlers#writegood#GetCommand',
|
||||
\ 'callback': 'ale#handlers#writegood#Handle',
|
||||
\})
|
||||
@@ -1,14 +0,0 @@
|
||||
" Author: Michael Jungo <michaeljungo92@gmail.com>
|
||||
" Description: A language server for OCaml
|
||||
|
||||
call ale#Set('ocaml_ols_executable', 'ocaml-language-server')
|
||||
call ale#Set('ocaml_ols_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
|
||||
call ale#linter#Define('ocaml', {
|
||||
\ 'name': 'ols',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable_callback': 'ale#handlers#ols#GetExecutable',
|
||||
\ 'command_callback': 'ale#handlers#ols#GetCommand',
|
||||
\ 'language_callback': 'ale#handlers#ols#GetLanguage',
|
||||
\ 'project_root_callback': 'ale#handlers#ols#GetProjectRoot',
|
||||
\})
|
||||
@@ -12,7 +12,7 @@ function! ale_linters#perl#perl#GetExecutable(buffer) abort
|
||||
endfunction
|
||||
|
||||
function! ale_linters#perl#perl#GetCommand(buffer) abort
|
||||
return ale#Escape(ale_linters#perl#perl#GetExecutable(a:buffer))
|
||||
return ale_linters#perl#perl#GetExecutable(a:buffer)
|
||||
\ . ' ' . ale#Var(a:buffer, 'perl_perl_options')
|
||||
\ . ' %t'
|
||||
endfunction
|
||||
@@ -27,20 +27,12 @@ function! ale_linters#perl#perl#Handle(buffer, lines) abort
|
||||
let l:output = []
|
||||
let l:basename = expand('#' . a:buffer . ':t')
|
||||
|
||||
let l:type = 'E'
|
||||
if a:lines[-1] =~# 'syntax OK'
|
||||
let l:type = 'W'
|
||||
endif
|
||||
|
||||
let l:seen = {}
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:line = l:match[3]
|
||||
let l:file = l:match[2]
|
||||
let l:text = l:match[1]
|
||||
let l:type = 'E'
|
||||
|
||||
if ale#path#IsBufferPath(a:buffer, l:file)
|
||||
\ && !has_key(l:seen,l:line)
|
||||
if ale#path#IsBufferPath(a:buffer, l:match[2])
|
||||
\ && (
|
||||
\ l:text isnot# 'BEGIN failed--compilation aborted'
|
||||
\ || empty(l:output)
|
||||
@@ -51,8 +43,6 @@ function! ale_linters#perl#perl#Handle(buffer, lines) abort
|
||||
\ 'text': l:text,
|
||||
\ 'type': l:type,
|
||||
\})
|
||||
|
||||
let l:seen[l:line] = 1
|
||||
endif
|
||||
endfor
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ function! ale_linters#perl#perlcritic#GetExecutable(buffer) abort
|
||||
endfunction
|
||||
|
||||
function! ale_linters#perl#perlcritic#GetProfile(buffer) abort
|
||||
|
||||
" first see if we've been overridden
|
||||
let l:profile = ale#Var(a:buffer, 'perl_perlcritic_profile')
|
||||
|
||||
if l:profile is? ''
|
||||
return ''
|
||||
endif
|
||||
@@ -31,7 +31,6 @@ endfunction
|
||||
|
||||
function! ale_linters#perl#perlcritic#GetCommand(buffer) abort
|
||||
let l:critic_verbosity = '%l:%c %m\n'
|
||||
|
||||
if ale#Var(a:buffer, 'perl_perlcritic_showrules')
|
||||
let l:critic_verbosity = '%l:%c %m [%p]\n'
|
||||
endif
|
||||
@@ -39,11 +38,17 @@ function! ale_linters#perl#perlcritic#GetCommand(buffer) abort
|
||||
let l:profile = ale_linters#perl#perlcritic#GetProfile(a:buffer)
|
||||
let l:options = ale#Var(a:buffer, 'perl_perlcritic_options')
|
||||
|
||||
return ale#Escape(ale_linters#perl#perlcritic#GetExecutable(a:buffer))
|
||||
\ . ' --verbose ' . ale#Escape(l:critic_verbosity)
|
||||
\ . ' --nocolor'
|
||||
\ . (!empty(l:profile) ? ' --profile ' . ale#Escape(l:profile) : '')
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
let l:command = ale#Escape(ale_linters#perl#perlcritic#GetExecutable(a:buffer))
|
||||
\ . " --verbose '". l:critic_verbosity . "' --nocolor"
|
||||
|
||||
if l:profile isnot? ''
|
||||
let l:command .= ' --profile ' . ale#Escape(l:profile)
|
||||
endif
|
||||
if l:options isnot? ''
|
||||
let l:command .= ' ' . l:options
|
||||
endif
|
||||
|
||||
return l:command
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -56,7 +61,6 @@ function! ale_linters#perl#perlcritic#Handle(buffer, lines) abort
|
||||
\ 'lnum': l:match[1],
|
||||
\ 'col': l:match[2],
|
||||
\ 'text': l:match[3],
|
||||
\ 'type': 'W'
|
||||
\})
|
||||
endfor
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
" Description: PHP Language server integration for ALE
|
||||
|
||||
call ale#Set('php_langserver_executable', 'php-language-server.php')
|
||||
call ale#Set('php_langserver_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('php_langserver_use_global', 0)
|
||||
|
||||
function! ale_linters#php#langserver#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'php_langserver', [
|
||||
@@ -14,6 +14,10 @@ function! ale_linters#php#langserver#GetCommand(buffer) abort
|
||||
return 'php ' . ale#Escape(ale_linters#php#langserver#GetExecutable(a:buffer))
|
||||
endfunction
|
||||
|
||||
function! ale_linters#php#langserver#GetLanguage(buffer) abort
|
||||
return 'php'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#php#langserver#GetProjectRoot(buffer) abort
|
||||
let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git')
|
||||
|
||||
@@ -25,6 +29,6 @@ call ale#linter#Define('php', {
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable_callback': 'ale_linters#php#langserver#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#php#langserver#GetCommand',
|
||||
\ 'language': 'php',
|
||||
\ 'language_callback': 'ale_linters#php#langserver#GetLanguage',
|
||||
\ 'project_root_callback': 'ale_linters#php#langserver#GetProjectRoot',
|
||||
\})
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
" Author: diegoholiveira <https://github.com/diegoholiveira>, haginaga <https://github.com/haginaga>
|
||||
" Description: static analyzer for PHP
|
||||
|
||||
" Define the minimum severity
|
||||
let g:ale_php_phan_minimum_severity = get(g:, 'ale_php_phan_minimum_severity', 0)
|
||||
|
||||
let g:ale_php_phan_executable = get(g:, 'ale_php_phan_executable', 'phan')
|
||||
let g:ale_php_phan_use_client = get(g:, 'ale_php_phan_use_client', 0)
|
||||
|
||||
function! ale_linters#php#phan#GetExecutable(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'php_phan_executable')
|
||||
|
||||
if ale#Var(a:buffer, 'php_phan_use_client') == 1 && l:executable is# 'phan'
|
||||
let l:executable = 'phan_client'
|
||||
endif
|
||||
|
||||
return l:executable
|
||||
endfunction
|
||||
|
||||
function! ale_linters#php#phan#GetCommand(buffer) abort
|
||||
if ale#Var(a:buffer, 'php_phan_use_client') == 1
|
||||
let l:args = '-l '
|
||||
\ . ' %s'
|
||||
else
|
||||
let l:args = '-y '
|
||||
\ . ale#Var(a:buffer, 'php_phan_minimum_severity')
|
||||
\ . ' %s'
|
||||
endif
|
||||
|
||||
let l:executable = ale_linters#php#phan#GetExecutable(a:buffer)
|
||||
|
||||
return ale#Escape(l:executable) . ' ' . l:args
|
||||
endfunction
|
||||
|
||||
function! ale_linters#php#phan#Handle(buffer, lines) abort
|
||||
" Matches against lines like the following:
|
||||
if ale#Var(a:buffer, 'php_phan_use_client') == 1
|
||||
" Phan error: ERRORTYPE: message in /path/to/some-filename.php on line nnn
|
||||
let l:pattern = '^Phan error: \(\w\+\): \(.\+\) in \(.\+\) on line \(\d\+\)$'
|
||||
else
|
||||
" /path/to/some-filename.php:18 ERRORTYPE message
|
||||
let l:pattern = '^.*:\(\d\+\)\s\(\w\+\)\s\(.\+\)$'
|
||||
endif
|
||||
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
if ale#Var(a:buffer, 'php_phan_use_client') == 1
|
||||
let l:dict = {
|
||||
\ 'lnum': l:match[4] + 0,
|
||||
\ 'text': l:match[2],
|
||||
\ 'type': 'W',
|
||||
\}
|
||||
else
|
||||
let l:dict = {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'text': l:match[3],
|
||||
\ 'type': 'W',
|
||||
\}
|
||||
endif
|
||||
|
||||
call add(l:output, l:dict)
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('php', {
|
||||
\ 'name': 'phan',
|
||||
\ 'executable_callback': 'ale_linters#php#phan#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#php#phan#GetCommand',
|
||||
\ 'callback': 'ale_linters#php#phan#Handle',
|
||||
\})
|
||||
@@ -4,14 +4,12 @@
|
||||
function! ale_linters#php#php#Handle(buffer, lines) abort
|
||||
" Matches patterns like the following:
|
||||
"
|
||||
" PHP 7.1<= - Parse error: syntax error, unexpected ';', expecting ']' in - on line 15
|
||||
" PHP 7.2>= - Parse error: syntax error, unexpected ';', expecting ']' in Standard input code on line 15
|
||||
let l:pattern = '\v^%(Fatal|Parse) error:\s+(.+unexpected ''(.+)%(expecting.+)@<!''.*|.+) in %(-|Standard input code) on line (\d+)'
|
||||
" Parse error: syntax error, unexpected ';', expecting ']' in - on line 15
|
||||
let l:pattern = '\v^%(Fatal|Parse) error:\s+(.+unexpected ''(.+)%(expecting.+)@<!''.*|.+) in - on line (\d+)'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:col = empty(l:match[2]) ? 0 : stridx(getline(l:match[3]), l:match[2]) + 1
|
||||
|
||||
let l:obj = {
|
||||
\ 'lnum': l:match[3] + 0,
|
||||
\ 'col': l:col,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
let g:ale_php_phpcs_standard = get(g:, 'ale_php_phpcs_standard', '')
|
||||
|
||||
call ale#Set('php_phpcs_executable', 'phpcs')
|
||||
call ale#Set('php_phpcs_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('php_phpcs_use_global', 0)
|
||||
|
||||
function! ale_linters#php#phpcs#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'php_phpcs', [
|
||||
@@ -29,12 +29,11 @@ function! ale_linters#php#phpcs#Handle(buffer, lines) abort
|
||||
" Matches against lines like the following:
|
||||
"
|
||||
" /path/to/some-filename.php:18:3: error - Line indented incorrectly; expected 4 spaces, found 2 (Generic.WhiteSpace.ScopeIndent.IncorrectExact)
|
||||
let l:pattern = '^.*:\(\d\+\):\(\d\+\): \(.\+\) - \(.\+\) (\(.\+\))$'
|
||||
let l:pattern = '^.*:\(\d\+\):\(\d\+\): \(.\+\) - \(.\+\) \(\(.\+\)\)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:code = l:match[5]
|
||||
let l:text = l:match[4] . ' (' . l:code . ')'
|
||||
let l:text = l:match[4]
|
||||
let l:type = l:match[3]
|
||||
|
||||
call add(l:output, {
|
||||
|
||||
@@ -1,20 +1,11 @@
|
||||
" Author: medains <https://github.com/medains>, David Sierra <https://github.com/davidsierradz>
|
||||
" Author: medains <https://github.com/medains>
|
||||
" Description: phpmd for PHP files
|
||||
|
||||
let g:ale_php_phpmd_executable = get(g:, 'ale_php_phpmd_executable', 'phpmd')
|
||||
|
||||
" Set to change the ruleset
|
||||
let g:ale_php_phpmd_ruleset = get(g:, 'ale_php_phpmd_ruleset', 'cleancode,codesize,controversial,design,naming,unusedcode')
|
||||
|
||||
function! ale_linters#php#phpmd#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'php_phpmd_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#php#phpmd#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#php#phpmd#GetExecutable(a:buffer)
|
||||
|
||||
return ale#Escape(l:executable)
|
||||
\ . ' %s text '
|
||||
return 'phpmd %s text '
|
||||
\ . ale#Var(a:buffer, 'php_phpmd_ruleset')
|
||||
\ . ' --ignore-violations-on-exit %t'
|
||||
endfunction
|
||||
@@ -39,7 +30,7 @@ endfunction
|
||||
|
||||
call ale#linter#Define('php', {
|
||||
\ 'name': 'phpmd',
|
||||
\ 'executable_callback': 'ale_linters#php#phpmd#GetExecutable',
|
||||
\ 'executable': 'phpmd',
|
||||
\ 'command_callback': 'ale_linters#php#phpmd#GetCommand',
|
||||
\ 'callback': 'ale_linters#php#phpmd#Handle',
|
||||
\})
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
" Author: Cian Butler https://github.com/butlerx
|
||||
" Description: alex for PO files
|
||||
|
||||
call ale#linter#Define('po', {
|
||||
\ 'name': 'alex',
|
||||
\ 'executable': 'alex',
|
||||
\ 'command': 'alex %s -t',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'callback': 'ale#handlers#alex#Handle',
|
||||
\ 'lint_file': 1,
|
||||
\})
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user