2018-01-12 08:55:24 +00:00
# Asynchronous Lint Engine [![Travis CI Build Status](https://travis-ci.org/w0rp/ale.svg?branch=master)](https://travis-ci.org/w0rp/ale) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/r0ef1xu8xjmik58d/branch/master?svg=true)](https://ci.appveyor.com/project/w0rp/ale)
2017-10-23 22:21:50 +00:00
2016-10-11 20:55:26 +00:00
![ALE Logo by Mark Grealish - https://www.bhalash.com/ ](img/logo.jpg?raw=true )
2016-09-08 23:23:26 +00:00
ALE (Asynchronous Lint Engine) is a plugin for providing linting in NeoVim
and Vim 8 while you edit your text files.
2016-10-07 16:48:47 +00:00
![linting example ](img/example.gif?raw=true )
2016-10-04 21:38:43 +00:00
2016-09-08 23:23:26 +00:00
ALE makes use of NeoVim and Vim 8 job control functions and timers to
run linters on the contents of text buffers and return errors as
text is changed in Vim. This allows for displaying warnings and
2016-09-13 22:18:52 +00:00
errors in files being edited in Vim before files have been saved
back to a filesystem.
In other words, this plugin allows you to lint while you type.
2016-09-08 23:23:26 +00:00
2017-08-17 23:13:08 +00:00
In addition to linting support, ALE offers some support for fixing code with
2017-11-26 23:12:13 +00:00
formatting tools, and some Language Server Protocol and `tsserver` features.
2017-05-20 18:01:12 +00:00
2016-10-25 09:39:06 +00:00
## Table of Contents
2016-10-25 09:44:50 +00:00
1. [Supported Languages and Tools ](#supported-languages )
2. [Usage ](#usage )
2017-08-17 23:08:58 +00:00
1. [Linting ](#usage-linting )
2. [Fixing ](#usage-fixing )
3. [Completion ](#usage-completion )
2017-11-26 23:12:13 +00:00
4. [Go To Definition ](#usage-go-to-definition )
2016-10-25 09:44:50 +00:00
3. [Installation ](#installation )
2017-07-19 12:36:30 +00:00
1. [Installation with Vim package management ](#standard-installation )
2. [Installation with Pathogen ](#installation-with-pathogen )
3. [Installation with Vundle ](#installation-with-vundle )
2017-02-23 22:51:08 +00:00
4. [Contributing ](#contributing )
5. [FAQ ](#faq )
2017-04-12 20:22:56 +00:00
1. [How do I disable particular linters? ](#faq-disable-linters )
2017-04-12 20:53:20 +00:00
2. [How can I keep the sign gutter open? ](#faq-keep-signs )
2017-04-12 20:22:56 +00:00
3. [How can I change the signs ALE uses? ](#faq-change-signs )
2017-11-02 10:39:40 +00:00
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 )
2017-12-07 15:26:20 +00:00
8. [How can I execute some code when ALE starts or stops linting? ](#faq-autocmd )
2017-11-02 10:39:40 +00:00
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 )
2017-11-18 18:59:03 +00:00
14. [How can I configure my C or C++ project? ](#faq-c-configuration )
2017-11-19 13:56:09 +00:00
15. [How can I configure ALE differently for different buffers? ](#faq-buffer-configuration )
2016-10-25 09:39:06 +00:00
< a name = "supported-languages" > < / a >
## 1. Supported Languages and Tools
2016-09-19 21:19:21 +00:00
This plugin supports the following languages and tools. All available
tools will be run in combination, so they can be complementary.
<!--
Keep the table rows sorted alphabetically by the language name,
and the tools in the tools column sorted alphabetically by the tool
name. That seems to be the fairest way to arrange this table.
2017-08-28 21:05:12 +00:00
Remember to also update doc/ale.txt, which has a similar list with different
formatting.
2016-09-19 21:19:21 +00:00
-->
2017-08-28 21:05:12 +00:00
**Notes:**
* *^ No linters for text or Vim help filetypes are enabled by default.*
2017-08-28 21:08:55 +00:00
* *!! These linters check only files on disk. See `:help ale-lint-file-linters` *
2017-08-28 21:05:12 +00:00
2016-09-19 21:19:21 +00:00
| Language | Tools |
| -------- | ----- |
2017-03-25 23:02:59 +00:00
| ASM | [gcc ](https://gcc.gnu.org ) |
2016-10-20 14:26:56 +00:00
| Ansible | [ansible-lint ](https://github.com/willthames/ansible-lint ) |
2017-11-20 10:57:13 +00:00
| API Blueprint | [drafter ](https://github.com/apiaryio/drafter ) |
2017-12-18 14:26:52 +00:00
| AsciiDoc | [alex ](https://github.com/wooorm/alex ) !!, [proselint ](http://proselint.com/ ), [redpen ](http://redpen.cc/ ), [write-good ](https://github.com/btford/write-good ) |
2017-06-08 17:26:21 +00:00
| Awk | [gawk ](https://www.gnu.org/software/gawk/ )|
2017-11-05 21:24:41 +00:00
| 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 ) |
2017-08-30 21:08:41 +00:00
| 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 )|
2017-12-18 10:28:49 +00:00
| 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 ) !!, [gcc ](https://gcc.gnu.org/ ) |
2017-09-07 18:23:58 +00:00
| CUDA | [nvcc ](http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html ) |
2017-09-26 07:19:53 +00:00
| 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|
2016-10-30 18:23:32 +00:00
| Chef | [foodcritic ](http://www.foodcritic.io/ ) |
2017-11-15 21:46:51 +00:00
| Clojure | [joker ](https://github.com/candid82/joker ) |
2017-02-25 17:27:03 +00:00
| CMake | [cmakelint ](https://github.com/richq/cmake-lint ) |
2016-10-08 15:52:23 +00:00
| CoffeeScript | [coffee ](http://coffeescript.org/ ), [coffeelint ](https://www.npmjs.com/package/coffeelint ) |
2017-08-28 21:12:41 +00:00
| Crystal | [crystal ](https://crystal-lang.org/ ) !! |
2017-11-12 12:11:15 +00:00
| CSS | [csslint ](http://csslint.net/ ), [prettier ](https://github.com/prettier/prettier ), [stylelint ](https://github.com/stylelint/stylelint ) |
2016-10-07 20:33:16 +00:00
| Cython (pyrex filetype) | [cython ](http://cython.org/ ) |
2017-02-08 22:25:08 +00:00
| D | [dmd ](https://dlang.org/dmd-linux.html ) |
2017-11-08 06:18:49 +00:00
| Dafny | [dafny ](https://rise4fun.com/Dafny ) !! |
2017-10-30 16:46:02 +00:00
| Dart | [dartanalyzer ](https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_cli ) !!, [language_server ](https://github.com/natebosch/dart_language_server ) |
2018-01-29 21:21:50 +00:00
| Dockerfile | [hadolint ](https://github.com/hadolint/hadolint ) |
2018-01-22 12:21:07 +00:00
| Elixir | [credo ](https://github.com/rrrene/credo ), [dialyxir ](https://github.com/jeremyjh/dialyxir ), [dogma ](https://github.com/lpil/dogma ) !!|
2017-09-10 11:58:42 +00:00
| Elm | [elm-format ](https://github.com/avh4/elm-format ), [elm-make ](https://github.com/elm-lang/elm-make ) |
2017-11-12 05:53:02 +00:00
| Erb | [erb ](https://apidock.com/ruby/ERB ), [erubi ](https://github.com/jeremyevans/erubi ), [erubis ](https://github.com/kwatch/erubis ) |
2017-07-16 11:35:43 +00:00
| Erlang | [erlc ](http://erlang.org/doc/man/erlc.html ), [SyntaxErl ](https://github.com/ten0s/syntaxerl ) |
2017-12-26 18:00:28 +00:00
| Fish | fish [-n flag ](https://linux.die.net/man/1/fish )
2016-09-19 21:19:21 +00:00
| Fortran | [gcc ](https://gcc.gnu.org/ ) |
2017-12-20 03:57:25 +00:00
| Fountain | [proselint ](http://proselint.com/ ) |
2017-06-14 08:35:11 +00:00
| FusionScript | [fusion-lint ](https://github.com/RyanSquared/fusionscript ) |
2017-12-20 10:10:07 +00:00
| Git Commit Messages | [gitlint ](https://github.com/jorisroovers/gitlint ) |
2017-12-01 17:36:44 +00:00
| GLSL | [glslang ](https://github.com/KhronosGroup/glslang ), [glslls ](https://github.com/svenstaro/glsl-language-server ) |
2018-01-07 12:11:01 +00:00
| 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 ) !! |
2018-01-05 12:02:05 +00:00
| GraphQL | [eslint ](http://eslint.org/ ), [gqlint ](https://github.com/happylinks/gqlint ), [prettier ](https://github.com/prettier/prettier ) |
2017-09-08 10:06:47 +00:00
| Haml | [haml-lint ](https://github.com/brigade/haml-lint ) |
2017-04-07 14:38:50 +00:00
| Handlebars | [ember-template-lint ](https://github.com/rwjblue/ember-template-lint ) |
2017-11-28 22:58:13 +00:00
| 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 ) |
2017-12-18 14:26:52 +00:00
| 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 ) |
2017-08-10 20:09:58 +00:00
| Idris | [idris ](http://www.idris-lang.org/ ) |
2017-12-09 13:52:15 +00:00
| 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 ) |
2017-12-18 10:37:21 +00:00
| 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 ), [prettier-standard ](https://github.com/sheerun/prettier-standard ), [standard ](http://standardjs.com/ ), [xo ](https://github.com/sindresorhus/xo )
2018-01-24 10:36:02 +00:00
| JSON | [fixjson ](https://github.com/rhysd/fixjson ), [jsonlint ](http://zaa.ch/jsonlint/ ), [jq ](https://stedolan.github.io/jq/ ), [prettier ](https://github.com/prettier/prettier ) |
2017-10-10 09:13:09 +00:00
| Kotlin | [kotlinc ](https://kotlinlang.org ) !!, [ktlint ](https://ktlint.github.io ) !! see `:help ale-integration-kotlin` for configuration instructions |
2017-12-18 14:26:52 +00:00
| 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 ) |
2017-11-12 12:09:19 +00:00
| Less | [lessc ](https://www.npmjs.com/package/less ), [prettier ](https://github.com/prettier/prettier ), [stylelint ](https://github.com/stylelint/stylelint ) |
2017-10-10 09:13:09 +00:00
| LLVM | [llc ](https://llvm.org/docs/CommandGuide/llc.html ) |
2018-01-08 15:19:17 +00:00
| Lua | [luac ](https://www.lua.org/manual/5.1/luac.html ), [luacheck ](https://github.com/mpeterv/luacheck ) |
2017-12-18 14:26:52 +00:00
| Mail | [alex ](https://github.com/wooorm/alex ) !!, [proselint ](http://proselint.com/ ), [vale ](https://github.com/ValeLint/vale ) |
2017-10-24 12:09:56 +00:00
| Make | [checkmake ](https://github.com/mrtazz/checkmake ) |
2018-01-15 02:22:09 +00:00
| Markdown | [alex ](https://github.com/wooorm/alex ) !!, [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 ) !!, [vale ](https://github.com/ValeLint/vale ), [write-good ](https://github.com/btford/write-good ) |
2016-10-24 19:32:52 +00:00
| MATLAB | [mlint ](https://www.mathworks.com/help/matlab/ref/mlint.html ) |
2017-08-28 21:12:41 +00:00
| Nim | [nim check ](https://nim-lang.org/docs/nimc.html ) !! |
2017-03-03 21:45:48 +00:00
| nix | [nix-instantiate ](http://nixos.org/nix/manual/#sec-nix-instantiate ) |
2017-12-18 14:26:52 +00:00
| nroff | [alex ](https://github.com/wooorm/alex ) !!, [proselint ](http://proselint.com/ ), [write-good ](https://github.com/btford/write-good )|
2017-05-19 16:41:57 +00:00
| Objective-C | [clang ](http://clang.llvm.org/ ) |
| Objective-C++ | [clang ](http://clang.llvm.org/ ) |
2017-11-11 18:27:41 +00:00
| 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 ) |
2016-10-09 15:31:03 +00:00
| Perl | [perl -c ](https://perl.org/ ), [perl-critic ](https://metacpan.org/pod/Perl::Critic ) |
2017-10-26 23:11:02 +00:00
| 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 ) |
2018-01-27 11:40:40 +00:00
| 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 ) |
2017-12-18 14:26:52 +00:00
| Pod | [alex ](https://github.com/wooorm/alex ) !!, [proselint ](http://proselint.com/ ), [write-good ](https://github.com/btford/write-good ) |
2017-11-10 09:43:42 +00:00
| proto | [protoc-gen-lint ](https://github.com/ckaznocha/protoc-gen-lint ) |
2016-10-07 21:16:29 +00:00
| Pug | [pug-lint ](https://github.com/pugjs/pug-lint ) |
2016-11-25 12:00:07 +00:00
| Puppet | [puppet ](https://puppet.com ), [puppet-lint ](https://puppet-lint.com ) |
2017-12-01 17:04:30 +00:00
| 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/ ), [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 ) |
2017-07-03 21:34:22 +00:00
| R | [lintr ](https://github.com/jimhester/lintr ) |
2018-02-13 03:52:39 +00:00
| 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 ) |
2017-12-18 14:26:52 +00:00
| 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 ) |
2017-11-17 06:21:18 +00:00
| Re:VIEW | [redpen ](http://redpen.cc/ ) |
2017-04-20 15:55:20 +00:00
| RPM spec | [rpmlint ](https://github.com/rpm-software-management/rpmlint ) (disabled by default; see `:help ale-integration-spec` ) |
2017-08-28 21:12:41 +00:00
| 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 ) |
2017-10-21 17:31:49 +00:00
| 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 ) |
2016-12-06 13:26:06 +00:00
| SASS | [sass-lint ](https://www.npmjs.com/package/sass-lint ), [stylelint ](https://github.com/stylelint/stylelint ) |
2017-11-12 12:11:15 +00:00
| 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 ) |
2017-07-13 22:41:01 +00:00
| Scala | [scalac ](http://scala-lang.org ), [scalastyle ](http://www.scalastyle.org ) |
2017-10-10 09:13:09 +00:00
| Slim | [slim-lint ](https://github.com/sds/slim-lint ) |
2017-02-18 02:05:33 +00:00
| SML | [smlnj ](http://www.smlnj.org/ ) |
2017-12-04 17:23:34 +00:00
| Solidity | [solhint ](https://github.com/protofire/solhint ), [solium ](https://github.com/duaraghav8/Solium ) |
2017-07-03 15:57:39 +00:00
| Stylus | [stylelint ](https://github.com/stylelint/stylelint ) |
2017-04-15 10:24:05 +00:00
| SQL | [sqlint ](https://github.com/purcell/sqlint ) |
2017-08-09 17:26:38 +00:00
| Swift | [swiftlint ](https://github.com/realm/SwiftLint ), [swiftformat ](https://github.com/nicklockwood/SwiftFormat ) |
2017-08-28 21:12:41 +00:00
| Tcl | [nagelfar ](http://nagelfar.sourceforge.net ) !! |
2017-10-26 18:32:33 +00:00
| Terraform | [tflint ](https://github.com/wata727/tflint ) |
2017-12-18 14:26:52 +00:00
| 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/ ), [vale ](https://github.com/ValeLint/vale ), [write-good ](https://github.com/btford/write-good ), [redpen ](http://redpen.cc/ ) |
2017-08-30 17:59:40 +00:00
| Thrift | [thrift ](http://thrift.apache.org/ ) |
2017-11-12 12:11:15 +00:00
| TypeScript | [eslint ](http://eslint.org/ ), [prettier ](https://github.com/prettier/prettier ), [tslint ](https://github.com/palantir/tslint ), tsserver, typecheck |
2016-10-08 12:38:31 +00:00
| Verilog | [iverilog ](https://github.com/steveicarus/iverilog ), [verilator ](http://www.veripool.org/projects/verilator/wiki/Intro ) |
2016-10-07 20:33:16 +00:00
| Vim | [vint ](https://github.com/Kuniwak/vint ) |
2017-12-18 14:26:52 +00:00
| Vim help^ | [alex ](https://github.com/wooorm/alex ) !!, [proselint ](http://proselint.com/ ), [write-good ](https://github.com/btford/write-good ) |
2018-01-31 16:29:01 +00:00
| Vue | [prettier ](https://github.com/prettier/prettier ) |
2017-12-18 14:26:52 +00:00
| XHTML | [alex ](https://github.com/wooorm/alex ) !!, [proselint ](http://proselint.com/ ), [write-good ](https://github.com/btford/write-good ) |
2017-10-24 23:27:40 +00:00
| XML | [xmllint ](http://xmlsoft.org/xmllint.html ) |
2017-07-17 19:28:21 +00:00
| YAML | [swaglint ](https://github.com/byCedric/swaglint ), [yamllint ](https://yamllint.readthedocs.io/ ) |
2016-09-19 21:19:21 +00:00
2016-10-25 09:39:06 +00:00
< a name = "usage" > < / a >
## 2. Usage
2016-09-19 21:19:21 +00:00
2017-08-17 23:08:58 +00:00
< a name = "usage-linting" > < / a >
### 2.i Linting
2016-09-19 21:19:21 +00:00
Once this plugin is installed, while editing your files in supported
languages and tools which have been correctly installed,
this plugin will send the contents of your text buffers to a variety of
programs for checking the syntax and semantics of your programs. By default,
linters will be re-run in the background to check your syntax when you open
new buffers or as you make edits to your files.
2016-10-25 09:39:06 +00:00
The behaviour of linting can be configured with a variety of options,
documented in [the Vim help file ](doc/ale.txt ). For more information on the
options ALE offers, consult `:help ale-options` for global options and `:help
ale-linter-options` for options specified to particular linters.
2017-08-17 23:08:58 +00:00
< a name = "usage-fixing" > < / a >
### 2.ii Fixing
2017-05-20 18:01:12 +00:00
ALE can fix files with the `ALEFix` command. Functions need to be configured
2017-08-17 23:08:58 +00:00
for different filetypes with the `g:ale_fixers` variable. For example, the
following code can be used to fix JavaScript code with ESLint:
```vim
" Put this in vimrc or a plugin file of your own.
" After this is configured, :ALEFix will try and fix your JS code with ESLint.
let g:ale_fixers = {
\ 'javascript': ['eslint'],
\}
" Set this setting in vimrc if you want to fix files automatically on save.
" This is off by default.
let g:ale_fix_on_save = 1
```
The `:ALEFixSuggest` command will suggest some supported tools for fixing code,
but fixers can be also implemented with functions, including lambda functions
too. See `:help ale-fix` for detailed information.
< a name = "usage-completion" > < / a >
### 2.iii Completion
ALE offers some support for completion via hijacking of omnicompletion while you
type. All of ALE's completion information must come from Language Server
Protocol linters, or similar protocols. At the moment, completion is only
supported for TypeScript code with `tsserver` , when `tsserver` is enabled. You
can enable completion like so:
```vim
" Enable completion where available.
let g:ale_completion_enabled = 1
```
See `:help ale-completion` for more information.
2017-05-20 18:01:12 +00:00
2017-11-26 23:12:13 +00:00
< 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 LSP linters and `tsserver` .
See `:help ale-go-to-definition` for more information.
2016-10-25 09:39:06 +00:00
< a name = "installation" > < / a >
## 3. Installation
To install this plugin, you should use one of the following methods.
For Windows users, replace usage of the Unix `~/.vim` directory with
2017-07-19 12:36:30 +00:00
`%USERPROFILE%\vimfiles` , or another directory if you have configured
2016-10-25 09:39:06 +00:00
Vim differently. On Windows, your `~/.vimrc` file will be similarly
stored in `%USERPROFILE%\_vimrc` .
2017-07-19 12:36:30 +00:00
< a name = "standard-installation" > < / a >
2016-10-25 09:39:06 +00:00
2017-07-19 12:36:30 +00:00
### 3.i. Installation with Vim package management
2016-10-25 09:39:06 +00:00
2017-07-19 12:36:30 +00:00
In Vim 8 and NeoVim, you can install plugins easily without needing to use
any other tools. Simply clone the plugin into your `pack` directory.
2017-07-19 12:37:40 +00:00
#### Vim 8 on Unix
2016-10-25 09:39:06 +00:00
```bash
2017-07-19 12:36:30 +00:00
mkdir -p ~/.vim/pack/git-plugins/start
git clone https://github.com/w0rp/ale.git ~/.vim/pack/git-plugins/start/ale
2016-10-25 09:39:06 +00:00
```
2017-07-19 12:37:40 +00:00
#### NeoVim on Unix
2016-10-25 09:39:06 +00:00
2017-07-19 12:36:30 +00:00
```bash
mkdir -p ~/.local/share/nvim/site/pack/git-plugins/start
git clone https://github.com/w0rp/ale.git ~/.local/share/nvim/site/pack/git-plugins/start/ale
```
2016-10-25 09:39:06 +00:00
2017-07-19 12:37:40 +00:00
#### Vim 8 on Windows
2016-10-25 09:39:06 +00:00
2017-07-19 12:36:30 +00:00
```bash
# Run these commands in the "Git for Windows" Bash terminal
mkdir -p ~/vimfiles/pack/git-plugins/start
git clone https://github.com/w0rp/ale.git ~/vimfiles/pack/git-plugins/start/ale
2016-10-25 09:39:06 +00:00
```
2017-08-14 22:52:13 +00:00
#### Generating Vim help files
2016-10-25 09:39:06 +00:00
2017-07-19 12:36:30 +00:00
You can add the following line to your vimrc files to generate documentation
tags automatically, if you don't have something similar already, so you can use
the `:help` command to consult ALE's online documentation:
2016-10-25 09:39:06 +00:00
2017-07-19 12:36:30 +00:00
```vim
2017-07-20 12:45:28 +00:00
" Put these lines at the very end of your vimrc file.
" Load all plugins now.
" Plugins need to be added to runtimepath before helptags can be generated.
packloadall
" Load all of the helptags now, after plugins have been loaded.
" All messages and errors will be ignored.
2017-07-19 12:36:30 +00:00
silent! helptags ALL
```
< a name = "installation-with-pathogen" > < / a >
2016-10-25 09:39:06 +00:00
2017-07-19 12:36:30 +00:00
### 3.ii. Installation with Pathogen
To install this module with [Pathogen ](https://github.com/tpope/vim-pathogen ),
you should clone this repository to your bundle directory, and ensure
you have the line `execute pathogen#infect()` in your `~/.vimrc` file.
You can run the following commands in your terminal to do so:
2016-10-25 09:39:06 +00:00
```bash
cd ~/.vim/bundle
git clone https://github.com/w0rp/ale.git
```
2017-07-19 12:36:30 +00:00
< a name = "installation-with-vundle" > < / a >
2016-10-25 09:39:06 +00:00
2017-07-19 12:36:30 +00:00
### 3.iii. Installation with Vundle
2016-10-25 09:39:06 +00:00
2017-07-19 12:36:30 +00:00
You can install this plugin using [Vundle ](https://github.com/VundleVim/Vundle.vim )
by using the path on GitHub for this repository.
2016-10-25 09:39:06 +00:00
```vim
2017-07-19 12:36:30 +00:00
Plugin 'w0rp/ale'
2016-10-25 09:39:06 +00:00
```
2017-07-19 12:36:30 +00:00
See the Vundle documentation for more information.
2016-10-25 09:39:06 +00:00
2017-02-23 22:51:08 +00:00
< a name = "contributing" > < / a >
## 4. Contributing
If you would like to see support for more languages and tools, please
[create an issue ](https://github.com/w0rp/ale/issues )
or [create a pull request ](https://github.com/w0rp/ale/pulls ).
If your tool can read from stdin or you have code to suggest which is good,
support can be happily added for it.
If you are interested in the general direction of the project, check out the
[wiki home page ](https://github.com/w0rp/ale/wiki ). The wiki includes a
Roadmap for the future, and more.
2017-04-20 15:02:51 +00:00
If you'd liked to discuss the project more directly, check out the `#vim-ale` channel
on Freenode. Web chat is available [here ](https://webchat.freenode.net/?channels=vim-ale ).
2016-10-25 09:39:06 +00:00
< a name = "faq" > < / a >
2017-02-23 22:51:08 +00:00
## 5. FAQ
2016-10-25 09:39:06 +00:00
< a name = "faq-disable-linters" > < / a >
2017-02-23 22:51:08 +00:00
### 5.i. How do I disable particular linters?
2016-09-19 21:19:21 +00:00
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
let g:ale_linters = {
\ 'javascript': ['eslint'],
\}
```
For all languages unspecified in the dictionary, all possible linters will
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.
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.
2016-10-25 09:39:06 +00:00
< a name = "faq-keep-signs" > < / a >
2016-10-02 08:22:24 +00:00
2017-02-23 22:51:08 +00:00
### 5.ii. How can I keep the sign gutter open?
2016-10-25 09:39:06 +00:00
You can keep the sign gutter open at all times by setting the
`g:ale_sign_column_always` to 1
2016-09-26 14:55:26 +00:00
```vim
let g:ale_sign_column_always = 1
```
2016-10-25 09:39:06 +00:00
< a name = "faq-change-signs" > < / a >
2017-02-23 22:51:08 +00:00
### 5.iii. How can I change the signs ALE uses?
2016-10-02 08:22:24 +00:00
Use these options to specify what text should be used for signs:
```vim
let g:ale_sign_error = '>>'
let g:ale_sign_warning = '--'
```
2017-01-30 15:22:14 +00:00
ALE sets some background colors automatically for warnings and errors
in the sign gutter, with the names `ALEErrorSign` and `ALEWarningSign` .
These colors can be customised, or even removed completely:
```vim
highlight clear ALEErrorSign
highlight clear ALEWarningSign
```
2017-11-02 10:39:40 +00:00
< 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
2017-11-06 13:17:38 +00:00
color scheme which produces ugly highlights. For example:
```vim
highlight ALEWarning ctermbg=DarkMagenta
```
See `:help ale-highlights` for more information.
2017-11-02 10:39:40 +00:00
2016-10-25 09:39:06 +00:00
< a name = "faq-statusline" > < / a >
2017-11-02 10:39:40 +00:00
### 5.v. How can I show errors or warnings in my statusline?
2016-10-07 16:48:47 +00:00
2017-06-25 19:01:46 +00:00
[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
status for ALE in a nice format, it is recommended to use vim-airline with ALE.
The airline extension can be enabled by adding the following to your vimrc:
```vim
" Set this. Airline will handle the rest.
let g:airline#extensions#ale#enabled = 1
```
If you don't want to use vim-airline, you can implement your own statusline
function without adding any other plugins. ALE provides a function for counting
the number of problems for this purpose, named `ale#statusline#Count` .
2016-10-07 16:48:47 +00:00
2017-05-24 09:38:20 +00:00
Say you want to display all errors as one figure, and all non-errors as another
figure. You can do the following:
2016-10-07 16:48:47 +00:00
2017-05-24 09:38:20 +00:00
```vim
function! LinterStatus() abort
2017-05-25 12:33:29 +00:00
let l:counts = ale#statusline#Count(bufnr(''))
2016-10-07 16:48:47 +00:00
2017-05-24 09:38:20 +00:00
let l:all_errors = l:counts.error + l:counts.style_error
let l:all_non_errors = l:counts.total - l:all_errors
2016-10-07 16:48:47 +00:00
2017-05-24 09:38:20 +00:00
return l:counts.total == 0 ? 'OK' : printf(
\ '%dW %dE',
\ all_non_errors,
\ all_errors
\)
endfunction
set statusline=%{LinterStatus()}
2016-10-07 16:48:47 +00:00
```
2017-05-24 09:38:20 +00:00
See `:help ale#statusline#Count()` for more information.
2016-10-07 16:48:47 +00:00
2017-10-19 16:39:49 +00:00
< a name = "faq-lightline" > < / a >
2017-11-02 10:39:40 +00:00
### 5.vi. How can I show errors or warnings in my lightline?
2017-10-19 16:39:49 +00:00
2017-10-23 22:21:50 +00:00
[lightline ](https://github.com/itchyny/lightline.vim ) does not have built-in
2017-10-31 12:26:12 +00:00
support for ALE, nevertheless there is a plugin that adds this functionality: [maximbaz/lightline-ale ](https://github.com/maximbaz/lightline-ale ).
2017-10-19 16:39:49 +00:00
2017-10-31 12:26:12 +00:00
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 ).
2017-10-19 16:39:49 +00:00
2016-10-25 09:39:06 +00:00
< a name = "faq-echo-format" > < / a >
2016-10-10 11:53:54 +00:00
2017-11-02 10:39:40 +00:00
### 5.vii. How can I change the format for echo messages?
2016-10-10 11:53:54 +00:00
There are 3 global options that allow customizing the echoed message.
- `g:ale_echo_msg_format` where:
2017-04-12 20:22:56 +00:00
* `%s` is the error message itself
* `%linter%` is the linter name
* `%severity` is the severity type
2016-10-10 11:53:54 +00:00
- `g:ale_echo_msg_error_str` is the string used for error severity.
- `g:ale_echo_msg_warning_str` is the string used for warning severity.
So for example this:
```vim
let g:ale_echo_msg_error_str = 'E'
2016-10-10 14:53:09 +00:00
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
2016-10-10 11:53:54 +00:00
```
Will give you:
![Echoed message ](img/echo.png )
2016-10-25 09:39:06 +00:00
< a name = "faq-autocmd" > < / a >
2016-09-19 21:04:11 +00:00
2017-12-07 15:26:20 +00:00
### 5.viii. How can I execute some code when ALE starts or stops linting?
2016-09-19 21:04:11 +00:00
2016-10-25 09:39:06 +00:00
ALE runs its own [autocmd ](http://vimdoc.sourceforge.net/htmldoc/autocmd.html )
2017-12-07 15:26:20 +00:00
events whenever has a linter is started and has been successfully executed and
2017-12-10 13:03:03 +00:00
processed. These events can be used to call arbitrary functions before and after
ALE stops linting.
2016-09-19 21:04:11 +00:00
```vim
2016-10-25 09:39:06 +00:00
augroup YourGroup
autocmd!
2017-12-10 13:03:03 +00:00
autocmd User ALELintPre call YourFunction()
autocmd User ALELintPost call YourFunction()
2016-10-25 09:39:06 +00:00
augroup END
2016-09-19 21:04:11 +00:00
```
2016-10-24 21:09:41 +00:00
< a name = "faq-navigation" > < / a >
2017-11-02 10:39:40 +00:00
### 5.ix. How can I navigate between errors quickly?
2016-10-24 21:09:41 +00:00
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
for example:
```vim
nmap < silent > < C-k > < Plug > (ale_previous_wrap)
nmap < silent > < C-j > < Plug > (ale_next_wrap)
```
For more information, consult the online documentation with
`:help ale-navigation-commands` .
2016-12-01 09:52:43 +00:00
< a name = "faq-lint-on-save" > < / a >
2017-11-02 10:39:40 +00:00
### 5.x. How can I run linters only when I save files?
2016-12-01 09:52:43 +00:00
ALE offers an option `g:ale_lint_on_save` for enabling running the linters
2017-03-27 19:36:35 +00:00
when files are saved. This option is enabled by default. If you only
wish to run linters when files are saved, you can turn the other
options off.
2016-12-01 09:52:43 +00:00
```vim
" Write this in your vimrc file
2017-03-30 22:21:37 +00:00
let g:ale_lint_on_text_changed = 'never'
2016-12-01 09:52:43 +00:00
" You can disable this option too
" if you don't want linters to run on opening a file
let g:ale_lint_on_enter = 0
```
2017-02-05 15:34:35 +00:00
2017-03-27 19:36:35 +00:00
If for whatever reason you don't wish to run linters again when you save
files, you can set `g:ale_lint_on_save` to `0` .
2017-02-05 15:34:35 +00:00
< a name = "faq-quickfix" > < / a >
2017-11-02 10:39:40 +00:00
### 5.xi. How can I use the quickfix list instead of the loclist?
2017-02-05 15:34:35 +00:00
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
the `g:ale_set_loclist` option.
```vim
" Write this in your vimrc file
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 1
```
If you wish to show Vim windows for the loclist or quickfix items
when a file contains warnings or errors, `g:ale_open_list` can be
set to `1` . `g:ale_keep_list_window_open` can be set to `1`
if you wish to keep the window open even after errors disappear.
```vim
let g:ale_open_list = 1
" Set this if you want to.
" This can be useful if you are combining ALE with
" some other plugin which sets quickfix errors, etc.
let g:ale_keep_list_window_open = 1
```
2017-02-11 21:18:24 +00:00
< a name = "faq-jsx-stylelint-eslint" > < / a >
2017-11-02 10:39:40 +00:00
### 5.xii. How can I check JSX files with both stylelint and eslint?
2017-02-11 21:18:24 +00:00
If you configure ALE options correctly in your vimrc file, and install
the right tools, you can check JSX files with stylelint and eslint.
First, install eslint and install stylelint with
2017-06-02 11:54:38 +00:00
[stylelint-processor-styled-components ](https://github.com/styled-components/stylelint-processor-styled-components ).
2017-02-11 21:18:24 +00:00
Supposing you have installed both tools correctly, configure your .jsx files so
`jsx` is included in the filetype. You can use an `autocmd` for this.
```vim
augroup FiletypeGroup
autocmd!
au BufNewFile,BufRead *.jsx set filetype=javascript.jsx
augroup END
```
Supposing the filetype has been set correctly, you can set the following
options in your vimrc file:
```vim
let g:ale_linters = {'jsx': ['stylelint', 'eslint']}
let g:ale_linter_aliases = {'jsx': 'css'}
```
ALE will alias the `jsx` filetype so it uses the `css` filetype linters, and
use the original Array of selected linters for `jsx` from the `g:ale_linters`
object. All available linters will be used for the filetype `javascript` , and
no linter will be run twice for the same file.
2017-02-16 20:59:29 +00:00
< a name = "faq-my-battery-is-sad" > < / a >
2017-11-02 10:39:40 +00:00
### 5.xiii. Will this plugin eat all of my laptop battery power?
2017-02-16 20:59:29 +00:00
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
are concerned about the CPU time ALE will spend, which will of course imply
some cost to battery life, you can adjust your settings to make your CPU do
less work.
First, consider increasing the delay before which ALE will run any linters
while you type. ALE uses a timeout which is cancelled and reset every time you
type, and this delay can be increased so linters are run less often. See
`:help g:ale_lint_delay` for more information.
If you don't wish to run linters while you type, you can disable that
2017-03-30 22:21:37 +00:00
behaviour. Set `g:ale_lint_on_text_changed` to `never` or `normal` . You won't
get as frequent error checking, but ALE shouldn't block your ability to edit a
document after you save a file, so the asynchronous nature of the plugin will
still be an advantage.
2017-02-16 20:59:29 +00:00
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
2017-06-02 14:08:54 +00:00
`:ALELint` .
2017-11-18 18:59:03 +00:00
< 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.
2017-11-19 13:56:09 +00:00
< 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 = {
2017-11-19 13:57:04 +00:00
\ '\.min\.js$': {'ale_linters': [], 'ale_fixers': []},
\ '\.min\.css$': {'ale_linters': [], 'ale_fixers': []},
2017-11-19 13:56:09 +00:00
\}
" 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.