forked from github-mirrors/ale
Add nixfmt as a Nix fixer. (#3651)
* Add nixfmt fixer. * Replace manual options pad with ale#Pad()
This commit is contained in:
parent
eb0ebe6221
commit
b1f95dc4fb
|
@ -406,6 +406,11 @@ let s:default_registry = {
|
||||||
\ 'suggested_filetypes': ['ada'],
|
\ 'suggested_filetypes': ['ada'],
|
||||||
\ 'description': 'Format Ada files with gnatpp.',
|
\ 'description': 'Format Ada files with gnatpp.',
|
||||||
\ },
|
\ },
|
||||||
|
\ 'nixfmt': {
|
||||||
|
\ 'function': 'ale#fixers#nixfmt#Fix',
|
||||||
|
\ 'suggested_filetypes': ['nix'],
|
||||||
|
\ 'description': 'A nix formatter written in Haskell.',
|
||||||
|
\ },
|
||||||
\ 'nixpkgs-fmt': {
|
\ 'nixpkgs-fmt': {
|
||||||
\ 'function': 'ale#fixers#nixpkgsfmt#Fix',
|
\ 'function': 'ale#fixers#nixpkgsfmt#Fix',
|
||||||
\ 'suggested_filetypes': ['nix'],
|
\ 'suggested_filetypes': ['nix'],
|
||||||
|
|
|
@ -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
|
|
@ -2,6 +2,24 @@
|
||||||
ALE Nix Integration *ale-nix-options*
|
ALE Nix Integration *ale-nix-options*
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
nixfmt *ale-nix-nixfmt*
|
||||||
|
|
||||||
|
g:ale_nix_nixfmt_executable *g:ale_nix_nixfmt_executable*
|
||||||
|
*b:ale_nix_nixfmt_executable*
|
||||||
|
Type: String
|
||||||
|
Default: 'nixfmt'
|
||||||
|
|
||||||
|
This variable sets the executable used for nixfmt.
|
||||||
|
|
||||||
|
g:ale_nix_nixfmt_options *g:ale_nix_nixfmt_options*
|
||||||
|
*b:ale_nix_nixfmt_options*
|
||||||
|
Type: String
|
||||||
|
Default: ''
|
||||||
|
|
||||||
|
This variable can be set to pass additional options to the nixfmt fixer.
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
nixpkgs-fmt *ale-nix-nixpkgs-fmt*
|
nixpkgs-fmt *ale-nix-nixpkgs-fmt*
|
||||||
|
|
||||||
|
|
|
@ -319,6 +319,7 @@ Notes:
|
||||||
* `nimpretty`
|
* `nimpretty`
|
||||||
* nix
|
* nix
|
||||||
* `nix-instantiate`
|
* `nix-instantiate`
|
||||||
|
* `nixfmt`
|
||||||
* `nixpkgs-fmt`
|
* `nixpkgs-fmt`
|
||||||
* `rnix-lsp`
|
* `rnix-lsp`
|
||||||
* nroff
|
* nroff
|
||||||
|
|
|
@ -2859,6 +2859,7 @@ documented in additional help files.
|
||||||
nimlsp................................|ale-nim-nimlsp|
|
nimlsp................................|ale-nim-nimlsp|
|
||||||
nimpretty.............................|ale-nim-nimpretty|
|
nimpretty.............................|ale-nim-nimpretty|
|
||||||
nix.....................................|ale-nix-options|
|
nix.....................................|ale-nix-options|
|
||||||
|
nixfmt................................|ale-nix-nixfmt|
|
||||||
nixpkgs-fmt...........................|ale-nix-nixpkgs-fmt|
|
nixpkgs-fmt...........................|ale-nix-nixpkgs-fmt|
|
||||||
nroff...................................|ale-nroff-options|
|
nroff...................................|ale-nroff-options|
|
||||||
write-good............................|ale-nroff-write-good|
|
write-good............................|ale-nroff-write-good|
|
||||||
|
|
|
@ -328,6 +328,7 @@ formatting.
|
||||||
* nimpretty
|
* nimpretty
|
||||||
* nix
|
* nix
|
||||||
* [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate)
|
* [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate)
|
||||||
|
* [nixfmt](https://github.com/serokell/nixfmt)
|
||||||
* [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt)
|
* [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt)
|
||||||
* [rnix-lsp](https://github.com/nix-community/rnix-lsp)
|
* [rnix-lsp](https://github.com/nix-community/rnix-lsp)
|
||||||
* nroff
|
* nroff
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
Before:
|
||||||
|
Save g:ale_nix_nixfmt_executable
|
||||||
|
Save g:ale_nix_nixfmt_options
|
||||||
|
|
||||||
|
After:
|
||||||
|
Restore
|
||||||
|
|
||||||
|
Execute(The nixfmt callback should return the correct default values):
|
||||||
|
AssertEqual
|
||||||
|
\ {
|
||||||
|
\ 'command': ale#Escape('nixfmt')
|
||||||
|
\ },
|
||||||
|
\ ale#fixers#nixfmt#Fix(bufnr(''))
|
||||||
|
|
||||||
|
Execute(The nixfmt executable and options should be configurable):
|
||||||
|
let g:ale_nix_nixfmt_executable = '/path/to/nixfmt'
|
||||||
|
let g:ale_nix_nixfmt_options = '--help'
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ {
|
||||||
|
\ 'command': ale#Escape('/path/to/nixfmt')
|
||||||
|
\ . ' --help',
|
||||||
|
\ },
|
||||||
|
\ ale#fixers#nixfmt#Fix(bufnr(''))
|
Loading…
Reference in New Issue