### Example Linter Test Setup Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-development.txt This example demonstrates how to set up a linter test by loading the linter file and resetting linter variables. It includes Vader commands for saving and restoring test states. ```vim " Load the linter and set up a series of commands, reset linter variables, " clear caches, etc. " " Vader's 'Save' command will be called here for linter variables. call ale#assert#SetUpLinterTest('filetype', 'linter_name') ``` ```vim " Reset linters, variables, etc. " " Vader's 'Restore' command will be called here. call ale#assert#TearDownLinterTest() ``` -------------------------------- ### Install ALE with lazy.nvim Source: https://github.com/dense-analysis/ale/blob/master/README.md Configure lazy.nvim to load and set up ALE. Includes example configuration for RuboCop and language servers. ```lua { 'dense-analysis/ale', config = function() -- Configuration goes here. local g = vim.g g.ale_ruby_rubocop_auto_correct_all = 1 g.ale_linters = { ruby = {'rubocop', 'ruby'}, lua = {'lua_language_server'} } end } ``` -------------------------------- ### Install yq Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-yaml.txt Instructions for installing the yq tool. Refer to the official website for detailed steps. ```bash Install yq: > ``` -------------------------------- ### Install cfn-python-lint with setuptools Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-cloudformation.txt Use these commands to install the cfn-python-lint linter if pip is not available, by building from source. ```bash python setup.py clean --all python setup.py install ``` -------------------------------- ### Configure gitlablint installation Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-yaml.txt Instructions for installing gitlab-lint using pip3. It can be installed in a virtual environment, locally, or globally. ```bash pip3 install gitlab_lint # After activating virtualenv ``` ```bash pip3 install --user gitlab_lint # Install to ~/.local/bin ``` ```bash sudo pip3 install gitlab_lint # Install globally ``` -------------------------------- ### Install yaml-language-server Globally Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-yaml.txt Use this command to install the yaml-language-server globally on your system. ```bash npm install yaml-language-server -g # global ``` -------------------------------- ### Install gopls with go get Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-go.txt Install the latest stable version of gopls to your $GOPATH. This command ensures you have the official Go language server available for ALE. ```bash GO111MODULE=on go get golang.org/x/tools/gopls@latest ``` -------------------------------- ### Setup ALE Linters Globally Source: https://github.com/dense-analysis/ale/blob/master/doc/ale.txt Configure linters for specific file types globally. This example sets up flake8 and pylint for Python, then ignores pylint. ```vimscript require("ale").setup({ linters = {"python": {"flake8", "pylint"}}, linters_ignore = {"python": {"pylint"}}, }) ``` -------------------------------- ### Install yamlfmt Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-yaml.txt Instructions for installing the yamlfmt tool. Refer to the official website for detailed steps. ```bash See the website. ``` -------------------------------- ### Install yaml-language-server Locally Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-yaml.txt Use this command to install the yaml-language-server locally within your project. ```bash npm install yaml-language-server # local ``` -------------------------------- ### Install ibm-openapi-validator Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-openapi.txt Install the ibm-openapi-validator package globally or locally using npm. ```bash npm install ibm-openapi-validator -g # global npm install ibm-openapi-validator # local ``` -------------------------------- ### Install Swaglint Globally or Locally Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-yaml.txt Instructions for installing Swaglint, a linter for OpenAPI specifications, either globally or as a local project dependency. ```bash npm install swaglint -g # global npm install swaglint # local ``` -------------------------------- ### Install Prettier Globally or Locally Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-yaml.txt Instructions for installing the Prettier code formatter, which can be used for YAML files. ```bash npm install prettier -g # global npm install prettier # local ``` -------------------------------- ### Handler Test Example Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-development.txt This example demonstrates testing linter output parsing. It shows how to load a linter file and then use AssertEqual to compare the parsed loclist items with the expected output. ```vim " Load the file which defines the linter. runtime ale_linters/filetype/linter_name_here.vim ``` ```vim " Unload all linters again. call ale#linter#Reset() ``` ```vim " Test that the right loclist items are parsed from the handler. AssertEqual \ [ \ { \ 'lnum': 1, \ 'type': 'E', \ 'text': 'Something went wrong', \ }, \ ], \ ale_linters#filetype#linter_name#Handle(bufnr(''), [ \ '1:Something went wrong', \ ] ``` -------------------------------- ### Configure yamllint installation Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-yaml.txt Instructions for installing yamllint using pip. It can be installed in a virtual environment, locally, or globally. ```bash pip install yamllint # After activating virtualenv ``` ```bash pip install --user yamllint # Install to ~/.local/bin ``` ```bash sudo pip install yamllint # Install globally ``` -------------------------------- ### Install TypeScript Source: https://github.com/dense-analysis/ale/wiki/JavaScript-and-TypeScript-integration Install TypeScript in your project using NPM. ALE uses the installed `tsserver` for TypeScript code checking. ```sh npm install typescript ``` -------------------------------- ### Install spectral locally Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-json.txt Install the spectral executable locally using npm. This is an alternative to global installation for ALE integration. ```bash npm install @stoplight/spectral ``` -------------------------------- ### Install cfn-python-lint with pip Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-cloudformation.txt Use this command to install the cfn-python-lint linter using pip. ```bash pip install cfn-lint ``` -------------------------------- ### Initialize help tags for ALE Source: https://github.com/dense-analysis/ale/blob/master/README.md Run this command in Vim to ensure help tags are updated after installation. ```vim packloadall | silent! helptags ALL ``` -------------------------------- ### Install Spectral Globally or Locally Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-yaml.txt Instructions for installing Spectral, a JSON/YAML linter, either globally or as a local project dependency. ```bash npm install @stoplight/spectral -g # global npm install @stoplight/spectral # local ``` -------------------------------- ### Install ALE with Windows packload Source: https://github.com/dense-analysis/ale/blob/master/README.md Manually install ALE using Vim's package loading system on Windows via Git Bash. ```bash # Run these commands in the "Git for Windows" Bash terminal mkdir -p ~/vimfiles/pack/git-plugins/start git clone --depth 1 https://github.com/dense-analysis/ale.git ~/vimfiles/pack/git-plugins/start/ale ``` -------------------------------- ### Check Rust Examples with Cargo Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-rust.txt When set to 1, ALE will include examples in `cargo check` linting. This allows for linting of examples which are normally excluded. ```vim let g:ale_rust_cargo_check_examples = 1 ``` -------------------------------- ### Verilog Linters Command Examples Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-verilog.txt Examples of commands used by ALE for various Verilog/SystemVerilog linters. ```bash hdl_checker --lsp ``` ```bash iverilog -t null -Wall ``` ```bash slang -Weverything ``` ```bash verible-verilog-ls ``` ```bash verilator --lint-only -Wall ``` ```bash vlog -quiet -lint ``` ```bash xvlog ``` ```bash yosys -Q -T -p 'read_verilog' ``` -------------------------------- ### Configure ALE Fixers with a List Source: https://github.com/dense-analysis/ale/blob/master/doc/ale.txt This example demonstrates configuring ALE fixers using a list, which is an alternative to using a dictionary for buffer-local settings. It includes the same fixer actions as the dictionary example. ```vimscript let b:ale_fixers = [ 'DoSomething', 'eslint', {buffer, lines -> filter(lines, 'v:val !=~ ''^ *//''')}, ] ``` -------------------------------- ### Install ALE with Pathogen Source: https://github.com/dense-analysis/ale/blob/master/README.md Clone the ALE repository into your vim bundle directory to install it with Pathogen. ```bash git clone https://github.com/dense-analysis/ale ~/.vim/bundle/ale ``` -------------------------------- ### Install jq globally Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-json.txt Install the jq executable globally using npm. This allows ALE to use jq for JSON processing. ```bash npm install -g jq ``` -------------------------------- ### Install ESLint with NPM Source: https://github.com/dense-analysis/ale/wiki/JavaScript-and-TypeScript-integration Install ESLint as a development dependency in your project using NPM. This command sets up ESLint for use with ALE. ```sh # Install ESLInt with NPM npm install eslint --save-dev # Create an initial configuration file. ./node_modules/.bin/eslint --init ``` -------------------------------- ### Install ALE with Neovim packload Source: https://github.com/dense-analysis/ale/blob/master/README.md Manually install ALE using Neovim's package loading system. ```bash mkdir -p ~/.local/share/nvim/site/pack/git-plugins/start git clone --depth 1 https://github.com/dense-analysis/ale.git ~/.local/share/nvim/site/pack/git-plugins/start/ale ``` -------------------------------- ### Install ALE with Vim packload Source: https://github.com/dense-analysis/ale/blob/master/README.md Manually install ALE using Vim's package loading system. ```bash mkdir -p ~/.vim/pack/git-plugins/start git clone --depth 1 https://github.com/dense-analysis/ale.git ~/.vim/pack/git-plugins/start/ale ``` -------------------------------- ### Install cfn-python-lint with brew Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-cloudformation.txt Use this command to install the cfn-python-lint linter via brew on macOS. ```bash brew install cfn-lint ``` -------------------------------- ### Install jsonlint globally Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-json.txt Install the jsonlint executable globally using npm. This is the default executable ALE will look for. ```bash npm install -g jsonlint ``` -------------------------------- ### Install Vim and Vader.vim on Windows Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-development.txt These PowerShell commands download and install specific versions of Vim and Vader.vim required for running ALE tests in a Windows VM. ```powershell Add-Type -A System.IO.Compression.FileSystem Invoke-WebRequest https://github.com/dense-analysis/ale/releases/download/v4.0.0/vim80-586w32.zip -OutFile C:\vim.zip [IO.Compression.ZipFile]::ExtractToDirectory('C:\vim.zip', 'C:\vim') rm C:\vim.zip Invoke-WebRequest https://github.com/dense-analysis/ale/releases/download/v4.0.0/vim80-586rt.zip -OutFile C:\rt.zip [IO.Compression.ZipFile]::ExtractToDirectory('C:\rt.zip', 'C:\vim') rm C:\rt.zip Invoke-WebRequest https://github.com/junegunn/vader.vim/archive/c6243dd81c98350df4dec608fa972df98fa2a3af.zip -OutFile C:\vader.zip [IO.Compression.ZipFile]::ExtractToDirectory('C:\vader.zip', 'C:\') mv C:\vader.vim-c6243dd81c98350df4dec608fa972df98fa2a3af C:\vader rm C:\vader.zip ``` -------------------------------- ### AssertLinter with Chained Commands Example Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-development.txt This example shows how to test chained commands using AssertLinter. GivenCommandOutput defines the output for the first command, and AssertLinter checks the sequence of commands. ```vim GivenCommandOutput ['v2.1.2'] " Given a List of commands, check all of them. " Given a String, only the last command in the chain will be checked. AssertLinter 'some-command', [ \ ale#Escape('some-command') . ' --version', \ ale#Escape('some-command') . ' --foo', \] ``` -------------------------------- ### ale.setup Source: https://github.com/dense-analysis/ale/blob/master/doc/ale.txt Configures global ALE settings. ```APIDOC ## ale.setup(config) ### Description Configure ALE global settings, which are documented in |ale-options|. For example: ```lua require("ale").setup({ completion_enabled = true, maximum_file_size = 1024 * 1024, warn_about_trailing_whitespace = false, }) ``` You can also call this function with `ale.setup.global` to make what context ALE is being configured in less ambiguous if you like. ``` -------------------------------- ### Configure ALE Globally Source: https://github.com/dense-analysis/ale/blob/master/doc/ale.txt Use the `ale.setup` function in `init.vim` to configure ALE globally. This example enables completion, sets a maximum file size, and disables warnings for trailing whitespace. ```lua require("ale").setup({ completion_enabled = true, maximum_file_size = 1024 * 1024, warn_about_trailing_whitespace = false, }) ``` -------------------------------- ### Configure gopls initialization options Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-go.txt Set LSP initialization options for gopls to customize its behavior. This example enables specific analyses like unused parameters and results, while disabling others. ```vim let g:ale_go_gopls_init_options = { \ 'ui.diagnostic.analyses': { \ 'composites': v:false, \ 'unusedparams': v:true, \ 'unusedresult': v:true, \ }, \ \} ``` -------------------------------- ### Sample .project File Structure Source: https://github.com/dense-analysis/ale/wiki/Eclipse-Java-Language-Server-(jdtls) A sample `.project` file structure for a root project, including build specifications and natures. This can be used as a template for multi-package Java projects. ```xml root_of_project package1 package2 org.eclipse.buildship.core.gradleprojectbuilder org.eclipse.buildship.core.gradleprojectnature ``` -------------------------------- ### ale.setup.buffer Source: https://github.com/dense-analysis/ale/blob/master/doc/ale.txt Configures buffer-local ALE settings. ```APIDOC ## ale.setup.buffer(config) ### Description Configure ALE buffer-local settings, which are documented in |ale-options|. For example: ```lua require("ale").setup.buffer({ linters = {"ruff", "pyright"}, fixers = {"ruff"} }) ``` ``` -------------------------------- ### Configure PureScript Language Server Options Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-purescript.txt Pass configuration settings to the PureScript language server. This example shows how to configure it for a spago project, enabling specific build options. ```vim let g:ale_purescript_ls_config = { \ 'purescript': { \ 'addSpagoSources': v:true, \ 'addNpmPath': v:true, \ 'buildCommand': 'spago --quiet build --purs-args --json-errors', \ }, \} ``` -------------------------------- ### Verilog Fixer Command Example Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-verilog.txt Example of the command used by ALE for the verible_fomat fixer. ```bash verible-verilog-format ``` -------------------------------- ### Configure Refurb Options Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-python.txt Add command-line arguments to the 'refurb' invocation. This allows customization of error code selection and other refurb behaviors. ```vim let g:ale_python_refurb_options = '--ignore 100' ``` -------------------------------- ### Configure C Astyle Project Options Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-c.txt Specify a filename for project-level Astyle configurations. The file is searched in parent directories of the source file. ```vim let g:ale_c_astyle_project_options = '.astylrc' ``` -------------------------------- ### Install ALE with Vundle Source: https://github.com/dense-analysis/ale/blob/master/README.md Add this line to your vimrc file to install ALE using Vundle. ```vim Plugin 'dense-analysis/ale' ``` -------------------------------- ### Install ALE with vim-plug Source: https://github.com/dense-analysis/ale/blob/master/README.md Add this line to your vimrc file to install ALE using vim-plug. ```vim Plug 'dense-analysis/ale' ``` -------------------------------- ### Set Up ALE Fixer Test Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-development.txt Use SetUpFixerTest to load a fixer and prepare for testing. Call TearDownFixerTest to clean up after tests. ```vimscript call ale#assert#SetUpFixerTest('filetype', 'fixer_name') ``` ```vimscript call ale#assert#TearDownFixerTest() ``` -------------------------------- ### Install yamlfix Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-yaml.txt Install the yamlfix tool using pip. This is required for linting and formatting YAML files. ```bash pip install yamlfix ``` -------------------------------- ### Configure ALE Global Settings Source: https://github.com/dense-analysis/ale/blob/master/doc/ale.txt Use this function to configure ALE's global settings. Refer to |ale-options| for available options. This example shows how to enable completion, set a maximum file size, and disable trailing whitespace warnings. ```lua require("ale").setup({ completion_enabled = true, maximum_file_size = 1024 * 1024, warn_about_trailing_whitespace = false, }) ``` -------------------------------- ### Buffer-Local Linters Configuration (Lua) Source: https://github.com/dense-analysis/ale/blob/master/doc/ale.txt Configure buffer-local linters in Lua using require('ale').setup.buffer(). This example shows setting specific linters, a list of linters, disabling all linters, and enabling all linters. ```lua require("ale").setup.buffer({ linters = {javascript = {"eslint"}, html = {"tidy"}}, }) ``` ```lua require("ale").setup.buffer({linters = {"eslint", "tidy"}}) ``` ```lua require("ale").setup.buffer({linters = {}}) ``` ```lua require("ale").setup.buffer({linters = "all"}) ``` -------------------------------- ### Install fixjson Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-json.txt Install the fixjson tool globally using npm. This tool is used for fixing and formatting JSON files. ```bash $ npm install -g fixjson ``` -------------------------------- ### Integrate Custom Checks with ALE Source: https://github.com/dense-analysis/ale/blob/master/doc/ale.txt This example shows how to hook into ALE's event system to perform custom background checks and report results. Ensure `ale#other_source#StartChecking()` is called synchronously and background work is done asynchronously. ```vimscript augroup SomeGroupName autocmd! autocmd User ALEWantResults call Hook(g:ale_want_results_buffer) augroup END function! DoBackgroundWork(buffer) abort " Start some work in the background here. " ... " Then call WorkDone(a:buffer, results) endfunction function! Hook(buffer) abort " Tell ALE we're going to check this buffer. call ale#other_source#StartChecking(a:buffer, 'some-name') call DoBackgroundWork(a:buffer) endfunction function! WorkDone(buffer, results) abort " Send results to ALE after they have been collected. call ale#other_source#ShowResults(a:buffer, 'some-name', a:results) endfunction ``` -------------------------------- ### Install spectral globally Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-json.txt Install the spectral executable globally using npm. This is required for ALE to lint JSON files with spectral. ```bash npm install @stoplight/spectral -g ``` -------------------------------- ### Configure google-java-format Executable Path Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-java.txt Set the path to the google-java-format executable. Ensure the executable is available in your system's PATH or provide the full path. ```vim let g:ale_java_google_java_format_executable = 'google-java-format' ``` -------------------------------- ### Configure ALE Per-Buffer Source: https://github.com/dense-analysis/ale/blob/master/doc/ale.txt Customize ALE behavior for specific filetypes using `ale.setup.buffer` in `ftplugin` files. This example configures linters and fixers for Python files. ```lua -- In ftplugin/python.lua in &runtimepath require("ale").setup.buffer({ linters = {"ruff", "pyright"}, fixers = {"ruff"} }) ``` -------------------------------- ### Customize Phpactor LSP Initialization Options Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-php.txt Customize the LSP initialization_options for phpactor. Visit the official documentation for available options. ```vim let g:ale_php_phpactor_init_options = { \ 'language_server_phpstan.enabled': v:false, \ 'language_server_psalm.enabled': v:false, \ 'worse_reflection.stub_dir': '%application_root%/.php-stubs' \ } ``` -------------------------------- ### ALE Autocommand Events Source: https://github.com/dense-analysis/ale/blob/master/README.md Define custom autocmd events to execute functions when ALE linting or fixing cycles start or stop, or when a linter job starts. ```vim augroup YourGroup autocmd! autocmd User ALELintPre call YourFunction() autocmd User ALELintPost call YourFunction() autocmd User ALEJobStarted call YourFunction() autocmd User ALEFixPre call YourFunction() autocmd User ALEFixPost call YourFunction() augroup END ``` -------------------------------- ### Configure buf-lint Executable and Config Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-proto.txt Set g:ale_proto_buf_lint_executable to change the buf executable used for linting. Set g:ale_proto_buf_lint_config to specify a buf configuration file. ```vim g:ale_proto_buf_lint_executable Type: |String| Default: `'buf'` ``` ```vim g:ale_proto_buf_lint_config Type: |String| Default: `''` ``` -------------------------------- ### Configure PureScript Language Server Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-purescript.txt Set the executable path for the PureScript language server. This is useful if the server is not in your system's PATH. ```vim let g:ale_purescript_ls_executable = '/path/to/purescript-language-server' ``` -------------------------------- ### Install VSCode JSON language server globally Source: https://github.com/dense-analysis/ale/blob/master/doc/ale-json.txt Install the VSCode JSON language server globally using npm. This enables advanced JSON linting and completion features within ALE. ```bash npm install -g vscode-langservers-extracted ``` -------------------------------- ### ale#other_source#StartChecking Source: https://github.com/dense-analysis/ale/blob/master/doc/ale.txt Notifies ALE that an external source has started checking a buffer. ```APIDOC ## ale#other_source#StartChecking(buffer, linter_name) ### Description Notifies ALE that an external source has started checking a buffer. ### Parameters - **buffer** (Integer) - A valid buffer number. - **linter_name** (String) - A unique name to identify the external source. ``` -------------------------------- ### Get Filename Mappings for Buffer Source: https://github.com/dense-analysis/ale/blob/master/doc/ale.txt Retrieves filename mappings for a given buffer and name using `ale.get_filename_mappings`. ```vim ale.get_filename_mappings(buffer, name) ```