File tree Expand file tree Collapse file tree 7 files changed +65
-0
lines changed Expand file tree Collapse file tree 7 files changed +65
-0
lines changed Original file line number Diff line number Diff line change @@ -406,6 +406,11 @@ let s:default_registry = {
406
406
\ ' suggested_filetypes' : [' ada' ],
407
407
\ ' description' : ' Format Ada files with gnatpp.' ,
408
408
\ },
409
+ \ ' nixfmt' : {
410
+ \ ' function' : ' ale#fixers#nixfmt#Fix' ,
411
+ \ ' suggested_filetypes' : [' nix' ],
412
+ \ ' description' : ' A nix formatter written in Haskell.' ,
413
+ \ },
409
414
\ ' nixpkgs-fmt' : {
410
415
\ ' function' : ' ale#fixers#nixpkgsfmt#Fix' ,
411
416
\ ' suggested_filetypes' : [' nix' ],
Original file line number Diff line number Diff line change
1
+ scriptencoding utf- 8
2
+ " Author: houstdav000 <[email protected] >
3
+ " Description: Fix files with nixfmt
4
+
5
+ call ale#Set (' nix_nixfmt_executable' , ' nixfmt' )
6
+ call ale#Set (' nix_nixfmt_options' , ' ' )
7
+
8
+ function ! ale#fixers#nixfmt#Fix (buffer ) abort
9
+ let l: executable = ale#Var (a: buffer , ' nix_nixfmt_executable' )
10
+ let l: options = ale#Var (a: buffer , ' nix_nixfmt_options' )
11
+
12
+ return {
13
+ \ ' command' : ale#Escape (l: executable ) . ale#Pad (l: options ),
14
+ \}
15
+ endfunction
Original file line number Diff line number Diff line change 2
2
ALE Nix Integration *ale-nix-options*
3
3
4
4
5
+ ===============================================================================
6
+ nixfmt *ale-nix-nixfmt*
7
+
8
+ g:ale_nix_nixfmt_executable *g:ale_nix_nixfmt_executable*
9
+ *b:ale_nix_nixfmt_executable*
10
+ Type: String
11
+ Default: 'nixfmt'
12
+
13
+ This variable sets the executable used for nixfmt.
14
+
15
+ g:ale_nix_nixfmt_options *g:ale_nix_nixfmt_options*
16
+ *b:ale_nix_nixfmt_options*
17
+ Type: String
18
+ Default: ''
19
+
20
+ This variable can be set to pass additional options to the nixfmt fixer.
21
+
22
+
5
23
===============================================================================
6
24
nixpkgs-fmt *ale-nix-nixpkgs-fmt*
7
25
Original file line number Diff line number Diff line change @@ -319,6 +319,7 @@ Notes:
319
319
* `nimpretty`
320
320
* nix
321
321
* `nix- instantiate`
322
+ * `nixfmt`
322
323
* `nixpkgs- fmt`
323
324
* `rnix- lsp `
324
325
* nroff
Original file line number Diff line number Diff line change @@ -2859,6 +2859,7 @@ documented in additional help files.
2859
2859
nimlsp................................| ale-nim-nimlsp |
2860
2860
nimpretty.............................| ale-nim-nimpretty |
2861
2861
nix.....................................| ale-nix-options |
2862
+ nixfmt................................| ale-nix-nixfmt |
2862
2863
nixpkgs-fmt...........................| ale-nix-nixpkgs-fmt |
2863
2864
nroff...................................| ale-nroff-options |
2864
2865
write-good............................| ale-nroff-write-good |
Original file line number Diff line number Diff line change @@ -328,6 +328,7 @@ formatting.
328
328
* nimpretty
329
329
* nix
330
330
* [ nix-instantiate] ( http://nixos.org/nix/manual/#sec-nix-instantiate )
331
+ * [ nixfmt] ( https://github.com/serokell/nixfmt )
331
332
* [ nixpkgs-fmt] ( https://github.com/nix-community/nixpkgs-fmt )
332
333
* [ rnix-lsp] ( https://github.com/nix-community/rnix-lsp )
333
334
* nroff
Original file line number Diff line number Diff line change
1
+ Before:
2
+ Save g:ale_nix_nixfmt_executable
3
+ Save g:ale_nix_nixfmt_options
4
+
5
+ After:
6
+ Restore
7
+
8
+ Execute(The nixfmt callback should return the correct default values):
9
+ AssertEqual
10
+ \ {
11
+ \ 'command': ale#Escape('nixfmt')
12
+ \ },
13
+ \ ale#fixers#nixfmt#Fix(bufnr(''))
14
+
15
+ Execute(The nixfmt executable and options should be configurable):
16
+ let g:ale_nix_nixfmt_executable = '/path/to/nixfmt'
17
+ let g:ale_nix_nixfmt_options = '--help'
18
+
19
+ AssertEqual
20
+ \ {
21
+ \ 'command': ale#Escape('/path/to/nixfmt')
22
+ \ . ' --help',
23
+ \ },
24
+ \ ale#fixers#nixfmt#Fix(bufnr(''))
You can’t perform that action at this time.
0 commit comments