summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorDavid Houston <houstdav000@gmail.com>2021-03-23 20:02:17 -0400
committerGitHub <noreply@github.com>2021-03-24 09:02:17 +0900
commitb1f95dc4fb15efb1d5238845c99548f2906e2ba3 (patch)
tree669b5cba5963b96624628cdc7160b6ba3ef99571 /autoload
parenteb0ebe622102cc6da3d7e943a3b739db7b6ed216 (diff)
downloadale-b1f95dc4fb15efb1d5238845c99548f2906e2ba3.zip
Add nixfmt as a Nix fixer. (#3651)
* Add nixfmt fixer. * Replace manual options pad with ale#Pad()
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/nixfmt.vim15
2 files changed, 20 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 7ef502c8..632bc890 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -406,6 +406,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['ada'],
\ 'description': 'Format Ada files with gnatpp.',
\ },
+\ 'nixfmt': {
+\ 'function': 'ale#fixers#nixfmt#Fix',
+\ 'suggested_filetypes': ['nix'],
+\ 'description': 'A nix formatter written in Haskell.',
+\ },
\ 'nixpkgs-fmt': {
\ 'function': 'ale#fixers#nixpkgsfmt#Fix',
\ 'suggested_filetypes': ['nix'],
diff --git a/autoload/ale/fixers/nixfmt.vim b/autoload/ale/fixers/nixfmt.vim
new file mode 100644
index 00000000..4a548b23
--- /dev/null
+++ b/autoload/ale/fixers/nixfmt.vim
@@ -0,0 +1,15 @@
+scriptencoding utf-8
+" Author: houstdav000 <houstdav000@gh0st.sh>
+" Description: Fix files with nixfmt
+
+call ale#Set('nix_nixfmt_executable', 'nixfmt')
+call ale#Set('nix_nixfmt_options', '')
+
+function! ale#fixers#nixfmt#Fix(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'nix_nixfmt_executable')
+ let l:options = ale#Var(a:buffer, 'nix_nixfmt_options')
+
+ return {
+ \ 'command': ale#Escape(l:executable) . ale#Pad(l:options),
+ \}
+endfunction