]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/README.md

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Do not set EDITOR/VISUAL for shell
[etc/vim.git] / .vim / bundle / ale / README.md
1 # Asynchronous Lint Engine
2
3 [![Vim](https://img.shields.io/badge/VIM-%2311AB00.svg?style=for-the-badge&logo=vim&logoColor=white)](https://www.vim.org/) [![Neovim](https://img.shields.io/badge/NeoVim-%2357A143.svg?&style=for-the-badge&logo=neovim&logoColor=white)](https://neovim.io/) [![CI](https://img.shields.io/github/actions/workflow/status/dense-analysis/ale/main.yml?branch=master&label=CI&logo=github&style=for-the-badge)](https://github.com/dense-analysis/ale/actions?query=event%3Apush+workflow%3ACI+branch%3Amaster++) [![AppVeyor Build Status](https://img.shields.io/appveyor/build/dense-analysis/ale?label=Windows&style=for-the-badge)](https://ci.appveyor.com/project/dense-analysis/ale) [![Join the Dense Analysis Discord server](https://img.shields.io/badge/chat-Discord-5865F2?style=for-the-badge&logo=appveyor)](https://discord.gg/5zFD6pQxDk)
4
5 ![ALE Logo by Mark Grealish - https://www.bhalash.com/](https://user-images.githubusercontent.com/3518142/59195920-2c339500-8b85-11e9-9c22-f6b7f69637b8.jpg)
6
7 ALE (Asynchronous Lint Engine) is a plugin providing linting (syntax checking
8 and semantic errors) in Neovim 0.7.0+ and Vim 8.0+ while you edit your text files,
9 and acts as a Vim [Language Server Protocol](https://langserver.org/) client.
10
11 <video autoplay="true" muted="true" loop="true" controls="false" src="https://user-images.githubusercontent.com/3518142/210141215-8f2ff760-6a87-4704-a11e-c109b8e9ec41.mp4" title="An example showing what ALE can do."></video>
12
13 ALE makes use of Neovim and Vim 8 job control functions and timers to
14 run linters on the contents of text buffers and return errors as
15 text is changed in Vim. This allows for displaying warnings and
16 errors in files being edited in Vim before files have been saved
17 back to a filesystem.
18
19 In other words, this plugin allows you to lint while you type.
20
21 ALE offers support for fixing code with command line tools in a non-blocking
22 manner with the `:ALEFix` feature, supporting tools in many languages, like
23 `prettier`, `eslint`, `autopep8`, and more.
24
25 ALE acts as a "language client" to support a variety of Language Server Protocol
26 features, including:
27
28 * Diagnostics (via Language Server Protocol linters)
29 * Go To Definition (`:ALEGoToDefinition`)
30 * Completion (Built in completion support, or with Deoplete)
31 * Finding references (`:ALEFindReferences`)
32 * Hover information (`:ALEHover`)
33 * Symbol search (`:ALESymbolSearch`)
34
35 If you don't care about Language Server Protocol, ALE won't load any of the code
36 for working with it unless needed. One of ALE's general missions is that you
37 won't pay for the features that you don't use.
38
39 **Help Wanted:** If you would like to help maintain this plugin by managing the
40 many issues and pull requests that are submitted, please send the author an
41 email at [dev@w0rp.com](mailto:dev@w0rp.com?subject=Helping%20with%20ALE).
42
43 If you enjoy this plugin, feel free to contribute or check out the author's
44 other content at [w0rp.com](https://w0rp.com).
45
46 ## Why ALE?
47
48 ALE has been around for many years, and there are many ways to run asynchronous
49 linting and fixing of code in Vim. ALE offers the following.
50
51 * No dependencies for ALE itself
52 * Lightweight plugin architecture (No JavaScript or Python required)
53 * Low memory footprint
54 * Runs virtually everywhere, including remote shells, and in `git commit`
55 * Out of the box support for running particular linters and language servers
56 * Near-zero configuration with custom code for better defaults
57 * Highly customizable and well-documented (`:help ale-options`)
58 * Breaking changes for the plugin are extremely rare
59 * Integrates with Neovim's LSP client (0.8+) and diagnostics (0.7+)
60 * Support for older Vim and Neovim versions
61 * Windows support
62 * Well-integrated with other plugins
63
64 ## Supported Languages and Tools
65
66 ALE supports a wide variety of languages and tools. See the
67 [full list](supported-tools.md) in the
68 [Supported Languages and Tools](supported-tools.md) page.
69
70 ## Usage
71
72 <a name="usage-linting"></a>
73
74 ### Linting
75
76 Once this plugin is installed, while editing your files in supported
77 languages and tools which have been correctly installed,
78 this plugin will send the contents of your text buffers to a variety of
79 programs for checking the syntax and semantics of your programs. By default,
80 linters will be re-run in the background to check your syntax when you open
81 new buffers or as you make edits to your files.
82
83 The behavior of linting can be configured with a variety of options,
84 documented in [the Vim help file](doc/ale.txt). For more information on the
85 options ALE offers, consult `:help ale-options` for global options and `:help
86 ale-integration-options` for options specified to particular linters.
87
88 <a name="usage-fixing"></a>
89
90 ### Fixing
91
92 ALE can fix files with the `ALEFix` command. Functions need to be configured
93 either in each buffer with a `b:ale_fixers`, or globally with `g:ale_fixers`.
94
95 The recommended way to configure fixers is to define a List in an ftplugin file.
96
97 ```vim
98 " In ~/.vim/ftplugin/javascript.vim, or somewhere similar.
99
100 " Fix files with prettier, and then ESLint.
101 let b:ale_fixers = ['prettier', 'eslint']
102 " Equivalent to the above.
103 let b:ale_fixers = {'javascript': ['prettier', 'eslint']}
104 ```
105
106 You can also configure your fixers from vimrc using `g:ale_fixers`, before or
107 after ALE has been loaded.
108
109 A `*` in place of the filetype will apply a List of fixers to all files which
110 do not match some filetype in the Dictionary.
111
112 Note that using a plain List for `g:ale_fixers` is not supported.
113
114 ```vim
115 " In ~/.vim/vimrc, or somewhere similar.
116 let g:ale_fixers = {
117 \   '*': ['remove_trailing_lines', 'trim_whitespace'],
118 \   'javascript': ['eslint'],
119 \}
120 ```
121
122 If you want to automatically fix files when you save them, you need to turn
123 a setting on in vimrc.
124
125 ```vim
126 " Set this variable to 1 to fix files when you save them.
127 let g:ale_fix_on_save = 1
128 ```
129
130 The `:ALEFixSuggest` command will suggest some supported tools for fixing code.
131 Both `g:ale_fixers` and `b:ale_fixers` can also accept functions, including
132 lambda functions, as fixers, for fixing files with custom tools.
133
134 See `:help ale-fix` for complete information on how to fix files with ALE.
135
136 <a name="usage-completion"></a>
137
138 ### Completion
139
140 ALE offers some support for completion via hijacking of omnicompletion while you
141 type. All of ALE's completion information must come from Language Server
142 Protocol linters, or from `tsserver` for TypeScript.
143
144 When running ALE in Neovim 0.8+, ALE will integrate with Neovim's LSP client by
145 default, and any auto-completion plugin that uses the native LSP client will
146 work when ALE runs language servers.
147 [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) is recommended as a
148 completion plugin worth trying in Neovim.
149
150 ALE integrates with [Deoplete](https://github.com/Shougo/deoplete.nvim) as a
151 completion source, named `'ale'`. You can configure Deoplete to only use ALE as
152 the source of completion information, or mix it with other sources.
153
154 ```vim
155 " Use ALE and also some plugin 'foobar' as completion sources for all code.
156 call deoplete#custom#option('sources', {
157 \ '_': ['ale', 'foobar'],
158 \})
159 ```
160
161 ALE also offers its own automatic completion support, which does not require any
162 other plugins, and can be enabled by changing a setting before ALE is loaded.
163
164 ```vim
165 " Enable completion where available.
166 " This setting must be set before ALE is loaded.
167 "
168 " You should not turn this setting on if you wish to use ALE as a completion
169 " source for other completion plugins, like Deoplete.
170 let g:ale_completion_enabled = 1
171 ```
172
173 ALE provides an omni-completion function you can use for triggering
174 completion manually with `<C-x><C-o>`.
175
176 ```vim
177 set omnifunc=ale#completion#OmniFunc
178 ```
179
180 ALE supports automatic imports from external modules. This behavior is enabled
181 by default and can be disabled by setting:
182
183 ```vim
184 let g:ale_completion_autoimport = 0
185 ```
186
187 Note that disabling auto import can result in missing completion items from some
188 LSP servers (e.g. eclipselsp). See `:help ale-completion` for more information.
189
190 <a name="usage-go-to-definition"></a>
191
192 ### Go To Definition
193
194 ALE supports jumping to the definition of words under your cursor with the
195 `:ALEGoToDefinition` command using any enabled Language Server Protocol linters
196 and `tsserver`. In Neovim 0.8+, you can also use Neovim's built in `gd` keybind
197 and more.
198
199 See `:help ale-go-to-definition` for more information.
200
201 <a name="usage-find-references"></a>
202
203 ### Find References
204
205 ALE supports finding references for words under your cursor with the
206 `:ALEFindReferences` command using any enabled Language Server Protocol linters
207 and `tsserver`.
208
209 See `:help ale-find-references` for more information.
210
211 <a name="usage-hover"></a>
212
213 ### Hovering
214
215 ALE supports "hover" information for printing brief information about symbols at
216 the cursor taken from Language Server Protocol linters and `tsserver` with the
217 `ALEHover` command.
218
219 Truncated information will be displayed when the cursor rests on a symbol by
220 default, as long as there are no problems on the same line.
221
222 The information can be displayed in a `balloon` tooltip in Vim or GVim by
223 hovering your mouse over symbols. Mouse hovering is enabled by default in GVim,
224 and needs to be configured for Vim 8.1+ in terminals.
225
226 See `:help ale-hover` for more information.
227
228 <a name="usage-symbol-search"></a>
229
230 ### Symbol Search
231
232 ALE supports searching for workspace symbols via Language Server Protocol
233 linters with the `ALESymbolSearch` command.
234
235 Search queries can be performed to find functions, types, and more which are
236 similar to a given query string.
237
238 See `:help ale-symbol-search` for more information.
239
240 <a name="usage-refactoring"></a>
241
242 ### Refactoring: Rename, Actions
243
244 ALE supports renaming symbols in code such as variables or class
245 names with the `ALERename` command.
246
247 `ALEFileRename` will rename file and fix import paths (tsserver
248 only).
249
250 `ALECodeAction` will execute actions on the cursor or applied to a visual
251 range selection, such as automatically fixing errors.
252
253 See `:help ale-refactor` for more information.
254
255 ## Installation
256
257 Add ALE to your runtime path in the usual ways.
258
259 If you have trouble reading `:help ale`, try the following.
260
261 ```vim
262 packloadall | silent! helptags ALL
263 ```
264
265 #### Vim `packload`:
266
267 ```bash
268 mkdir -p ~/.vim/pack/git-plugins/start
269 git clone --depth 1 https://github.com/dense-analysis/ale.git ~/.vim/pack/git-plugins/start/ale
270 ```
271
272 #### Neovim `packload`:
273
274 ```bash
275 mkdir -p ~/.local/share/nvim/site/pack/git-plugins/start
276 git clone --depth 1 https://github.com/dense-analysis/ale.git ~/.local/share/nvim/site/pack/git-plugins/start/ale
277 ```
278
279 #### Windows `packload`:
280
281 ```bash
282 # Run these commands in the "Git for Windows" Bash terminal
283 mkdir -p ~/vimfiles/pack/git-plugins/start
284 git clone --depth 1 https://github.com/dense-analysis/ale.git ~/vimfiles/pack/git-plugins/start/ale
285 ```
286
287 #### [vim-plug](https://github.com/junegunn/vim-plug)
288
289 ```vim
290 Plug 'dense-analysis/ale'
291 ```
292
293 #### [Vundle](https://github.com/VundleVim/Vundle.vim)
294
295 ```vim
296 Plugin 'dense-analysis/ale'
297 ```
298
299 #### [Pathogen](https://github.com/tpope/vim-pathogen)
300 ```vim
301 git clone https://github.com/dense-analysis/ale ~/.vim/bundle/ale
302 ```
303
304 #### [lazy.nvim](https://github.com/folke/lazy.nvim)
305 ```lua
306 {
307     'dense-analysis/ale',
308     config = function()
309         -- Configuration goes here.
310         local g = vim.g
311
312         g.ale_ruby_rubocop_auto_correct_all = 1
313
314         g.ale_linters = {
315             ruby = {'rubocop', 'ruby'},
316             lua = {'lua_language_server'}
317         }
318     end
319 }
320 ```
321
322 ## Contributing
323
324 If you would like to see support for more languages and tools, please
325 [create an issue](https://github.com/dense-analysis/ale/issues)
326 or [create a pull request](https://github.com/dense-analysis/ale/pulls).
327 If your tool can read from stdin or you have code to suggest which is good,
328 support can be happily added for it.
329
330 If you are interested in the general direction of the project, check out the
331 [wiki home page](https://github.com/dense-analysis/ale/wiki). The wiki includes
332 a Roadmap for the future, and more.
333
334 If you'd liked to discuss ALE and more check out the Dense Analysis Discord
335 server here: https://discord.gg/5zFD6pQxDk
336
337 ## FAQ
338
339 <a name="faq-disable-linters"></a>
340
341 ### How do I disable particular linters?
342
343 By default, all available tools for all supported languages will be run. If you
344 want to only select a subset of the tools, you can define `b:ale_linters` for a
345 single buffer, or `g:ale_linters` globally.
346
347 The recommended way to configure linters is to define a List in an ftplugin
348 file.
349
350 ```vim
351 " In ~/.vim/ftplugin/javascript.vim, or somewhere similar.
352
353 " Enable ESLint only for JavaScript.
354 let b:ale_linters = ['eslint']
355
356 " Equivalent to the above.
357 let b:ale_linters = {'javascript': ['eslint']}
358 ```
359
360 You can also declare which linters you want to run in your vimrc file, before or
361 after ALE has been loaded.
362
363 ```vim
364 " In ~/.vim/vimrc, or somewhere similar.
365 let g:ale_linters = {
366 \   'javascript': ['eslint'],
367 \}
368 ```
369
370 For all languages unspecified in the dictionary, all possible linters will
371 be run for those languages, just as when the dictionary is not defined.
372 Running many linters should not typically obstruct editing in Vim,
373 as they will all be executed in separate processes simultaneously.
374
375 If you don't want ALE to run anything other than what you've explicitly asked
376 for, you can set `g:ale_linters_explicit` to `1`.
377
378 ```vim
379 " Only run linters named in ale_linters settings.
380 let g:ale_linters_explicit = 1
381 ```
382
383 This plugin will look for linters in the [`ale_linters`](ale_linters) directory.
384 Each directory within corresponds to a particular filetype in Vim, and each file
385 in each directory corresponds to the name of a particular linter.
386
387 ### How do I disable a particular warning or error?
388
389 Warnings and errors should be configured in project configuration files for the
390 relevant tools. ALE supports disabling only warnings relating to trailing
391 whitespace, which Vim users often fix automatically.
392
393 ```vim
394 " Disable whitespace warnings
395 let g:ale_warn_about_trailing_whitespace = 0
396 ```
397
398 Users generally should not ignore warnings or errors in projects by changing
399 settings in their own editor. Instead, configure tools appropriately so any
400 other user of the same project will see the same problems.
401
402 <a name="faq-get-info"></a>
403
404 ### How can I see what ALE has configured for the current file?
405
406 Run the following to see what is currently configured:
407
408 ```vim
409 :ALEInfo
410 ```
411
412 ### How can I disable virtual text appearing at ends of lines?
413
414 By default, ALE displays errors and warnings with virtual text. The problems ALE
415 shows appear with comment-like syntax after every problem found. You can set ALE
416 to only show problems where the cursor currently lies like so.
417
418 ```vim
419 let g:ale_virtualtext_cursor = 'current'
420 ```
421
422 If you want to disable virtual text completely, apply the following.
423
424 ```vim
425 let g:ale_virtualtext_cursor = 'disabled'
426 ```
427
428 <a name="faq-keep-signs"></a>
429 <a name="faq-change-signs"></a>
430
431 ### How can I customise signs?
432
433 Use these options to specify what text should be used for signs:
434
435 ```vim
436 let g:ale_sign_error = '>>'
437 let g:ale_sign_warning = '--'
438 ```
439
440 ALE sets some background colors automatically for warnings and errors
441 in the sign gutter, with the names `ALEErrorSign` and `ALEWarningSign`.
442 These colors can be customised, or even removed completely:
443
444 ```vim
445 highlight clear ALEErrorSign
446 highlight clear ALEWarningSign
447 ```
448
449 You can configure the sign gutter open at all times, if you wish.
450
451 ```vim
452 let g:ale_sign_column_always = 1
453 ```
454
455 <a name="faq-change-highlights"></a>
456
457 ### How can I change or disable the highlights ALE uses?
458
459 ALE's highlights problems with highlight groups which link to `SpellBad`,
460 `SpellCap`, `error`, and `todo` groups by default. The characters that are
461 highlighted depend on the linters being used, and the information provided to
462 ALE.
463
464 Highlighting can be disabled completely by setting `g:ale_set_highlights` to
465 `0`.
466
467 ```vim
468 " Set this in your vimrc file to disabling highlighting
469 let g:ale_set_highlights = 0
470 ```
471
472 You can control all of the highlights ALE uses, say if you are using a different
473 color scheme which produces ugly highlights. For example:
474
475 ```vim
476 highlight ALEWarning ctermbg=DarkMagenta
477 ```
478
479 See `:help ale-highlights` for more information.
480
481 <a name="faq-echo-format"></a>
482
483 ### How can I change the format for echo messages?
484
485 There are 3 global options that allow customizing the echoed message.
486
487 - `g:ale_echo_msg_format` where:
488     * `%s` is the error message itself
489     * `%...code...%` is an optional error code, and most characters can be
490       written between the `%` characters.
491     * `%linter%` is the linter name
492     * `%severity%` is the severity type
493 - `g:ale_echo_msg_error_str` is the string used for error severity.
494 - `g:ale_echo_msg_warning_str` is the string used for warning severity.
495
496 So for example this:
497
498 ```vim
499 let g:ale_echo_msg_error_str = 'E'
500 let g:ale_echo_msg_warning_str = 'W'
501 let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
502 ```
503
504 Will give you:
505
506 ![Echoed message](https://user-images.githubusercontent.com/3518142/59195927-348bd000-8b85-11e9-88b6-508a094f1548.png)
507
508 See `:help g:ale_echo_msg_format` for more information.
509
510 <a name="faq-statusline"></a>
511 <a name="faq-lightline"></a>
512
513 ### How can I customise the statusline?
514
515 #### lightline
516
517 [lightline](https://github.com/itchyny/lightline.vim) does not have built-in
518 support for ALE, nevertheless there is a plugin that adds this functionality:
519 [maximbaz/lightline-ale](https://github.com/maximbaz/lightline-ale).
520
521 For more information, check out the sources of that plugin,
522 `:help ale#statusline#Count()` and
523 [lightline documentation](https://github.com/itchyny/lightline.vim#advanced-configuration).
524
525 #### vim-airline
526
527 [vim-airline](https://github.com/vim-airline/vim-airline) integrates with ALE
528 for displaying error information in the status bar. If you want to see the
529 status for ALE in a nice format, it is recommended to use vim-airline with ALE.
530 The airline extension can be enabled by adding the following to your vimrc:
531
532 ```vim
533 " Set this. Airline will handle the rest.
534 let g:airline#extensions#ale#enabled = 1
535 ```
536
537 #### Custom statusline
538
539 You can implement your own statusline function without adding any other plugins.
540 ALE provides some functions to assist in this endeavour, including:
541
542 * `ale#statusline#Count`: Which returns the number of problems found by ALE
543   for a specified buffer.
544 * `ale#statusline#FirstProblem`: Which returns a dictionary containing the
545   full loclist details of the first problem of a specified type found by ALE
546   in a buffer. (e.g. The first style warning in the current buffer.)
547   This can be useful for displaying more detailed information such as the
548   line number of the first problem in a file.
549
550 Say you want to display all errors as one figure, and all non-errors as another
551 figure. You can do the following:
552
553 ```vim
554 function! LinterStatus() abort
555     let l:counts = ale#statusline#Count(bufnr(''))
556
557     let l:all_errors = l:counts.error + l:counts.style_error
558     let l:all_non_errors = l:counts.total - l:all_errors
559
560     return l:counts.total == 0 ? 'OK' : printf(
561     \   '%dW %dE',
562     \   all_non_errors,
563     \   all_errors
564     \)
565 endfunction
566
567 set statusline=%{LinterStatus()}
568 ```
569
570 See `:help ale#statusline#Count()` or `:help ale#statusline#FirstProblem()`
571 for more information.
572
573 <a name="faq-window-borders"></a>
574
575 ### How can I change the borders for floating preview windows?
576
577 Borders for floating preview windows are enabled by default. You can use the
578 `g:ale_floating_window_border` setting to configure them.
579
580 You could disable the border with an empty list.
581
582 ```vim
583 let g:ale_floating_window_border = []
584 ```
585
586 If the terminal supports Unicode, you might try setting the value like below, to
587 make it look nicer.
588
589 ```vim
590 let g:ale_floating_window_border = ['│', '─', '╭', '╮', '╯', '╰', '│', '─']
591 ```
592
593 Since vim's default uses nice Unicode characters when possible, you can trick
594 ale into using that default with
595
596 ```vim
597 let g:ale_floating_window_border = repeat([''], 8)
598 ```
599
600 <a name="faq-my-battery-is-sad"></a>
601
602 ### Will this plugin eat all of my laptop battery power?
603
604 ALE takes advantage of the power of various tools to check your code. This of
605 course means that CPU time will be used to continuously check your code. If you
606 are concerned about the CPU time ALE will spend, which will of course imply
607 some cost to battery life, you can adjust your settings to make your CPU do
608 less work.
609
610 First, consider increasing the delay before which ALE will run any linters
611 while you type. ALE uses a timeout which is cancelled and reset every time you
612 type, and this delay can be increased so linters are run less often. See
613 `:help g:ale_lint_delay` for more information.
614
615 If you don't wish to run linters while you type, you can disable that behavior.
616 Set `g:ale_lint_on_text_changed` to `never`. You won't get as frequent error
617 checking, but ALE shouldn't block your ability to edit a document after you save
618 a file, so the asynchronous nature of the plugin will still be an advantage.
619
620 If you are still concerned, you can turn the automatic linting off altogether,
621 including the option `g:ale_lint_on_enter`, and you can run ALE manually with
622 `:ALELint`.
623
624 <a name="faq-coc-nvim"></a>
625 <a name="faq-vim-lsp"></a>
626
627 ### How can I use ALE with other LSP clients?
628
629 ALE offers an API for letting any other plugin integrate with ALE. If you are
630 interested in writing an integration, see `:help ale-lint-other-sources`.
631
632 If you're running ALE in Neovim with
633 [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) for configuring
634 particular language servers, ALE will automatically disable its LSP
635 functionality for any language servers configured with nvim-lspconfig by
636 default. The following setting is applied by default:
637
638 ```vim
639 let g:ale_disable_lsp = 'auto'
640 ```
641
642 If you are running ALE in combination with another LSP client, you may wish to
643 disable ALE's LSP functionality entirely. You can change the setting to `1` to
644 always disable all LSP functionality.
645
646 ```vim
647 let g:ale_disable_lsp = 1
648 ```
649
650 You can also use `b:ale_disable_lsp` in your ftplugin files to enable or disable
651 LSP features in ALE for different filetypes.
652
653 #### Neovim Diagnostics
654
655 If you are running Neovim 0.7 or later, you can make ALE display errors and
656 warnings via the Neovim diagnostics API.
657
658 ```vim
659 let g:ale_use_neovim_diagnostics_api = 1
660 ```
661
662 <!-- We could expand this section to say a little more. -->
663
664 #### coc.nvim
665
666 [coc.nvim](https://github.com/neoclide/coc.nvim) is a popular Vim plugin written
667 in TypeScript and dependent on the [npm](https://www.npmjs.com/) ecosystem for
668 providing full IDE features to Vim. Both ALE and coc.nvim implement
669 [Language Server Protocol](https://microsoft.github.io/language-server-protocol/)
670 (LSP) clients for supporting diagnostics (linting with a live server), and other
671 features like auto-completion, and others listed above.
672
673 ALE is primarily focused on integrating with external programs through virtually
674 any means, provided the plugin remains almost entirely written in Vim script.
675 coc.nvim is primarily focused on bringing IDE features to Vim. If you want to
676 run external programs on your files to check for errors, and also use the most
677 advanced IDE features, you might want to use both plugins at the same time.
678
679 The easiest way to get both plugins to work together is to configure coc.nvim to
680 send diagnostics to ALE, so ALE controls how all problems are presented to you,
681 and to disable all LSP features in ALE, so ALE doesn't try to provide LSP
682 features already provided by coc.nvim, such as auto-completion.
683
684 Open your coc.nvim configuration file with `:CocConfig` and add
685 `"diagnostic.displayByAle": true` to your settings.
686
687 #### vim-lsp
688
689 [vim-lsp](https://github.com/prabirshrestha/vim-lsp) is a popular plugin as
690 implementation of Language Server Protocol (LSP) client for Vim. It provides
691 all the LSP features including auto completion, diagnostics, go to definitions,
692 etc.
693
694 [vim-lsp-ale](https://github.com/rhysd/vim-lsp-ale) is a bridge plugin to solve
695 the problem when using both ALE and vim-lsp. With the plugin, diagnostics are
696 provided by vim-lsp and ALE can handle all the errors. Please read
697 [vim-lsp-ale's documentation](https://github.com/rhysd/vim-lsp-ale/blob/master/doc/vim-lsp-ale.txt)
698 for more details.
699
700 <a name="faq-autocmd"></a>
701
702 ### How can I execute some code when ALE starts or stops linting?
703
704 ALE runs its own [autocmd](http://vimdoc.sourceforge.net/htmldoc/autocmd.html)
705 events when a lint or fix cycle are started and stopped. There is also an event
706 that runs when a linter job has been successfully started. These events can be
707 used to call arbitrary functions during these respective parts of the ALE's
708 operation.
709
710 ```vim
711 augroup YourGroup
712     autocmd!
713     autocmd User ALELintPre    call YourFunction()
714     autocmd User ALELintPost   call YourFunction()
715
716     autocmd User ALEJobStarted call YourFunction()
717
718     autocmd User ALEFixPre     call YourFunction()
719     autocmd User ALEFixPost    call YourFunction()
720 augroup END
721 ```
722
723 <a name="faq-navigation"></a>
724
725 ### How can I navigate between errors quickly?
726
727 ALE offers some commands with `<Plug>` keybinds for moving between warnings and
728 errors quickly. You can map the keys Ctrl+j and Ctrl+k to moving between errors
729 for example:
730
731 ```vim
732 nmap <silent> <C-k> <Plug>(ale_previous_wrap)
733 nmap <silent> <C-j> <Plug>(ale_next_wrap)
734 ```
735
736 For more information, consult the online documentation with
737 `:help ale-navigation-commands`.
738
739 <a name="faq-lint-on-save"></a>
740
741 ### How can I run linters only when I save files?
742
743 ALE offers an option `g:ale_lint_on_save` for enabling running the linters when
744 files are saved. This option is enabled by default. If you only wish to run
745 linters when files are saved, you can turn the other options off.
746
747 ```vim
748 " Write this in your vimrc file
749 let g:ale_lint_on_text_changed = 'never'
750 let g:ale_lint_on_insert_leave = 0
751 " You can disable this option too
752 " if you don't want linters to run on opening a file
753 let g:ale_lint_on_enter = 0
754 ```
755
756 If for whatever reason you don't wish to run linters again when you save files,
757 you can set `g:ale_lint_on_save` to `0`.
758
759 <a name="faq-quickfix"></a>
760
761 ### How can I use the quickfix list instead of the loclist?
762
763 The quickfix list can be enabled by turning the `g:ale_set_quickfix` option on.
764 If you wish to also disable the loclist, you can disable the `g:ale_set_loclist`
765 option.
766
767 ```vim
768 " Write this in your vimrc file
769 let g:ale_set_loclist = 0
770 let g:ale_set_quickfix = 1
771 ```
772
773 If you wish to show Vim windows for the loclist or quickfix items when a file
774 contains warnings or errors, `g:ale_open_list` can be set to `1`.
775 `g:ale_keep_list_window_open` can be set to `1` if you wish to keep the window
776 open even after errors disappear.
777
778 ```vim
779 let g:ale_open_list = 1
780 " Set this if you want to.
781 " This can be useful if you are combining ALE with
782 " some other plugin which sets quickfix errors, etc.
783 let g:ale_keep_list_window_open = 1
784 ```
785
786 You can also set `let g:ale_list_vertical = 1` to open the windows vertically
787 instead of the default horizontally.
788
789 ### Why isn't ALE checking my filetype?
790
791 <a name="faq-jsx-stylelint-eslint"></a>
792
793 #### stylelint for JSX
794
795 First, install eslint and install stylelint with
796 [stylelint-processor-styled-components](https://github.com/styled-components/stylelint-processor-styled-components).
797
798 Supposing you have installed both tools correctly, configure your .jsx files so
799 `jsx` is included in the filetype. You can use an `autocmd` for this.
800
801 ```vim
802 augroup FiletypeGroup
803     autocmd!
804     au BufNewFile,BufRead *.jsx set filetype=javascript.jsx
805 augroup END
806 ```
807
808 Supposing the filetype has been set correctly, you can set the following
809 options in a jsx.vim ftplugin file.
810
811 ```vim
812 " In ~/.vim/ftplugin/jsx.vim, or somewhere similar.
813 let b:ale_linter_aliases = ['css', 'javascript']
814 let b:ale_linters = ['stylelint', 'eslint']
815 ```
816
817 Or if you want, you can configure the linters from your vimrc file.
818
819 ```vim
820 " In ~/.vim/vimrc, or somewhere similar.
821 let g:ale_linter_aliases = {'jsx': ['css', 'javascript']}
822 let g:ale_linters = {'jsx': ['stylelint', 'eslint']}
823 ```
824
825 ALE will alias the `jsx` filetype so it uses the `css` filetype linters, and
826 use the original Array of selected linters for `jsx` from the `g:ale_linters`
827 object. All available linters will be used for the filetype `javascript`, and
828 no linter will be run twice for the same file.
829
830 <a name="faq-vue-eslint"></a>
831
832 #### Checking Vue with ESLint
833
834 To check Vue files with ESLint, your ESLint project configuration file must be
835 configured to use the [Vue plugin](https://github.com/vuejs/eslint-plugin-vue).
836 After that, you need to configure ALE so it will run the JavaScript ESLint
837 linter on your files. The settings you need are similar to the settings needed
838 for checking JSX code with both stylelint and ESLint, in the previous section.
839
840 ```vim
841 " In ~/.vim/ftplugin/vue.vim, or somewhere similar.
842
843 " Run both javascript and vue linters for vue files.
844 let b:ale_linter_aliases = ['javascript', 'vue']
845 " Select the eslint and vls linters.
846 let b:ale_linters = ['eslint', 'vls']
847 ```
848
849 Run `:ALEInfo` to see which linters are available after telling ALE to run
850 JavaScript linters on Vue files. Not all linters support checking Vue files.
851
852 If you don't want to configure your linters in ftplugin files for some reason,
853 you can configure them from your vimrc file instead.
854
855 ```vim
856 " In ~/.vim/vimrc, or somewhere similar.
857 let g:ale_linter_aliases = {'vue': ['vue', 'javascript']}
858 let g:ale_linters = {'vue': ['eslint', 'vls']}
859 ```
860
861 <a name="faq-c-configuration"></a>
862
863 ### How can I configure my C or C++ project?
864
865 The structure of C and C++ projects varies wildly from project to project, with
866 many different build tools being used for building them, and many different
867 formats for project configuration files. ALE can run compilers easily, but
868 ALE cannot easily detect which compiler flags to use.
869
870 Some tools and build configurations can generate
871 [compile_commands.json](https://clang.llvm.org/docs/JSONCompilationDatabase.html)
872 files. The `cppcheck`, `clangcheck`, `clangtidy` and `cquery` linters can read
873 these files for automatically determining the appropriate compiler flags to
874 use.
875
876 For linting with compilers like `gcc` and `clang`, and with other tools, you
877 will need to tell ALE which compiler flags to use yourself. You can use
878 different options for different projects with the `g:ale_pattern_options`
879 setting.  Consult the documentation for that setting for more information.
880 `b:ale_linters` can be used to select which tools you want to run, say if you
881 want to use only `gcc` for one project, and only `clang` for another.
882
883 ALE will attempt to parse `compile_commands.json` files to discover compiler
884 flags to use when linting code. See `:help g:ale_c_parse_compile_commands` for
885 more information. See Clang's documentation for
886 [compile_commands.json files](https://clang.llvm.org/docs/JSONCompilationDatabase.html).
887 You should strongly consider generating them in your builds, which is easy to do
888 with CMake.
889
890 You can also configure ALE to automatically run `make -n` to run dry runs on
891 `Makefile`s to discover compiler flags. This can execute arbitrary code, so the
892 option is disabled by default. See `:help g:ale_c_parse_makefile`.
893
894 <a name="faq-vm"></a>
895
896 ### How can I run linters or fixers via Docker or a VM?
897
898 ALE supports running linters or fixers via Docker, virtual machines, or in
899 combination with any remote machine with a different file system, so long as the
900 tools are well-integrated with ALE, and ALE is properly configured to run the
901 correct commands and map filename paths between different file systems. See
902 `:help ale-lint-other-machines` for the full documentation on how to configure
903 ALE to support this.