ale_linters | ||
autoload | ||
doc | ||
img | ||
plugin | ||
test | ||
.eslintrc.js | ||
.gitattributes | ||
.gitignore | ||
.travis.yml | ||
CONTRIBUTING.md | ||
dmd-wrapper | ||
Dockerfile | ||
LICENSE | ||
Makefile | ||
README.md | ||
stdin-wrapper | ||
stdin-wrapper.exe | ||
stdin_wrapper.d |
Asynchronous Lint Engine
ALE (Asynchronous Lint Engine) is a plugin for providing linting in NeoVim and Vim 8 while you edit your text files.
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 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.
Table of Contents
- Supported Languages and Tools
- Usage
- Installation
- Installation with Pathogen
- Installation with Vundle
- Manual Installation
- FAQ
- How do I disable particular linters?
- How can I keep the sign gutter open?
- How can I change the signs ALE uses?
- How can I show errors or warnings in my statusline?
- How can I change the format for echo messages?
- How can I execute some code when ALE stops linting?
- How can I navigate between errors quickly?
1. Supported Languages and Tools
This plugin supports the following languages and tools. All available tools will be run in combination, so they can be complementary.
Language | Tools |
---|---|
Ansible | ansible-lint |
Bash | -n flag, shellcheck |
Bourne Shell | -n flag, shellcheck |
C | cppcheck, gcc |
C++ (filetype cpp) | [cppcheck] (http://cppcheck.sourceforge.net), gcc |
CoffeeScript | coffee, coffeelint |
CSS | csslint |
Cython (pyrex filetype) | cython |
D | dmd^ |
Elixir | credo |
Fortran | gcc |
Go | gofmt -e, go vet, golint |
Haskell | ghc, hlint |
HTML | HTMLHint, tidy |
JavaScript | eslint, jscs, jshint |
JSON | jsonlint |
Lua | luacheck |
Markdown | mdl |
MATLAB | mlint |
Perl | perl -c, perl-critic |
PHP | php -l, phpcs |
Pug | pug-lint |
Python | flake8 |
Ruby | rubocop |
SASS | sass-lint |
SCSS | sass-lint, scss-lint |
Scala | scalac |
TypeScript | tslint |
Verilog | iverilog, verilator |
Vim | vint |
YAML | yamllint |
^ Supported only on Unix machines via a wrapper script.
If you would like to see support for more languages and tools, please create an issue or create a pull request. If your tool can read from stdin or you have code to suggest which is good, support can be happily added for more tools.
2. Usage
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.
The behaviour of linting can be configured with a variety of options,
documented in the Vim help file. 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.
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
%USERPROFILE%\_vim
, or another directory if you have configured
Vim differently. On Windows, your ~/.vimrc
file will be similarly
stored in %USERPROFILE%\_vimrc
.
3.i. Installation with Pathogen
To install this module with 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:
cd ~/.vim/bundle
git clone https://github.com/w0rp/ale.git
3.ii. Installation with Vundle
You can install this plugin using Vundle by using the path on GitHub for this repository.
Plugin 'w0rp/ale'
See the Vundle documentation for more information.
3.iii. Manual Installation
For installation without a package manager, you can clone this git repository into a bundle directory as with pathogen, and add the repository to your runtime path yourself. First clone the repository.
cd ~/.vim/bundle
git clone https://github.com/w0rp/ale.git
Then, modify your ~/.vimrc
file to add this plugin to your runtime path.
set nocompatible
filetype off
let &runtimepath.=',~/.vim/bundle/ale'
filetype plugin on
You can add the following line to generate documentation tags automatically,
if you don't have something similar already, so you can use the :help
command
to consult ALE's online documentation:
silent! helptags ALL
Because the author of this plugin is a weird nerd, this is his preferred installation method.
4. FAQ
4.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, simply create a
g:ale_linters
dictionary in your vimrc file mapping filetypes
to lists of linters to run.
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
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.
4.ii. How can I keep the sign gutter open?
You can keep the sign gutter open at all times by setting the
g:ale_sign_column_always
to 1
let g:ale_sign_column_always = 1
4.iii. How can I change the signs ALE uses?
Use these options to specify what text should be used for signs:
let g:ale_sign_error = '>>'
let g:ale_sign_warning = '--'
4.iv. How can I show errors or warnings in my statusline?
You can use ALEGetStatusLine()
to integrate ALE into vim statusline.
To enable it, you should have in your statusline
settings
%{ALEGetStatusLine()}
When errors are detected a string showing the number of errors will be shown.
You can customize the output format using the global list g:ale_statusline_format
where:
- The 1st element is for errors
- The 2nd element is for warnings
- The 3rd element is for when no errors are detected
e.g
let g:ale_statusline_format = ['⨉ %d', '⚠ %d', '⬥ ok']
4.v. 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%linter%
is the linter name%severity
is the severity type
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:
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
Will give you:
4.vi. How can I execute some code when ALE stops linting?
ALE runs its own autocmd 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.
augroup YourGroup
autocmd!
autocmd User ALELint call YourFunction()
augroup END
4.vii. 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
for example:
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
.