mirror of
https://github.com/nix-community/home-manager
synced 2024-12-02 16:09:46 +01:00
c802fa310e
Signed-off-by: Reputable2722 <153411261+Reputable2772@users.noreply.github.com>
95 lines
2.4 KiB
Nix
95 lines
2.4 KiB
Nix
{ pkgs, lib, ... }:
|
|
|
|
let
|
|
|
|
snippetsDir = name:
|
|
if pkgs.stdenv.hostPlatform.isDarwin then
|
|
"Library/Application Support/Code/User${
|
|
lib.optionalString (name != "default") "profiles/${name}/"
|
|
}/snippets"
|
|
else
|
|
".config/Code/User/${
|
|
lib.optionalString (name != "default") "profiles/${name}/"
|
|
}snippets";
|
|
|
|
globalSnippetsPath = name: "${snippetsDir name}/global.code-snippets";
|
|
|
|
globalSnippetsExpectedContent = pkgs.writeText "global.code-snippet" ''
|
|
{
|
|
"fixme": {
|
|
"body": [
|
|
"fixme body in global user snippet"
|
|
],
|
|
"description": "Insert a FIXME remark",
|
|
"prefix": [
|
|
"fixme"
|
|
]
|
|
}
|
|
}
|
|
'';
|
|
|
|
haskellSnippetsPath = name: "${snippetsDir name}/haskell.json";
|
|
|
|
haskellSnippetsExpectedContent = pkgs.writeText "haskell.json" ''
|
|
{
|
|
"impl": {
|
|
"body": [
|
|
"impl body in user haskell snippet"
|
|
],
|
|
"description": "Insert an implementation stub",
|
|
"prefix": [
|
|
"impl"
|
|
]
|
|
}
|
|
}
|
|
'';
|
|
|
|
snippets = {
|
|
globalSnippets = {
|
|
fixme = {
|
|
prefix = [ "fixme" ];
|
|
body = [ "fixme body in global user snippet" ];
|
|
description = "Insert a FIXME remark";
|
|
};
|
|
};
|
|
languageSnippets = {
|
|
haskell = {
|
|
impl = {
|
|
prefix = [ "impl" ];
|
|
body = [ "impl body in user haskell snippet" ];
|
|
description = "Insert an implementation stub";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
in {
|
|
programs.vscode = {
|
|
enable = true;
|
|
package = pkgs.writeScriptBin "vscode" "" // { pname = "vscode"; };
|
|
defaultProfile = snippets;
|
|
profiles = [ ({ name = "test"; } // snippets) ];
|
|
};
|
|
|
|
nmt.script = ''
|
|
assertFileExists "home-files/${globalSnippetsPath "default"}"
|
|
assertFileContent "home-files/${
|
|
globalSnippetsPath "default"
|
|
}" "${globalSnippetsExpectedContent}"
|
|
|
|
assertFileExists "home-files/${globalSnippetsPath "test"}"
|
|
assertFileContent "home-files/${
|
|
globalSnippetsPath "test"
|
|
}" "${globalSnippetsExpectedContent}"
|
|
|
|
assertFileExists "home-files/${haskellSnippetsPath "default"}"
|
|
assertFileContent "home-files/${
|
|
haskellSnippetsPath "default"
|
|
}" "${haskellSnippetsExpectedContent}"
|
|
|
|
assertFileExists "home-files/${haskellSnippetsPath "test"}"
|
|
assertFileContent "home-files/${
|
|
haskellSnippetsPath "test"
|
|
}" "${haskellSnippetsExpectedContent}"
|
|
'';
|
|
}
|