Document completion support for ALE, and expand the fixer documentation a little

This commit is contained in:
w0rp 2017-08-18 00:08:58 +01:00
parent 0a282eb76a
commit 2365fd2948
2 changed files with 115 additions and 12 deletions

View file

@ -22,6 +22,9 @@ background with a command `ALEFix`.
1. [Supported Languages and Tools](#supported-languages) 1. [Supported Languages and Tools](#supported-languages)
2. [Usage](#usage) 2. [Usage](#usage)
1. [Linting](#usage-linting)
2. [Fixing](#usage-fixing)
3. [Completion](#usage-completion)
3. [Installation](#installation) 3. [Installation](#installation)
1. [Installation with Vim package management](#standard-installation) 1. [Installation with Vim package management](#standard-installation)
2. [Installation with Pathogen](#installation-with-pathogen) 2. [Installation with Pathogen](#installation-with-pathogen)
@ -136,6 +139,10 @@ name. That seems to be the fairest way to arrange this table.
## 2. Usage ## 2. Usage
<a name="usage-linting"></a>
### 2.i Linting
Once this plugin is installed, while editing your files in supported Once this plugin is installed, while editing your files in supported
languages and tools which have been correctly installed, languages and tools which have been correctly installed,
this plugin will send the contents of your text buffers to a variety of this plugin will send the contents of your text buffers to a variety of
@ -148,8 +155,46 @@ 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 options ALE offers, consult `:help ale-options` for global options and `:help
ale-linter-options` for options specified to particular linters. ale-linter-options` for options specified to particular linters.
<a name="usage-fixing"></a>
### 2.ii Fixing
ALE can fix files with the `ALEFix` command. Functions need to be configured ALE can fix files with the `ALEFix` command. Functions need to be configured
for different filetypes with the `g:ale_fixers` variable. See `:help ale-fix`. 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.
<a name="installation"></a> <a name="installation"></a>

View file

@ -11,7 +11,8 @@ CONTENTS *ale-contents*
3. Global Options.......................|ale-options| 3. Global Options.......................|ale-options|
3.1 Highlights........................|ale-highlights| 3.1 Highlights........................|ale-highlights|
4. Fixing Problems......................|ale-fix| 4. Fixing Problems......................|ale-fix|
5. Integration Documentation............|ale-integrations| 5. Completion...........................|ale-completion|
6. Integration Documentation............|ale-integrations|
asm...................................|ale-asm-options| asm...................................|ale-asm-options|
gcc.................................|ale-asm-gcc| gcc.................................|ale-asm-gcc|
c.....................................|ale-c-options| c.....................................|ale-c-options|
@ -132,10 +133,10 @@ CONTENTS *ale-contents*
yaml..................................|ale-yaml-options| yaml..................................|ale-yaml-options|
swaglint............................|ale-yaml-swaglint| swaglint............................|ale-yaml-swaglint|
yamllint............................|ale-yaml-yamllint| yamllint............................|ale-yaml-yamllint|
6. Commands/Keybinds....................|ale-commands| 7. Commands/Keybinds....................|ale-commands|
7. API..................................|ale-api| 8. API..................................|ale-api|
8. Special Thanks.......................|ale-special-thanks| 9. Special Thanks.......................|ale-special-thanks|
9. Contact..............................|ale-contact| 10. Contact.............................|ale-contact|
=============================================================================== ===============================================================================
1. Introduction *ale-introduction* 1. Introduction *ale-introduction*
@ -271,6 +272,44 @@ g:ale_change_sign_column_color *g:ale_change_sign_column_color*
windows. windows.
g:ale_completion_delay *g:ale_completion_delay*
Type: |Number|
Default: `100`
The number of milliseconds before ALE will send a request to a language
server for completions after you have finished typing.
See |ale-completion|
g:ale_completion_enabled *g:ale_completion_enabled*
Type: |Number|
Default: `0`
When this option is set to `1`, completion support will be enabled.
See |ale-completion|
g:ale_completion_max_suggestions *g:ale_completion_max_suggestions*
Type: |Number|
Default: `20`
The maximum number of items ALE will suggest in completion menus for
automatic completion.
Setting this number higher will require more processing time, and may
suggest too much noise. Setting this number lower will require less
processing time, but some suggestions will not be included, so you might not
be able to see the suggestions you want.
Adjust this option as needed, depending on the complexity of your codebase
and your available processing power.
g:ale_echo_cursor *g:ale_echo_cursor* g:ale_echo_cursor *g:ale_echo_cursor*
Type: |Number| Type: |Number|
@ -410,7 +449,7 @@ g:ale_keep_list_window_open *g:ale_keep_list_window_open*
the loclist or quicfix windows will be closed automatically when there the loclist or quicfix windows will be closed automatically when there
are no warnings or errors. are no warnings or errors.
See: |g:ale_open_list| See |g:ale_open_list|
g:ale_list_window_size *g:ale_list_window_size* g:ale_list_window_size *g:ale_list_window_size*
@ -1031,7 +1070,26 @@ by default.
=============================================================================== ===============================================================================
5. Integration Documentation *ale-integrations* 5. Completion *ale-completion*
ALE offers some limited support for automatic completion of code while you
type. Completion is only supported via Language Server Protocol servers which
ALE can connect to for linting, which can offer good built-in support for
suggesting completion information. ALE will only suggest symbols for
completion for LSP linters that are enabled.
NOTE: At the moment, only `tsserver` for TypeScript code is supported for
completion.
Suggestions will be made while you type after completion is enabled.
Completion can be enabled by setting |g:ale_completion_enabled| to `1`. The
delay for completion can be configured with |g:ale_completion_delay|. ALE will
only suggest so many possible matches for completion. The maximum number of
items can be controlled with |g:ale_completion_max_suggestions|.
===============================================================================
6. Integration Documentation *ale-integrations*
Linter and fixer options are documented in individual help files. See the Linter and fixer options are documented in individual help files. See the
table of contents at |ale-contents|. table of contents at |ale-contents|.
@ -1064,7 +1122,7 @@ ALE will use to search for Python executables.
=============================================================================== ===============================================================================
6. Commands/Keybinds *ale-commands* 7. Commands/Keybinds *ale-commands*
ALEFix *ALEFix* ALEFix *ALEFix*
@ -1167,7 +1225,7 @@ ALEInfoToClipboard *ALEInfoToClipboard*
=============================================================================== ===============================================================================
7. API *ale-api* 8. API *ale-api*
ale#Queue(delay, [linting_flag, buffer_number]) *ale#Queue()* ale#Queue(delay, [linting_flag, buffer_number]) *ale#Queue()*
@ -1557,13 +1615,13 @@ ALELint *ALELint-autocmd*
echoing messges. echoing messges.
=============================================================================== ===============================================================================
8. Special Thanks *ale-special-thanks* 9. Special Thanks *ale-special-thanks*
Special thanks to Mark Grealish (https://www.bhalash.com/) for providing ALE's Special thanks to Mark Grealish (https://www.bhalash.com/) for providing ALE's
snazzy looking ale glass logo. Cheers, Mark! snazzy looking ale glass logo. Cheers, Mark!
=============================================================================== ===============================================================================
9. Contact *ale-contact* 10. Contact *ale-contact*
If you like this plugin, and wish to get in touch, check out the GitHub If you like this plugin, and wish to get in touch, check out the GitHub
page for issues and more at https://github.com/w0rp/ale page for issues and more at https://github.com/w0rp/ale