This commit is contained in:
parent
dbf5bde36b
commit
4ac31540af
7 changed files with 269 additions and 1 deletions
|
@ -1,3 +1,16 @@
|
|||
{
|
||||
flake.modules.nixvim.custom.plugins.luasnip.enable = true;
|
||||
flake.modules.nixvim.custom.plugins = {
|
||||
cmp_luasnip.enable = true;
|
||||
|
||||
luasnip = {
|
||||
enable = true;
|
||||
|
||||
fromLua = [
|
||||
{
|
||||
lazyLoad = true;
|
||||
paths = ./snippets;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
return {
|
||||
s("log", fmta("console.log(<>);", { i(1, "value") })),
|
||||
}
|
13
modules2/nixvim/plugins/completion/snippets/lua.lua
Normal file
13
modules2/nixvim/plugins/completion/snippets/lua.lua
Normal file
|
@ -0,0 +1,13 @@
|
|||
return {
|
||||
s(
|
||||
"req",
|
||||
fmt([[local {} = require "{}"]], {
|
||||
f(function(import_name)
|
||||
local parts = vim.split(import_name[1][1], ".", true)
|
||||
|
||||
return parts[#parts] or ""
|
||||
end, { 1 }),
|
||||
i(1),
|
||||
})
|
||||
)
|
||||
}
|
111
modules2/nixvim/plugins/completion/snippets/nix.lua
Normal file
111
modules2/nixvim/plugins/completion/snippets/nix.lua
Normal file
|
@ -0,0 +1,111 @@
|
|||
return {
|
||||
s("home_packages", fmta("home.packages = with pkgs; [ <> ];", i(0))),
|
||||
|
||||
s(
|
||||
"homepage_options",
|
||||
fmta(
|
||||
[[
|
||||
homepage.name = mkOption {
|
||||
default = "<name>";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
homepage.description = mkOption {
|
||||
default = "<description>";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
homepage.icon = mkOption {
|
||||
default = "<icon>";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
homepage.category = mkOption {
|
||||
default = "<finish>";
|
||||
type = types.str;
|
||||
};
|
||||
]],
|
||||
{
|
||||
description = i(2),
|
||||
finish = i(0),
|
||||
icon = i(3),
|
||||
name = i(1),
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
s(
|
||||
"imports",
|
||||
fmta(
|
||||
[[
|
||||
{
|
||||
imports = [
|
||||
<>
|
||||
];
|
||||
}
|
||||
]],
|
||||
{ i(0) }
|
||||
)
|
||||
),
|
||||
|
||||
s(
|
||||
"new_flake",
|
||||
fmta(
|
||||
[[
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";<inputs>
|
||||
};
|
||||
|
||||
outputs =
|
||||
{ nixpkgs, ... }:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
|
||||
inherit (pkgs) mkShell;
|
||||
in
|
||||
{
|
||||
devShells.${system}.default = mkShell {
|
||||
packages = with pkgs; [ <pkgs> ];
|
||||
};<finish>
|
||||
|
||||
formatter.${system} = pkgs.nixfmt-classic;
|
||||
};
|
||||
}
|
||||
]],
|
||||
{ inputs = i(1), pkgs = i(2), finish = i(0) }
|
||||
)
|
||||
),
|
||||
s(
|
||||
"new_module",
|
||||
fmta(
|
||||
[[
|
||||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
name = "<name>";
|
||||
cfg = config.<namespace>.${name};
|
||||
in
|
||||
{
|
||||
options.<namespace>.${name} = {
|
||||
enable = lib.mkEnableOption "Enable ${name}";<more_options>
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
<finish>
|
||||
};
|
||||
}
|
||||
]],
|
||||
{
|
||||
finish = i(0),
|
||||
more_options = i(3),
|
||||
name = i(1),
|
||||
namespace = i(2),
|
||||
},
|
||||
{ repeat_duplicates = true }
|
||||
)
|
||||
),
|
||||
|
||||
s("system_packages", fmta("environment.systemPackages = with pkgs; [<>];", i(0))),
|
||||
}
|
55
modules2/nixvim/plugins/completion/snippets/php.lua
Normal file
55
modules2/nixvim/plugins/completion/snippets/php.lua
Normal file
|
@ -0,0 +1,55 @@
|
|||
return {
|
||||
s("func", fmta("function <>(<>)<> {\n <>\n}<>", { i(1), i(2), i(3), i(4), i(0) })),
|
||||
|
||||
s(
|
||||
"met",
|
||||
fmta(
|
||||
[[
|
||||
<> function <>(<>)<> {
|
||||
<>
|
||||
}<>
|
||||
]],
|
||||
{ c(1, { t "public", t "protected", t "private" }), i(2), i(3), i(4), i(5), i(0) }
|
||||
)
|
||||
),
|
||||
|
||||
s("pest", fmta("<>('<>', function() {\n <>\n});", { c(1, { t "it", t "test" }), i(2), i(0) })),
|
||||
|
||||
s(
|
||||
"test",
|
||||
fmta(
|
||||
[[
|
||||
public function test<>(): void {
|
||||
<>
|
||||
}<>
|
||||
]],
|
||||
{ i(1), i(2), i(0) }
|
||||
)
|
||||
),
|
||||
|
||||
s(
|
||||
"testan",
|
||||
fmta(
|
||||
[[
|
||||
/** @test */
|
||||
public function <>(): void {
|
||||
<>
|
||||
}<>
|
||||
]],
|
||||
{ i(1), i(2), i(0) }
|
||||
)
|
||||
),
|
||||
|
||||
s(
|
||||
"testat",
|
||||
fmta(
|
||||
[[
|
||||
[#Test]
|
||||
public function <>(): void {
|
||||
<>
|
||||
}<>
|
||||
]],
|
||||
{ i(1), i(2), i(0) }
|
||||
)
|
||||
)
|
||||
}
|
54
modules2/nixvim/plugins/completion/snippets/rst.lua
Normal file
54
modules2/nixvim/plugins/completion/snippets/rst.lua
Normal file
|
@ -0,0 +1,54 @@
|
|||
local fmta = require("luasnip.extras.fmt").fmta
|
||||
|
||||
local fill_line = function(char)
|
||||
return function()
|
||||
local row = vim.api.nvim_win_get_cursor(0)[1]
|
||||
local lines = vim.api.nvim_buf_get_lines(0, row - 2, row, false)
|
||||
return string.rep(char, #lines[1])
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
s("class", t(".. class:: ", i(1))),
|
||||
|
||||
s("footer", t(".. footer:: ", i(1))),
|
||||
|
||||
s("link", t(".. _", i(1), ":")),
|
||||
|
||||
s("raw", t(".. raw:: ", i(1))),
|
||||
|
||||
-- TODO: add an optional new line and ":width" property.
|
||||
s("image", t(".. image:: ", i(1))),
|
||||
|
||||
s("head", f(fill_line "=", {})),
|
||||
|
||||
s("sub", f(fill_line "-", {})),
|
||||
|
||||
s("subsub", f(fill_line "^", {})),
|
||||
|
||||
-- Add a page break with an optional page template.
|
||||
s(
|
||||
"pb",
|
||||
fmta(
|
||||
[[
|
||||
.. raw:: pdf
|
||||
|
||||
PageBreak<>
|
||||
]],
|
||||
{ i(0) }
|
||||
)
|
||||
),
|
||||
|
||||
-- Add a new speaker note.
|
||||
s(
|
||||
"ta",
|
||||
fmta(
|
||||
[[
|
||||
.. raw:: pdf
|
||||
|
||||
TextAnnotation "<>"
|
||||
]],
|
||||
{ i(0) }
|
||||
)
|
||||
),
|
||||
}
|
19
modules2/nixvim/plugins/completion/snippets/twig.lua
Normal file
19
modules2/nixvim/plugins/completion/snippets/twig.lua
Normal file
|
@ -0,0 +1,19 @@
|
|||
return {
|
||||
s("do", fmta("{% <> %}<>", { i(1), i(0) })),
|
||||
s("dump", fmta("{{ dump(<>) }}<>", { i(1), i(0) })),
|
||||
s("echo", fmta("{{ <> }}<>", { i(1), i(0) })),
|
||||
|
||||
s(
|
||||
"for",
|
||||
fmta(
|
||||
[[
|
||||
{% for <> in <> %}
|
||||
<>
|
||||
{% endfor %}<>
|
||||
]],
|
||||
{ i(1), i(2), i(3), i(0) }
|
||||
)
|
||||
),
|
||||
|
||||
s("if", fmta("{% if <> %}<>{% endif %}<>", { i(1), i(2), i(0) })),
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue