Add nixfmt as a Nix fixer. (#3651)

* Add nixfmt fixer.

* Replace manual options pad with ale#Pad()
This commit is contained in:
David Houston
2021-03-23 20:02:17 -04:00
committed by GitHub
parent eb0ebe6221
commit b1f95dc4fb
7 changed files with 65 additions and 0 deletions

View File

@@ -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'],

View File

@@ -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