summaryrefslogtreecommitdiff
path: root/doc/ale.txt
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2020-08-23 19:55:42 +0100
committerw0rp <devw0rp@gmail.com>2020-08-23 19:55:42 +0100
commitba3dd0d02735e7b23918200ae58410b0deed2f62 (patch)
tree83012a41e42d746629fbf07293a1b3e7b7ed0fe6 /doc/ale.txt
parent2b785688ead505dcbc1007374d3dca9914aa247a (diff)
downloadale-ba3dd0d02735e7b23918200ae58410b0deed2f62.zip
Close #2556 - Support filename mapping
ALE now supports mapping files between different systems for running linters and fixers with Docker, in virtual machines, in servers, etc.
Diffstat (limited to 'doc/ale.txt')
-rw-r--r--doc/ale.txt197
1 files changed, 181 insertions, 16 deletions
diff --git a/doc/ale.txt b/doc/ale.txt
index 81271105..7327959b 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -9,8 +9,9 @@ CONTENTS *ale-contents*
1. Introduction.........................|ale-introduction|
2. Supported Languages & Tools..........|ale-support|
3. Linting..............................|ale-lint|
- 3.1 Adding Language Servers...........|ale-lint-language-servers|
- 3.2 Other Sources.....................|ale-lint-other-sources|
+ 3.1 Linting On Other Machines.........|ale-lint-other-machines|
+ 3.2 Adding Language Servers...........|ale-lint-language-servers|
+ 3.3 Other Sources.....................|ale-lint-other-sources|
4. Fixing Problems......................|ale-fix|
5. Language Server Protocol Support.....|ale-lsp|
5.1 Completion........................|ale-completion|
@@ -148,7 +149,61 @@ ALE offers several options for controlling which linters are run.
-------------------------------------------------------------------------------
-3.1 Adding Language Servers *ale-lint-language-servers*
+3.1 Linting On Other Machines *ale-lint-other-machines*
+
+ALE offers support for running linters or fixers on files you are editing
+locally on other machines, so long as the other machine has access the file
+you are editing. This could be a linter or fixer run inside of a Docker image,
+running in a virtual machine, running on a remote server, etc.
+
+In order to run tools on other machines, you will need to configure your tools
+to run via scripts that execute commands on those machines, such as by setting
+the ALE `_executable` options for those tools to a path for a script to run,
+or by using |g:ale_command_wrapper| to specify a script to wrap all commands
+that are run by ALE, before they are executed. For tools that ALE runs where
+ALE looks for locally installed executables first, you may need to set the
+`_use_global` options for those tools to `1`, or you can set
+|g:ale_use_global_executables| to `1` before ALE is loaded to only use global
+executables for all tools.
+
+In order for ALE to properly lint or fix files which are running on another
+file system, you must provide ALE with |List|s of strings for mapping paths to
+and from your local file system and the remote file system, such as the file
+system of your Docker container. See |g:ale_filename_mappings| for all of the
+different ways these filename mappings can be configured.
+
+For example, you might configure `pylint` to run via Docker by creating a
+script like so. >
+
+ #!/usr/bin/env bash
+
+ exec docker run --rm -v "$(pwd):/data" cytopia/pylint "$@"
+<
+With the above script in mind, you might configure ALE to lint your Python
+project with `pylint` by providing the path to the script to execute, and
+mappings which describe how to between the two file systems in your
+`python.vim` |ftplugin| file, like so: >
+
+ if expand('%:p') =~# '^/home/w0rp/git/test-pylint/'
+ let b:ale_linters = ['pylint']
+ let b:ale_python_pylint_use_global = 1
+ " This is the path to the script above.
+ let b:ale_python_pylint_executable = '/home/w0rp/git/test-pylint/pylint.sh'
+ " /data matches the path in Docker.
+ let b:ale_filename_mappings = {
+ \ 'pylint': [
+ \ ['/home/w0rp/git/test-pylint', '/data'],
+ \ ],
+ \}
+ endif
+<
+
+You might consider using a Vim plugin for loading Vim configuration files
+specific to each project, if you have a lot of projects to manage.
+
+
+-------------------------------------------------------------------------------
+3.2 Adding Language Servers *ale-lint-language-servers*
ALE comes with many default configurations for language servers, so they can
be detected and run automatically. ALE can connect to other language servers
@@ -189,7 +244,7 @@ address to connect to instead. >
-------------------------------------------------------------------------------
-3.2 Other Sources *ale-lint-other-sources*
+3.3 Other Sources *ale-lint-other-sources*
Problems for a buffer can be taken from other sources and rendered by ALE.
This allows ALE to be used in combination with other plugins which also want
@@ -356,6 +411,10 @@ by default.
Fixers can be disabled on save with |g:ale_fix_on_save_ignore|. They will
still be run when you manually run |ALEFix|.
+Fixers can be run on another machines, just like linters, such as fixers run
+from a Docker container, running in a virtual machine, running a remote
+server, etc. See |ale-lint-other-machines|.
+
===============================================================================
5. Language Server Protocol Support *ale-lsp*
@@ -1286,6 +1345,90 @@ g:ale_linter_aliases *g:ale_linter_aliases*
<
No linters will be loaded when the buffer's filetype is empty.
+
+g:ale_filename_mappings *g:ale_filename_mappings*
+ *b:ale_filename_mappings*
+
+ Type: |Dictionary| or |List|
+ Default: `{}`
+
+ Either a |Dictionary| mapping a linter or fixer name, as displayed in
+ |:ALEInfo|, to a |List| of two-item |List|s for filename mappings, or just a
+ |List| of two-item |List|s. When given some paths to files, the value of
+ this setting will be used to convert filenames on a local file system to
+ filenames on some remote file system, such as paths in a Docker image,
+ virtual machine, or network drive.
+
+ For example: >
+
+ let g:ale_filename_mappings = {
+ \ 'pylint': [
+ \ ['/home/john/proj', '/data'],
+ \ ],
+ \}
+<
+ With the above configuration, a filename such as `/home/john/proj/foo.py`
+ will be provided to the linter/fixer as `/data/foo.py`, and paths parsed
+ from linter results such as `/data/foo.py` will be converted back to
+ `/home/john/proj/foo.py`.
+
+ You can use `*` as to apply a |List| of filename mappings to all other
+ linters or fixers not otherwise matched. >
+
+ " Use one List of paths for pylint.
+ " Use another List of paths for everything else.
+ let g:ale_filename_mappings = {
+ \ 'pylint': [
+ \ ['/home/john/proj', '/data'],
+ \ ],
+ \ '*': [
+ \ ['/home/john/proj', '/other-data'],
+ \ ],
+ \}
+<
+ If you just want every single linter or fixer to use the same filename
+ mapping, you can just use a |List|. >
+
+ " Same as above, but for ALL linters and fixers.
+ let g:ale_filename_mappings = [
+ \ ['/home/john/proj', '/data'],
+ \]
+<
+ You can provide many such filename paths for multiple projects. Paths are
+ matched by checking if the start of a file path matches the given strings,
+ in a case-sensitive manner. Earlier entries in the |List| will be tried
+ before later entries when mapping to a given file system.
+
+ Buffer-local options can be set to the same values to override the global
+ options, such as in |ftplugin| files.
+
+ NOTE: Only fixers registered with a short name can support filename mapping
+ by their fixer names. See |ale-fix|. Filename mappings set for all tools by
+ using only a |List| for the setting will also be applied to fixers not in
+ the registry.
+
+ NOTE: In order for this filename mapping to work correctly, linters and
+ fixers must exclusively determine paths to files to lint or fix via ALE
+ command formatting as per |ale-command-format-strings|, and paths parsed
+ from linter files must be provided in `filename` keys if a linter returns
+ results for more than one file at a time, as per |ale-loclist-format|. If
+ you discover a linter or fixer which does not behave properly, please report
+ it as an issue.
+
+ If you are running a linter or fixer through Docker or another remote file
+ system, you may have to mount your temporary directory, which you can
+ discover with the following command: >
+
+ :echo fnamemodify(tempname(), ':h:h')
+<
+ You should provide a mapping from this temporary directory to whatever you
+ mount this directory to in Docker, or whatever remote file system you are
+ working with.
+
+ You can inspect the filename mappings ALE will use with the
+ |ale#GetFilenameMappings()| function.
+
+
g:ale_linters *g:ale_linters*
*b:ale_linters*
Type: |Dictionary|
@@ -3073,6 +3216,15 @@ ale#Env(variable_name, value) *ale#Env()*
'set VAR="some value" && command' # On Windows
+ale#GetFilenameMappings(buffer, name) *ale#GetFilenameMappings()*
+
+ Given a `buffer` and the `name` of either a linter for fixer, return a
+ |List| of two-item |List|s that describe mapping to and from the local and
+ foreign file systems for running a particular linter or fixer.
+
+ See |g:ale_filename_mappings| for details on filename mapping.
+
+
ale#Has(feature) *ale#Has()*
Return `1` if ALE supports a given feature, like |has()| for Vim features.
@@ -3187,23 +3339,36 @@ ale#command#Run(buffer, command, callback, [options]) *ale#command#Run()*
<
The following `options` can be provided.
- `output_stream` - Either `'stdout'`, `'stderr'`, `'both'`, or `'none`' for
- selecting which output streams to read lines from.
+ `output_stream` - Either `'stdout'`, `'stderr'`, `'both'`, or
+ `'none`' for selecting which output streams to read
+ lines from.
+
+ The default is `'stdout'`
+
+ `executable` - An executable for formatting into `%e` in the
+ command. If this option is not provided, formatting
+ commands with `%e` will not work.
+
+ `read_buffer` - If set to `1`, the buffer will be piped into the
+ command.
+
+ The default is `0`.
- The default is `'stdout'`
+ `input` - When creating temporary files with `%t` or piping
+ text into a command `input` can be set to a |List| of
+ text to use instead of the buffer's text.
- `executable` - An executable for formatting into `%e` in the command.
- If this option is not provided, formatting commands with
- `%e` will not work.
+ `filename_mappings` - A |List| of two-item |List|s describing filename
+ mappings to apply for formatted filenames in the
+ command string, as per |g:ale_filename_mappings|.
- `read_buffer` - If set to `1`, the buffer will be piped into the
- command.
+ If the call to this function is being used for a
+ linter or fixer, the mappings should be provided with
+ this option, and can be retrieved easily with
+ |ale#GetFilenameMappings()|.
- The default is `0`.
+ The default is `[]`.
- `input` - When creating temporary files with `%t` or piping text
- into a command `input` can be set to a |List| of text to
- use instead of the buffer's text.
ale#command#EscapeCommandPart(command_part) *ale#command#EscapeCommandPart()*