From d6dbb5398e805466ab30b4e7f1c78d7c4168fcf8 Mon Sep 17 00:00:00 2001 From: ghsang <66662835+ghsang@users.noreply.github.com> Date: Fri, 16 Jul 2021 16:20:47 +0900 Subject: Add support for `dart format` fixer (#3764) --- autoload/ale/fix/registry.vim | 5 +++++ autoload/ale/fixers/dart_format.vim | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 autoload/ale/fixers/dart_format.vim (limited to 'autoload') diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 45518904..7a4d964e 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -381,6 +381,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['dart'], \ 'description': 'Fix Dart files with dartfmt.', \ }, +\ 'dart-format': { +\ 'function': 'ale#fixers#dart_format#Fix', +\ 'suggested_filetypes': ['dart'], +\ 'description': 'Fix Dart files with dart format.', +\ }, \ 'xmllint': { \ 'function': 'ale#fixers#xmllint#Fix', \ 'suggested_filetypes': ['xml'], diff --git a/autoload/ale/fixers/dart_format.vim b/autoload/ale/fixers/dart_format.vim new file mode 100644 index 00000000..4b8f730b --- /dev/null +++ b/autoload/ale/fixers/dart_format.vim @@ -0,0 +1,18 @@ +" Author: ghsang +" Description: Integration of dart format with ALE. + +call ale#Set('dart_format_executable', 'dart') +call ale#Set('dart_format_options', '') + +function! ale#fixers#dart_format#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'dart_format_executable') + let l:options = ale#Var(a:buffer, 'dart_format_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' format' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction -- cgit v1.2.3