Add custom snippets to COC
diff --git a/flake.nix b/flake.nix
index 60612f1..8f3ef8b 100644
--- a/flake.nix
+++ b/flake.nix
@@ -96,7 +96,7 @@
home-options =
nixpkgs.lib.traceVal (normalizeOptions
(args.options.home-manager.users.type.getSubOptions []));
- inherit system;
+ inherit system utils;
}))
])
{
diff --git a/modules/neovim/coc/default.nix b/modules/neovim/coc/default.nix
index 4248655..ca61561 100644
--- a/modules/neovim/coc/default.nix
+++ b/modules/neovim/coc/default.nix
@@ -4,6 +4,7 @@
lib,
nixpkgs-minion,
home,
+ utils,
...
}: {
programs.neovim = {
@@ -57,4 +58,18 @@
];
extraPackages = [pkgs.nodejs pkgs.rustc pkgs.go];
};
+ home.file = lib.pipe ./snippets [
+ builtins.readDir
+ builtins.attrNames
+ (map
+ (f: {
+ name = ".config/coc/ultisnips/${f}";
+ value = {
+ source = ./snippets + "/${f}";
+ target = ".config/coc/ultisnips/${f}";
+ };
+ }))
+ builtins.listToAttrs
+ lib.traceValSeq
+ ];
}
diff --git a/modules/neovim/coc/snippets/markdown.snippets b/modules/neovim/coc/snippets/markdown.snippets
new file mode 100644
index 0000000..a873672
--- /dev/null
+++ b/modules/neovim/coc/snippets/markdown.snippets
@@ -0,0 +1,33 @@
+# A valid snippet should starts with:
+#
+# snippet trigger_word [ "description" [ options ] ]
+#
+# and end with:
+#
+# endsnippet
+#
+# Snippet options:
+#
+# b - Beginning of line.
+# i - In-word expansion.
+# w - Word boundary.
+# r - Regular expression
+# e - Custom context snippet
+# A - Snippet will be triggered automatically, when condition matches.
+#
+# Basic example:
+#
+# snippet emitter "emitter properties" b
+# private readonly ${1} = new Emitter<$2>()
+# public readonly ${1/^_(.*)/$1/}: Event<$2> = this.$1.event
+# endsnippet
+#
+# Online reference: https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt
+
+snippet dydx "The derivative" w
+\frac{dy}{dx}
+endsnippet
+
+snippet d2ydx2 "The second derivative" w
+\frac{d^2y}{dx^2}
+endsnippet