treewide: remove vsnip, add luasnip

This commit is contained in:
diniamo 2024-10-06 20:29:05 +02:00
commit 2e07db7efc
12 changed files with 183 additions and 204 deletions

View file

@ -1,5 +1,5 @@
{
imports = [
./vsnip
./luasnip
];
}

View file

@ -0,0 +1,17 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
cfg = config.vim.snippets.luasnip;
in {
config = mkIf cfg.enable {
vim = {
startPlugins = ["luasnip" "cmp-luasnip"] ++ cfg.providers;
autocomplete.nvim-cmp.sources = {luasnip = "[LuaSnip]";};
pluginRC.luasnip = cfg.loaders;
};
};
}

View file

@ -0,0 +1,6 @@
{
imports = [
./luasnip.nix
./config.nix
];
}

View file

@ -0,0 +1,36 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption mkOption literalExpression literalMD;
inherit (lib.types) listOf lines;
inherit (lib.nvim.types) pluginType;
in {
options.vim.snippets.luasnip = {
enable = mkEnableOption "luasnip" // {default = false;};
providers = mkOption {
type = listOf pluginType;
default = ["friendly-snippets"];
description = ''
The snippet provider packages.
::: {.note}
These are simply appended to `vim.startPlugins`.
:::
'';
example = literalExpression "[\"vimPlugins.vim-snippets\"]";
};
loaders = mkOption {
type = lines;
default = "require('luasnip.loaders.from_vscode').lazy_load()";
defaultText = literalMD ''
```lua
require('luasnip.loaders.from_vscode').lazy_load()
```
'';
description = "Lua code used to load snippet providers.";
example = literalMD ''
```lua
require("luasnip.loaders.from_snipmate").lazy_load()
```
'';
};
};
}

View file

@ -1,30 +0,0 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf mkMerge;
inherit (lib.generators) mkLuaInline;
cfg = config.vim.snippets.vsnip;
in {
config = mkIf cfg.enable (mkMerge [
{
vim.startPlugins = ["vim-vsnip"];
}
(mkIf config.vim.autocomplete.nvim-cmp.enable {
vim = {
startPlugins = ["cmp-vsnip"];
autocomplete.nvim-cmp = {
sources = {"vsnip" = "[VSnip]";};
setupOpts.snippet.expand = mkLuaInline ''
function(args)
vim.fn["vsnip#anonymous"](args.body)
end
'';
};
};
})
]);
}

View file

@ -1,5 +0,0 @@
{
imports = [
./vsnip.nix
];
}

View file

@ -1,7 +0,0 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption;
in {
options.vim.snippets.vsnip = {
enable = mkEnableOption "vim-vsnip: snippet LSP/VSCode's format";
};
}