summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorghsang <66662835+ghsang@users.noreply.github.com>2021-07-16 16:20:47 +0900
committerGitHub <noreply@github.com>2021-07-16 16:20:47 +0900
commitd6dbb5398e805466ab30b4e7f1c78d7c4168fcf8 (patch)
tree6720ada3fa39907eaf358594badaf22ad0105f5e /autoload
parentd8f4e8b7081724c0b9ff2491dd68409b3da69b0f (diff)
downloadale-d6dbb5398e805466ab30b4e7f1c78d7c4168fcf8.zip
Add support for `dart format` fixer (#3764)
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/dart_format.vim18
2 files changed, 23 insertions, 0 deletions
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 <gwonhyuksang@gmail.com>
+" 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