summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorDavid Wood <david@davidtw.co>2019-08-03 12:36:55 +0100
committerDavid Wood <david.wood@codeplay.com>2019-08-26 19:21:07 +0100
commit6aeb46217177924367fe1961a7e615f3e4052298 (patch)
treeee3c629ba15dbe6f50246709e46414e73ceea7df /autoload
parent73812c3e41c1c7fcf1705811f35ac4c9ccec003e (diff)
downloadale-6aeb46217177924367fe1961a7e615f3e4052298.zip
Add nixpkgs-fmt fixer.
This commit adds a fixer for the Nix language, nixpkgs-fmt (https://github.com/nix-community/nixpkgs-fmt).
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/nixpkgsfmt.vim12
2 files changed, 17 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 7a553ccc..131f55e1 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -335,6 +335,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['ada'],
\ 'description': 'Format Ada files with gnatpp.',
\ },
+\ 'nixpkgs-fmt': {
+\ 'function': 'ale#fixers#nixpkgsfmt#Fix',
+\ 'suggested_filetypes': ['nix'],
+\ 'description': 'A formatter for Nix code',
+\ },
\}
" Reset the function registry to the default entries.
diff --git a/autoload/ale/fixers/nixpkgsfmt.vim b/autoload/ale/fixers/nixpkgsfmt.vim
new file mode 100644
index 00000000..403ce798
--- /dev/null
+++ b/autoload/ale/fixers/nixpkgsfmt.vim
@@ -0,0 +1,12 @@
+call ale#Set('nix_nixpkgsfmt_executable', 'nixpkgs-fmt')
+call ale#Set('nix_nixpkgsfmt_options', '')
+
+function! ale#fixers#nixpkgsfmt#Fix(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'nix_nixpkgsfmt_executable')
+ let l:options = ale#Var(a:buffer, 'nix_nixpkgsfmt_options')
+
+ return {
+ \ 'command': ale#Escape(l:executable)
+ \ . (empty(l:options) ? '' : ' ' . l:options),
+ \}
+endfunction