2017-05-18 22:50:06 +00:00
|
|
|
" Author: w0rp <devw0rp@gmail.com>
|
|
|
|
" Description: A registry of functions for fixing things.
|
|
|
|
|
|
|
|
let s:default_registry = {
|
2017-05-22 11:59:40 +00:00
|
|
|
\ 'add_blank_lines_for_python_control_statements': {
|
2017-06-07 13:02:29 +00:00
|
|
|
\ 'function': 'ale#fixers#generic_python#AddLinesBeforeControlStatements',
|
2017-05-22 11:59:40 +00:00
|
|
|
\ 'suggested_filetypes': ['python'],
|
|
|
|
\ 'description': 'Add blank lines before control statements.',
|
|
|
|
\ },
|
2017-07-03 15:51:34 +00:00
|
|
|
\ 'align_help_tags': {
|
|
|
|
\ 'function': 'ale#fixers#help#AlignTags',
|
|
|
|
\ 'suggested_filetypes': ['help'],
|
|
|
|
\ 'description': 'Align help tags to the right margin',
|
|
|
|
\ },
|
2017-05-19 14:24:41 +00:00
|
|
|
\ 'autopep8': {
|
2017-06-07 13:02:29 +00:00
|
|
|
\ 'function': 'ale#fixers#autopep8#Fix',
|
2017-05-19 14:24:41 +00:00
|
|
|
\ 'suggested_filetypes': ['python'],
|
|
|
|
\ 'description': 'Fix PEP8 issues with autopep8.',
|
|
|
|
\ },
|
2018-11-07 08:33:14 +00:00
|
|
|
\ 'bibclean': {
|
|
|
|
\ 'function': 'ale#fixers#bibclean#Fix',
|
|
|
|
\ 'suggested_filetypes': ['bib'],
|
|
|
|
\ 'description': 'Format bib files using bibclean.',
|
|
|
|
\ },
|
2018-04-06 09:08:25 +00:00
|
|
|
\ 'black': {
|
|
|
|
\ 'function': 'ale#fixers#black#Fix',
|
|
|
|
\ 'suggested_filetypes': ['python'],
|
|
|
|
\ 'description': 'Fix PEP8 issues with black.',
|
|
|
|
\ },
|
2019-09-10 19:54:14 +00:00
|
|
|
\ 'dfmt': {
|
|
|
|
\ 'function': 'ale#fixers#dfmt#Fix',
|
|
|
|
\ 'suggested_filetypes': ['d'],
|
|
|
|
\ 'description': 'Fix D files with dfmt.',
|
|
|
|
\ },
|
2019-03-26 12:40:51 +00:00
|
|
|
\ 'fecs': {
|
|
|
|
\ 'function': 'ale#fixers#fecs#Fix',
|
|
|
|
\ 'suggested_filetypes': ['javascript', 'css', 'html'],
|
|
|
|
\ 'description': 'Apply fecs format to a file.',
|
|
|
|
\ },
|
2018-06-23 10:10:28 +00:00
|
|
|
\ 'tidy': {
|
|
|
|
\ 'function': 'ale#fixers#tidy#Fix',
|
|
|
|
\ 'suggested_filetypes': ['html'],
|
|
|
|
\ 'description': 'Fix HTML files with tidy.',
|
|
|
|
\ },
|
2017-06-28 15:35:19 +00:00
|
|
|
\ 'prettier_standard': {
|
|
|
|
\ 'function': 'ale#fixers#prettier_standard#Fix',
|
|
|
|
\ 'suggested_filetypes': ['javascript'],
|
|
|
|
\ 'description': 'Apply prettier-standard to a file.',
|
2017-11-22 15:31:39 +00:00
|
|
|
\ 'aliases': ['prettier-standard'],
|
2017-06-28 15:35:19 +00:00
|
|
|
\ },
|
2018-03-04 16:11:10 +00:00
|
|
|
\ 'elm-format': {
|
|
|
|
\ 'function': 'ale#fixers#elm_format#Fix',
|
|
|
|
\ 'suggested_filetypes': ['elm'],
|
|
|
|
\ 'description': 'Apply elm-format to a file.',
|
|
|
|
\ 'aliases': ['format'],
|
|
|
|
\ },
|
2019-11-09 08:34:15 +00:00
|
|
|
\ 'nimpretty': {
|
|
|
|
\ 'function': 'ale#fixers#nimpretty#Fix',
|
|
|
|
\ 'suggested_filetypes': ['nim'],
|
|
|
|
\ 'description': 'Apply nimpretty to a file.',
|
|
|
|
\ },
|
2017-05-18 22:50:06 +00:00
|
|
|
\ 'eslint': {
|
2017-06-07 13:02:29 +00:00
|
|
|
\ 'function': 'ale#fixers#eslint#Fix',
|
2017-06-20 09:50:38 +00:00
|
|
|
\ 'suggested_filetypes': ['javascript', 'typescript'],
|
2017-05-19 14:24:41 +00:00
|
|
|
\ 'description': 'Apply eslint --fix to a file.',
|
|
|
|
\ },
|
2017-10-20 21:13:25 +00:00
|
|
|
\ 'mix_format': {
|
|
|
|
\ 'function': 'ale#fixers#mix_format#Fix',
|
|
|
|
\ 'suggested_filetypes': ['elixir'],
|
|
|
|
\ 'description': 'Apply mix format to a file.',
|
|
|
|
\ },
|
2017-05-19 14:24:41 +00:00
|
|
|
\ 'isort': {
|
2017-06-07 13:02:29 +00:00
|
|
|
\ 'function': 'ale#fixers#isort#Fix',
|
2017-05-19 14:24:41 +00:00
|
|
|
\ 'suggested_filetypes': ['python'],
|
|
|
|
\ 'description': 'Sort Python imports with isort.',
|
|
|
|
\ },
|
2017-05-27 17:31:52 +00:00
|
|
|
\ 'prettier': {
|
2017-06-07 13:02:29 +00:00
|
|
|
\ 'function': 'ale#fixers#prettier#Fix',
|
2018-11-12 07:13:08 +00:00
|
|
|
\ 'suggested_filetypes': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'json5', 'graphql', 'markdown', 'vue', 'html', 'yaml'],
|
2017-05-27 17:31:52 +00:00
|
|
|
\ 'description': 'Apply prettier to a file.',
|
|
|
|
\ },
|
|
|
|
\ 'prettier_eslint': {
|
2017-06-07 13:02:29 +00:00
|
|
|
\ 'function': 'ale#fixers#prettier_eslint#Fix',
|
2017-05-27 17:31:52 +00:00
|
|
|
\ 'suggested_filetypes': ['javascript'],
|
|
|
|
\ 'description': 'Apply prettier-eslint to a file.',
|
2017-11-22 15:31:39 +00:00
|
|
|
\ 'aliases': ['prettier-eslint'],
|
2017-05-27 17:31:52 +00:00
|
|
|
\ },
|
2017-12-04 15:29:44 +00:00
|
|
|
\ 'importjs': {
|
|
|
|
\ 'function': 'ale#fixers#importjs#Fix',
|
|
|
|
\ 'suggested_filetypes': ['javascript'],
|
|
|
|
\ 'description': 'automatic imports for javascript',
|
|
|
|
\ },
|
2017-06-28 14:27:02 +00:00
|
|
|
\ 'puppetlint': {
|
|
|
|
\ 'function': 'ale#fixers#puppetlint#Fix',
|
|
|
|
\ 'suggested_filetypes': ['puppet'],
|
|
|
|
\ 'description': 'Run puppet-lint -f on a file.',
|
|
|
|
\ },
|
2017-05-19 14:24:41 +00:00
|
|
|
\ 'remove_trailing_lines': {
|
2017-06-07 13:02:29 +00:00
|
|
|
\ 'function': 'ale#fixers#generic#RemoveTrailingBlankLines',
|
2017-05-19 14:24:41 +00:00
|
|
|
\ 'suggested_filetypes': [],
|
|
|
|
\ 'description': 'Remove all blank lines at the end of a file.',
|
|
|
|
\ },
|
2017-10-12 08:27:24 +00:00
|
|
|
\ 'trim_whitespace': {
|
|
|
|
\ 'function': 'ale#fixers#generic#TrimWhitespace',
|
|
|
|
\ 'suggested_filetypes': [],
|
|
|
|
\ 'description': 'Remove all trailing whitespace characters at the end of every line.',
|
|
|
|
\ },
|
2017-05-19 14:24:41 +00:00
|
|
|
\ 'yapf': {
|
2017-06-07 13:02:29 +00:00
|
|
|
\ 'function': 'ale#fixers#yapf#Fix',
|
2017-05-19 14:24:41 +00:00
|
|
|
\ 'suggested_filetypes': ['python'],
|
|
|
|
\ 'description': 'Fix Python files with yapf.',
|
2017-05-18 22:50:06 +00:00
|
|
|
\ },
|
2017-06-25 19:04:14 +00:00
|
|
|
\ 'rubocop': {
|
|
|
|
\ 'function': 'ale#fixers#rubocop#Fix',
|
|
|
|
\ 'suggested_filetypes': ['ruby'],
|
|
|
|
\ 'description': 'Fix ruby files with rubocop --auto-correct.',
|
|
|
|
\ },
|
2018-03-11 04:33:57 +00:00
|
|
|
\ 'rufo': {
|
|
|
|
\ 'function': 'ale#fixers#rufo#Fix',
|
|
|
|
\ 'suggested_filetypes': ['ruby'],
|
|
|
|
\ 'description': 'Fix ruby files with rufo',
|
|
|
|
\ },
|
2018-06-02 18:59:53 +00:00
|
|
|
\ 'scalafmt': {
|
|
|
|
\ 'function': 'ale#fixers#scalafmt#Fix',
|
|
|
|
\ 'suggested_filetypes': ['scala'],
|
|
|
|
\ 'description': 'Fix Scala files using scalafmt',
|
|
|
|
\ },
|
2019-07-13 16:37:48 +00:00
|
|
|
\ 'sorbet': {
|
|
|
|
\ 'function': 'ale#fixers#sorbet#Fix',
|
|
|
|
\ 'suggested_filetypes': ['ruby'],
|
|
|
|
\ 'description': 'Fix ruby files with srb tc --autocorrect.',
|
|
|
|
\ },
|
2017-07-19 20:50:33 +00:00
|
|
|
\ 'standard': {
|
|
|
|
\ 'function': 'ale#fixers#standard#Fix',
|
|
|
|
\ 'suggested_filetypes': ['javascript'],
|
|
|
|
\ 'description': 'Fix JavaScript files using standard --fix',
|
|
|
|
\ },
|
2018-12-10 21:02:32 +00:00
|
|
|
\ 'standardrb': {
|
|
|
|
\ 'function': 'ale#fixers#standardrb#Fix',
|
|
|
|
\ 'suggested_filetypes': ['ruby'],
|
|
|
|
\ 'description': 'Fix ruby files with standardrb --fix',
|
|
|
|
\ },
|
2017-07-31 00:51:08 +00:00
|
|
|
\ 'stylelint': {
|
|
|
|
\ 'function': 'ale#fixers#stylelint#Fix',
|
2019-01-27 11:42:11 +00:00
|
|
|
\ 'suggested_filetypes': ['css', 'sass', 'scss', 'sugarss', 'stylus'],
|
2017-07-31 00:51:08 +00:00
|
|
|
\ 'description': 'Fix stylesheet files using stylelint --fix.',
|
|
|
|
\ },
|
2017-08-09 17:26:38 +00:00
|
|
|
\ 'swiftformat': {
|
|
|
|
\ 'function': 'ale#fixers#swiftformat#Fix',
|
|
|
|
\ 'suggested_filetypes': ['swift'],
|
|
|
|
\ 'description': 'Apply SwiftFormat to a file.',
|
|
|
|
\ },
|
2017-08-20 05:47:21 +00:00
|
|
|
\ 'phpcbf': {
|
|
|
|
\ 'function': 'ale#fixers#phpcbf#Fix',
|
|
|
|
\ 'suggested_filetypes': ['php'],
|
|
|
|
\ 'description': 'Fix PHP files with phpcbf.',
|
|
|
|
\ },
|
2018-03-01 14:41:05 +00:00
|
|
|
\ 'php_cs_fixer': {
|
|
|
|
\ 'function': 'ale#fixers#php_cs_fixer#Fix',
|
|
|
|
\ 'suggested_filetypes': ['php'],
|
|
|
|
\ 'description': 'Fix PHP files with php-cs-fixer.',
|
|
|
|
\ },
|
2020-07-10 21:47:01 +00:00
|
|
|
\ 'astyle': {
|
|
|
|
\ 'function': 'ale#fixers#astyle#Fix',
|
2020-07-10 23:06:22 +00:00
|
|
|
\ 'suggested_filetypes': ['c'],
|
|
|
|
\ 'description': 'Fix C with astyle.',
|
2020-07-10 21:47:01 +00:00
|
|
|
\ },
|
2019-07-02 07:11:10 +00:00
|
|
|
\ 'clangtidy': {
|
|
|
|
\ 'function': 'ale#fixers#clangtidy#Fix',
|
|
|
|
\ 'suggested_filetypes': ['c', 'cpp', 'objc'],
|
|
|
|
\ 'description': 'Fix C/C++ and ObjectiveC files with clang-tidy.',
|
|
|
|
\ },
|
2017-08-24 21:49:43 +00:00
|
|
|
\ 'clang-format': {
|
|
|
|
\ 'function': 'ale#fixers#clangformat#Fix',
|
2019-03-03 04:39:44 +00:00
|
|
|
\ 'suggested_filetypes': ['c', 'cpp', 'cuda'],
|
|
|
|
\ 'description': 'Fix C/C++ and cuda files with clang-format.',
|
2017-08-24 21:49:43 +00:00
|
|
|
\ },
|
2019-01-27 11:45:57 +00:00
|
|
|
\ 'cmakeformat': {
|
|
|
|
\ 'function': 'ale#fixers#cmakeformat#Fix',
|
|
|
|
\ 'suggested_filetypes': ['cmake'],
|
|
|
|
\ 'description': 'Fix CMake files with cmake-format.',
|
|
|
|
\ },
|
2017-10-03 17:54:35 +00:00
|
|
|
\ 'gofmt': {
|
|
|
|
\ 'function': 'ale#fixers#gofmt#Fix',
|
|
|
|
\ 'suggested_filetypes': ['go'],
|
|
|
|
\ 'description': 'Fix Go files with go fmt.',
|
|
|
|
\ },
|
2017-11-14 17:37:22 +00:00
|
|
|
\ 'goimports': {
|
|
|
|
\ 'function': 'ale#fixers#goimports#Fix',
|
|
|
|
\ 'suggested_filetypes': ['go'],
|
2017-11-15 00:40:40 +00:00
|
|
|
\ 'description': 'Fix Go files imports with goimports.',
|
2017-11-14 17:37:22 +00:00
|
|
|
\ },
|
2018-09-19 18:33:23 +00:00
|
|
|
\ 'gomod': {
|
|
|
|
\ 'function': 'ale#fixers#gomod#Fix',
|
|
|
|
\ 'suggested_filetypes': ['gomod'],
|
|
|
|
\ 'description': 'Fix Go module files with go mod edit -fmt.',
|
|
|
|
\ },
|
2017-10-16 04:53:17 +00:00
|
|
|
\ 'tslint': {
|
|
|
|
\ 'function': 'ale#fixers#tslint#Fix',
|
|
|
|
\ 'suggested_filetypes': ['typescript'],
|
|
|
|
\ 'description': 'Fix typescript files with tslint --fix.',
|
|
|
|
\ },
|
2017-10-21 17:31:49 +00:00
|
|
|
\ 'rustfmt': {
|
|
|
|
\ 'function': 'ale#fixers#rustfmt#Fix',
|
|
|
|
\ 'suggested_filetypes': ['rust'],
|
|
|
|
\ 'description': 'Fix Rust files with Rustfmt.',
|
|
|
|
\ },
|
2019-01-10 18:53:45 +00:00
|
|
|
\ 'textlint': {
|
|
|
|
\ 'function': 'ale#fixers#textlint#Fix',
|
2019-01-27 12:14:34 +00:00
|
|
|
\ 'suggested_filetypes': ['text','markdown','asciidoc','tex'],
|
2019-01-10 18:53:45 +00:00
|
|
|
\ 'description': 'Fix text files with textlint --fix',
|
|
|
|
\ },
|
2017-10-26 23:11:02 +00:00
|
|
|
\ 'hackfmt': {
|
|
|
|
\ 'function': 'ale#fixers#hackfmt#Fix',
|
2018-08-02 16:57:40 +00:00
|
|
|
\ 'suggested_filetypes': ['hack'],
|
2017-10-26 23:11:02 +00:00
|
|
|
\ 'description': 'Fix Hack files with hackfmt.',
|
|
|
|
\ },
|
2019-04-14 16:18:50 +00:00
|
|
|
\ 'floskell': {
|
|
|
|
\ 'function': 'ale#fixers#floskell#Fix',
|
|
|
|
\ 'suggested_filetypes': ['haskell'],
|
|
|
|
\ 'description': 'Fix Haskell files with floskell.',
|
|
|
|
\ },
|
2017-10-24 21:29:04 +00:00
|
|
|
\ 'hfmt': {
|
|
|
|
\ 'function': 'ale#fixers#hfmt#Fix',
|
|
|
|
\ 'suggested_filetypes': ['haskell'],
|
|
|
|
\ 'description': 'Fix Haskell files with hfmt.',
|
|
|
|
\ },
|
2017-11-28 22:58:13 +00:00
|
|
|
\ 'brittany': {
|
|
|
|
\ 'function': 'ale#fixers#brittany#Fix',
|
|
|
|
\ 'suggested_filetypes': ['haskell'],
|
|
|
|
\ 'description': 'Fix Haskell files with brittany.',
|
|
|
|
\ },
|
2019-08-18 17:28:58 +00:00
|
|
|
\ 'hindent': {
|
|
|
|
\ 'function': 'ale#fixers#hindent#Fix',
|
|
|
|
\ 'suggested_filetypes': ['haskell'],
|
|
|
|
\ 'description': 'Fix Haskell files with hindent.',
|
|
|
|
\ },
|
2018-08-23 22:23:54 +00:00
|
|
|
\ 'hlint': {
|
|
|
|
\ 'function': 'ale#fixers#hlint#Fix',
|
|
|
|
\ 'suggested_filetypes': ['haskell'],
|
|
|
|
\ 'description': 'Refactor Haskell files with hlint.',
|
|
|
|
\ },
|
2018-08-23 22:14:59 +00:00
|
|
|
\ 'stylish-haskell': {
|
|
|
|
\ 'function': 'ale#fixers#stylish_haskell#Fix',
|
|
|
|
\ 'suggested_filetypes': ['haskell'],
|
|
|
|
\ 'description': 'Refactor Haskell files with stylish-haskell.',
|
|
|
|
\ },
|
2019-08-12 15:49:19 +00:00
|
|
|
\ 'purty': {
|
|
|
|
\ 'function': 'ale#fixers#purty#Fix',
|
|
|
|
\ 'suggested_filetypes': ['purescript'],
|
|
|
|
\ 'description': 'Format PureScript files with purty.',
|
|
|
|
\ },
|
2018-08-26 11:47:56 +00:00
|
|
|
\ 'ocamlformat': {
|
|
|
|
\ 'function': 'ale#fixers#ocamlformat#Fix',
|
|
|
|
\ 'suggested_filetypes': ['ocaml'],
|
|
|
|
\ 'description': 'Fix OCaml files with ocamlformat.',
|
|
|
|
\ },
|
2019-05-07 17:50:26 +00:00
|
|
|
\ 'ocp-indent': {
|
|
|
|
\ 'function': 'ale#fixers#ocp_indent#Fix',
|
|
|
|
\ 'suggested_filetypes': ['ocaml'],
|
|
|
|
\ 'description': 'Fix OCaml files with ocp-indent.',
|
|
|
|
\ },
|
2017-10-29 15:27:52 +00:00
|
|
|
\ 'refmt': {
|
|
|
|
\ 'function': 'ale#fixers#refmt#Fix',
|
|
|
|
\ 'suggested_filetypes': ['reason'],
|
|
|
|
\ 'description': 'Fix ReasonML files with refmt.',
|
|
|
|
\ },
|
2017-11-05 21:24:41 +00:00
|
|
|
\ 'shfmt': {
|
|
|
|
\ 'function': 'ale#fixers#shfmt#Fix',
|
|
|
|
\ 'suggested_filetypes': ['sh'],
|
|
|
|
\ 'description': 'Fix sh files with shfmt.',
|
|
|
|
\ },
|
2018-09-07 22:55:26 +00:00
|
|
|
\ 'sqlfmt': {
|
|
|
|
\ 'function': 'ale#fixers#sqlfmt#Fix',
|
|
|
|
\ 'suggested_filetypes': ['sql'],
|
|
|
|
\ 'description': 'Fix SQL files with sqlfmt.',
|
|
|
|
\ },
|
2019-09-12 21:48:27 +00:00
|
|
|
\ 'sqlformat': {
|
|
|
|
\ 'function': 'ale#fixers#sqlformat#Fix',
|
|
|
|
\ 'suggested_filetypes': ['sql'],
|
|
|
|
\ 'description': 'Fix SQL files with sqlformat.',
|
|
|
|
\ },
|
2017-12-09 13:52:15 +00:00
|
|
|
\ 'google_java_format': {
|
|
|
|
\ 'function': 'ale#fixers#google_java_format#Fix',
|
|
|
|
\ 'suggested_filetypes': ['java'],
|
|
|
|
\ 'description': 'Fix Java files with google-java-format.',
|
|
|
|
\ },
|
2018-01-24 10:36:02 +00:00
|
|
|
\ 'fixjson': {
|
|
|
|
\ 'function': 'ale#fixers#fixjson#Fix',
|
|
|
|
\ 'suggested_filetypes': ['json'],
|
|
|
|
\ 'description': 'Fix JSON files with fixjson.',
|
|
|
|
\ },
|
2018-01-24 10:12:29 +00:00
|
|
|
\ 'jq': {
|
|
|
|
\ 'function': 'ale#fixers#jq#Fix',
|
|
|
|
\ 'suggested_filetypes': ['json'],
|
|
|
|
\ 'description': 'Fix JSON files with jq.',
|
|
|
|
\ },
|
2018-04-21 13:09:38 +00:00
|
|
|
\ 'perltidy': {
|
|
|
|
\ 'function': 'ale#fixers#perltidy#Fix',
|
|
|
|
\ 'suggested_filetypes': ['perl'],
|
|
|
|
\ 'description': 'Fix Perl files with perltidy.',
|
|
|
|
\ },
|
2018-05-02 22:26:46 +00:00
|
|
|
\ 'xo': {
|
|
|
|
\ 'function': 'ale#fixers#xo#Fix',
|
2019-05-02 10:59:18 +00:00
|
|
|
\ 'suggested_filetypes': ['javascript', 'typescript'],
|
|
|
|
\ 'description': 'Fix JavaScript/TypeScript files using xo --fix.',
|
2018-05-02 22:26:46 +00:00
|
|
|
\ },
|
2018-06-12 18:38:16 +00:00
|
|
|
\ 'qmlfmt': {
|
|
|
|
\ 'function': 'ale#fixers#qmlfmt#Fix',
|
|
|
|
\ 'suggested_filetypes': ['qml'],
|
|
|
|
\ 'description': 'Fix QML files with qmlfmt.',
|
|
|
|
\ },
|
2018-07-01 12:55:41 +00:00
|
|
|
\ 'dartfmt': {
|
|
|
|
\ 'function': 'ale#fixers#dartfmt#Fix',
|
|
|
|
\ 'suggested_filetypes': ['dart'],
|
|
|
|
\ 'description': 'Fix Dart files with dartfmt.',
|
|
|
|
\ },
|
2018-08-28 02:28:43 +00:00
|
|
|
\ 'xmllint': {
|
|
|
|
\ 'function': 'ale#fixers#xmllint#Fix',
|
|
|
|
\ 'suggested_filetypes': ['xml'],
|
|
|
|
\ 'description': 'Fix XML files with xmllint.',
|
|
|
|
\ },
|
2018-09-05 00:39:32 +00:00
|
|
|
\ 'uncrustify': {
|
|
|
|
\ 'function': 'ale#fixers#uncrustify#Fix',
|
|
|
|
\ 'suggested_filetypes': ['c', 'cpp', 'cs', 'objc', 'objcpp', 'd', 'java', 'p', 'vala' ],
|
|
|
|
\ 'description': 'Fix C, C++, C#, ObjectiveC, ObjectiveC++, D, Java, Pawn, and VALA files with uncrustify.',
|
|
|
|
\ },
|
2018-10-24 00:44:31 +00:00
|
|
|
\ 'terraform': {
|
|
|
|
\ 'function': 'ale#fixers#terraform#Fix',
|
|
|
|
\ 'suggested_filetypes': ['hcl', 'terraform'],
|
|
|
|
\ 'description': 'Fix tf and hcl files with terraform fmt.',
|
|
|
|
\ },
|
2019-01-19 07:39:06 +00:00
|
|
|
\ 'ktlint': {
|
|
|
|
\ 'function': 'ale#fixers#ktlint#Fix',
|
|
|
|
\ 'suggested_filetypes': ['kt'],
|
|
|
|
\ 'description': 'Fix Kotlin files with ktlint.',
|
|
|
|
\ },
|
2019-04-23 18:44:26 +00:00
|
|
|
\ 'styler': {
|
|
|
|
\ 'function': 'ale#fixers#styler#Fix',
|
2019-09-14 14:55:04 +00:00
|
|
|
\ 'suggested_filetypes': ['r', 'rmarkdown', 'rmd'],
|
2019-04-23 18:44:26 +00:00
|
|
|
\ 'description': 'Fix R files with styler.',
|
|
|
|
\ },
|
2019-04-13 12:21:59 +00:00
|
|
|
\ 'latexindent': {
|
|
|
|
\ 'function': 'ale#fixers#latexindent#Fix',
|
|
|
|
\ 'suggested_filetypes': ['tex'],
|
|
|
|
\ 'description' : 'Indent code within environments, commands, after headings and within special code blocks.',
|
|
|
|
\ },
|
2019-05-27 04:30:11 +00:00
|
|
|
\ 'pgformatter': {
|
|
|
|
\ 'function': 'ale#fixers#pgformatter#Fix',
|
|
|
|
\ 'suggested_filetypes': ['sql'],
|
|
|
|
\ 'description': 'A PostgreSQL SQL syntax beautifier',
|
|
|
|
\ },
|
2019-06-06 03:18:33 +00:00
|
|
|
\ 'reorder-python-imports': {
|
|
|
|
\ 'function': 'ale#fixers#reorder_python_imports#Fix',
|
|
|
|
\ 'suggested_filetypes': ['python'],
|
|
|
|
\ 'description': 'Sort Python imports with reorder-python-imports.',
|
|
|
|
\ },
|
2019-07-02 00:49:12 +00:00
|
|
|
\ 'gnatpp': {
|
|
|
|
\ 'function': 'ale#fixers#gnatpp#Fix',
|
|
|
|
\ 'suggested_filetypes': ['ada'],
|
|
|
|
\ 'description': 'Format Ada files with gnatpp.',
|
|
|
|
\ },
|
2019-08-03 11:36:55 +00:00
|
|
|
\ 'nixpkgs-fmt': {
|
|
|
|
\ 'function': 'ale#fixers#nixpkgsfmt#Fix',
|
|
|
|
\ 'suggested_filetypes': ['nix'],
|
|
|
|
\ 'description': 'A formatter for Nix code',
|
|
|
|
\ },
|
2019-10-28 13:25:36 +00:00
|
|
|
\ 'html-beautify': {
|
|
|
|
\ 'function': 'ale#fixers#html_beautify#Fix',
|
|
|
|
\ 'suggested_filetypes': ['html', 'htmldjango'],
|
|
|
|
\ 'description': 'Fix HTML files with html-beautify.',
|
|
|
|
\ },
|
2017-05-18 22:50:06 +00:00
|
|
|
\}
|
|
|
|
|
|
|
|
" Reset the function registry to the default entries.
|
|
|
|
function! ale#fix#registry#ResetToDefaults() abort
|
|
|
|
let s:entries = deepcopy(s:default_registry)
|
2017-11-22 15:31:39 +00:00
|
|
|
let s:aliases = {}
|
|
|
|
|
|
|
|
" Set up aliases for fixers too.
|
|
|
|
for [l:key, l:entry] in items(s:entries)
|
|
|
|
for l:alias in get(l:entry, 'aliases', [])
|
|
|
|
let s:aliases[l:alias] = l:key
|
|
|
|
endfor
|
|
|
|
endfor
|
2017-05-18 22:50:06 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
" Set up entries now.
|
|
|
|
call ale#fix#registry#ResetToDefaults()
|
|
|
|
|
2017-05-20 17:56:44 +00:00
|
|
|
" Remove everything from the registry, useful for tests.
|
|
|
|
function! ale#fix#registry#Clear() abort
|
|
|
|
let s:entries = {}
|
2017-11-22 15:31:39 +00:00
|
|
|
let s:aliases = {}
|
2017-05-20 17:56:44 +00:00
|
|
|
endfunction
|
|
|
|
|
2017-05-18 22:50:06 +00:00
|
|
|
" Add a function for fixing problems to the registry.
|
2017-11-22 15:31:39 +00:00
|
|
|
" (name, func, filetypes, desc, aliases)
|
|
|
|
function! ale#fix#registry#Add(name, func, filetypes, desc, ...) abort
|
2018-07-17 20:39:50 +00:00
|
|
|
" This command will throw from the sandbox.
|
2018-08-17 09:10:49 +00:00
|
|
|
let &l:equalprg=&l:equalprg
|
2018-07-17 20:39:50 +00:00
|
|
|
|
2018-07-25 00:27:28 +00:00
|
|
|
if type(a:name) isnot v:t_string
|
2017-05-18 22:50:06 +00:00
|
|
|
throw '''name'' must be a String'
|
|
|
|
endif
|
|
|
|
|
2018-07-25 00:27:28 +00:00
|
|
|
if type(a:func) isnot v:t_string
|
2017-05-18 22:50:06 +00:00
|
|
|
throw '''func'' must be a String'
|
|
|
|
endif
|
|
|
|
|
2018-07-25 00:27:28 +00:00
|
|
|
if type(a:filetypes) isnot v:t_list
|
2017-05-18 22:50:06 +00:00
|
|
|
throw '''filetypes'' must be a List'
|
|
|
|
endif
|
|
|
|
|
|
|
|
for l:type in a:filetypes
|
2018-07-25 00:27:28 +00:00
|
|
|
if type(l:type) isnot v:t_string
|
2017-05-18 22:50:06 +00:00
|
|
|
throw 'Each entry of ''filetypes'' must be a String'
|
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
|
2018-07-25 00:27:28 +00:00
|
|
|
if type(a:desc) isnot v:t_string
|
2017-05-18 22:50:06 +00:00
|
|
|
throw '''desc'' must be a String'
|
|
|
|
endif
|
|
|
|
|
2017-11-22 15:31:39 +00:00
|
|
|
let l:aliases = get(a:000, 0, [])
|
|
|
|
|
2018-07-25 00:27:28 +00:00
|
|
|
if type(l:aliases) isnot v:t_list
|
|
|
|
\|| !empty(filter(copy(l:aliases), 'type(v:val) isnot v:t_string'))
|
2017-11-22 15:31:39 +00:00
|
|
|
throw '''aliases'' must be a List of String values'
|
|
|
|
endif
|
|
|
|
|
2017-05-18 22:50:06 +00:00
|
|
|
let s:entries[a:name] = {
|
|
|
|
\ 'function': a:func,
|
|
|
|
\ 'suggested_filetypes': a:filetypes,
|
|
|
|
\ 'description': a:desc,
|
|
|
|
\}
|
2017-11-22 15:31:39 +00:00
|
|
|
|
|
|
|
" Set up aliases for the fixer.
|
|
|
|
if !empty(l:aliases)
|
|
|
|
let s:entries[a:name].aliases = l:aliases
|
|
|
|
|
|
|
|
for l:alias in l:aliases
|
|
|
|
let s:aliases[l:alias] = a:name
|
|
|
|
endfor
|
|
|
|
endif
|
2017-05-18 22:50:06 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
" Get a function from the registry by its short name.
|
|
|
|
function! ale#fix#registry#GetFunc(name) abort
|
2017-11-22 15:31:39 +00:00
|
|
|
" Use the exact name, or an alias.
|
|
|
|
let l:resolved_name = !has_key(s:entries, a:name)
|
|
|
|
\ ? get(s:aliases, a:name, a:name)
|
|
|
|
\ : a:name
|
|
|
|
|
|
|
|
return get(s:entries, l:resolved_name, {'function': ''}).function
|
2017-05-18 22:50:06 +00:00
|
|
|
endfunction
|
2017-05-20 17:56:44 +00:00
|
|
|
|
|
|
|
function! s:ShouldSuggestForType(suggested_filetypes, type_list) abort
|
|
|
|
for l:type in a:type_list
|
|
|
|
if index(a:suggested_filetypes, l:type) >= 0
|
|
|
|
return 1
|
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
|
|
|
|
return 0
|
|
|
|
endfunction
|
|
|
|
|
2018-04-12 00:23:58 +00:00
|
|
|
function! s:IsGenericFixer(suggested_filetypes) abort
|
|
|
|
if empty(a:suggested_filetypes)
|
|
|
|
return 1
|
|
|
|
endif
|
|
|
|
|
|
|
|
return 0
|
|
|
|
endfunction
|
|
|
|
|
2017-11-22 15:31:39 +00:00
|
|
|
function! s:FormatEntry(key, entry) abort
|
|
|
|
let l:aliases_str = ''
|
|
|
|
|
|
|
|
" Show aliases in :ALEFixSuggest if they are there.
|
|
|
|
if !empty(get(a:entry, 'aliases', []))
|
|
|
|
let l:aliases_str = ', ' . join(
|
|
|
|
\ map(copy(a:entry.aliases), 'string(v:val)'),
|
|
|
|
\ ','
|
|
|
|
\)
|
|
|
|
endif
|
|
|
|
|
|
|
|
return printf(
|
|
|
|
\ '%s%s - %s',
|
|
|
|
\ string(a:key),
|
|
|
|
\ l:aliases_str,
|
|
|
|
\ a:entry.description,
|
|
|
|
\)
|
|
|
|
endfunction
|
|
|
|
|
2018-04-12 00:23:58 +00:00
|
|
|
" Get list of applicable fixers for filetype, including generic fixers
|
|
|
|
function! ale#fix#registry#GetApplicableFixers(filetype) abort
|
|
|
|
let l:type_list = split(a:filetype, '\.')
|
|
|
|
let l:fixer_name_list = []
|
|
|
|
|
|
|
|
for l:key in sort(keys(s:entries))
|
|
|
|
let l:suggested_filetypes = s:entries[l:key].suggested_filetypes
|
|
|
|
|
|
|
|
if s:IsGenericFixer(l:suggested_filetypes) || s:ShouldSuggestForType(l:suggested_filetypes, l:type_list)
|
|
|
|
call add(l:fixer_name_list, l:key)
|
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
|
|
|
|
return l:fixer_name_list
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" Function that returns autocomplete candidates for ALEFix command
|
|
|
|
function! ale#fix#registry#CompleteFixers(ArgLead, CmdLine, CursorPos) abort
|
2018-05-08 05:56:19 +00:00
|
|
|
return filter(ale#fix#registry#GetApplicableFixers(&filetype), 'v:val =~? a:ArgLead')
|
2018-04-12 00:23:58 +00:00
|
|
|
endfunction
|
|
|
|
|
2018-06-21 01:26:41 +00:00
|
|
|
function! ale#fix#registry#SuggestedFixers(filetype) abort
|
2017-05-20 17:56:44 +00:00
|
|
|
let l:type_list = split(a:filetype, '\.')
|
2017-06-28 15:20:01 +00:00
|
|
|
let l:filetype_fixer_list = []
|
2017-05-20 17:56:44 +00:00
|
|
|
|
|
|
|
for l:key in sort(keys(s:entries))
|
|
|
|
let l:suggested_filetypes = s:entries[l:key].suggested_filetypes
|
|
|
|
|
|
|
|
if s:ShouldSuggestForType(l:suggested_filetypes, l:type_list)
|
2017-06-28 15:20:01 +00:00
|
|
|
call add(
|
|
|
|
\ l:filetype_fixer_list,
|
2017-11-22 15:31:39 +00:00
|
|
|
\ s:FormatEntry(l:key, s:entries[l:key]),
|
2017-06-28 15:20:01 +00:00
|
|
|
\)
|
2017-05-20 17:56:44 +00:00
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
|
2017-06-28 15:20:01 +00:00
|
|
|
let l:generic_fixer_list = []
|
2017-05-20 17:56:44 +00:00
|
|
|
|
|
|
|
for l:key in sort(keys(s:entries))
|
2018-04-12 00:23:58 +00:00
|
|
|
if s:IsGenericFixer(s:entries[l:key].suggested_filetypes)
|
2017-06-28 15:20:01 +00:00
|
|
|
call add(
|
|
|
|
\ l:generic_fixer_list,
|
2017-11-22 15:31:39 +00:00
|
|
|
\ s:FormatEntry(l:key, s:entries[l:key]),
|
2017-06-28 15:20:01 +00:00
|
|
|
\)
|
2017-05-20 17:56:44 +00:00
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
|
2018-06-21 01:26:41 +00:00
|
|
|
return [l:filetype_fixer_list, l:generic_fixer_list]
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" Suggest functions to use from the registry.
|
|
|
|
function! ale#fix#registry#Suggest(filetype) abort
|
|
|
|
let l:suggested = ale#fix#registry#SuggestedFixers(a:filetype)
|
|
|
|
let l:filetype_fixer_list = l:suggested[0]
|
|
|
|
let l:generic_fixer_list = l:suggested[1]
|
|
|
|
|
2017-06-28 15:20:01 +00:00
|
|
|
let l:filetype_fixer_header = !empty(l:filetype_fixer_list)
|
|
|
|
\ ? ['Try the following fixers appropriate for the filetype:', '']
|
|
|
|
\ : []
|
|
|
|
let l:generic_fixer_header = !empty(l:generic_fixer_list)
|
|
|
|
\ ? ['Try the following generic fixers:', '']
|
|
|
|
\ : []
|
|
|
|
|
|
|
|
let l:has_both_lists = !empty(l:filetype_fixer_list) && !empty(l:generic_fixer_list)
|
|
|
|
|
|
|
|
let l:lines =
|
|
|
|
\ l:filetype_fixer_header
|
|
|
|
\ + l:filetype_fixer_list
|
|
|
|
\ + (l:has_both_lists ? [''] : [])
|
|
|
|
\ + l:generic_fixer_header
|
|
|
|
\ + l:generic_fixer_list
|
|
|
|
|
|
|
|
if empty(l:lines)
|
|
|
|
let l:lines = ['There is nothing in the registry to suggest.']
|
2017-05-20 17:56:44 +00:00
|
|
|
else
|
2017-06-28 15:20:01 +00:00
|
|
|
let l:lines += ['', 'See :help ale-fix-configuration']
|
2017-05-20 17:56:44 +00:00
|
|
|
endif
|
2017-06-28 15:20:01 +00:00
|
|
|
|
|
|
|
let l:lines += ['', 'Press q to close this window']
|
|
|
|
|
|
|
|
new +set\ filetype=ale-fix-suggest
|
|
|
|
call setline(1, l:lines)
|
|
|
|
setlocal nomodified
|
|
|
|
setlocal nomodifiable
|
2017-05-20 17:56:44 +00:00
|
|
|
endfunction
|