fish: format user and generated .fish files
Adds a `fishIndent` wrapper to pass fish scripts to the built in `fish_indent` function.
This commit is contained in:
parent
518dca61c0
commit
ca48fced83
3 changed files with 99 additions and 28 deletions
50
tests/modules/programs/fish/format-scripts.nix
Normal file
50
tests/modules/programs/fish/format-scripts.nix
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
{ config, pkgs, ... }:
|
||||
|
||||
let
|
||||
|
||||
expectedFunc = pkgs.writeText "func.fish" ''
|
||||
function func
|
||||
echo foo
|
||||
end
|
||||
'';
|
||||
|
||||
expectedFuncMulti = pkgs.writeText "func-multi.fish" ''
|
||||
function func-multi
|
||||
echo bar
|
||||
if foo
|
||||
bar
|
||||
baz
|
||||
end
|
||||
end
|
||||
'';
|
||||
|
||||
in {
|
||||
config = {
|
||||
programs.fish = {
|
||||
enable = true;
|
||||
|
||||
formatFishScripts = true;
|
||||
|
||||
functions = {
|
||||
func = ''echo "foo"'';
|
||||
func-multi = ''
|
||||
echo bar
|
||||
if foo
|
||||
bar
|
||||
baz
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/fish/functions/func.fish
|
||||
echo ${expectedFunc}
|
||||
assertFileContent home-files/.config/fish/functions/func.fish ${expectedFunc}
|
||||
|
||||
assertFileExists home-files/.config/fish/functions/func-multi.fish
|
||||
echo ${expectedFuncMulti}
|
||||
assertFileContent home-files/.config/fish/functions/func-multi.fish ${expectedFuncMulti}
|
||||
'';
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue