mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-12-16 17:11:02 +00:00
treewide: remove vsnip, add luasnip
This commit is contained in:
parent
130f64d1ee
commit
2e07db7efc
12 changed files with 183 additions and 204 deletions
|
|
@ -108,7 +108,7 @@ isMaximal: {
|
||||||
autopairs.nvim-autopairs.enable = true;
|
autopairs.nvim-autopairs.enable = true;
|
||||||
|
|
||||||
autocomplete.nvim-cmp.enable = true;
|
autocomplete.nvim-cmp.enable = true;
|
||||||
snippets.vsnip.enable = true;
|
snippets.luasnip.enable = true;
|
||||||
|
|
||||||
filetree = {
|
filetree = {
|
||||||
nvimTree = {
|
nvimTree = {
|
||||||
|
|
|
||||||
85
flake.lock
generated
85
flake.lock
generated
|
|
@ -316,6 +316,22 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"plugin-cmp-luasnip": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1696878902,
|
||||||
|
"narHash": "sha256-nUJJl2zyK/oSwz5RzI9j3gf9zpDfCImCYbPbVsyXgz8=",
|
||||||
|
"owner": "saadparwaiz1",
|
||||||
|
"repo": "cmp_luasnip",
|
||||||
|
"rev": "05a9ab28b53f71d1aece421ef32fee2cb857a843",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "saadparwaiz1",
|
||||||
|
"repo": "cmp_luasnip",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"plugin-cmp-nvim-lsp": {
|
"plugin-cmp-nvim-lsp": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
|
@ -364,22 +380,6 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"plugin-cmp-vsnip": {
|
|
||||||
"flake": false,
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1669100283,
|
|
||||||
"narHash": "sha256-2mkN03noOr5vBvRbSb35xZKorSH+8savQNZtgM9+QcM=",
|
|
||||||
"owner": "hrsh7th",
|
|
||||||
"repo": "cmp-vsnip",
|
|
||||||
"rev": "989a8a73c44e926199bfd05fa7a516d51f2d2752",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "hrsh7th",
|
|
||||||
"repo": "cmp-vsnip",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"plugin-codewindow-nvim": {
|
"plugin-codewindow-nvim": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
|
@ -588,6 +588,22 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"plugin-friendly-snippets": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1727061933,
|
||||||
|
"narHash": "sha256-yTsuV5unoujY0mhLINssYYBWCeefe+nJaxQHJKm7hlk=",
|
||||||
|
"owner": "rafamadriz",
|
||||||
|
"repo": "friendly-snippets",
|
||||||
|
"rev": "00ba9dd3df89509f95437b8d595553707c46d5ea",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "rafamadriz",
|
||||||
|
"repo": "friendly-snippets",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"plugin-gesture-nvim": {
|
"plugin-gesture-nvim": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
|
@ -828,6 +844,22 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"plugin-luasnip": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1726165831,
|
||||||
|
"narHash": "sha256-nkaa1NGOI28Et2QitQB+Spv+J42QVdHE1oywteLcJJw=",
|
||||||
|
"owner": "L3MON4D3",
|
||||||
|
"repo": "LuaSnip",
|
||||||
|
"rev": "e808bee352d1a6fcf902ca1a71cee76e60e24071",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "L3MON4D3",
|
||||||
|
"repo": "LuaSnip",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"plugin-mind-nvim": {
|
"plugin-mind-nvim": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
|
@ -1757,22 +1789,6 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"plugin-vim-vsnip": {
|
|
||||||
"flake": false,
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1704937299,
|
|
||||||
"narHash": "sha256-gvm6z4pgSULBVPukewRyjwxZ0vZgreQWbG/0kOB1QBo=",
|
|
||||||
"owner": "hrsh7th",
|
|
||||||
"repo": "vim-vsnip",
|
|
||||||
"rev": "02a8e79295c9733434aab4e0e2b8c4b7cea9f3a9",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "hrsh7th",
|
|
||||||
"repo": "vim-vsnip",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"plugin-which-key": {
|
"plugin-which-key": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
|
@ -1827,10 +1843,10 @@
|
||||||
"plugin-cheatsheet-nvim": "plugin-cheatsheet-nvim",
|
"plugin-cheatsheet-nvim": "plugin-cheatsheet-nvim",
|
||||||
"plugin-cinnamon-nvim": "plugin-cinnamon-nvim",
|
"plugin-cinnamon-nvim": "plugin-cinnamon-nvim",
|
||||||
"plugin-cmp-buffer": "plugin-cmp-buffer",
|
"plugin-cmp-buffer": "plugin-cmp-buffer",
|
||||||
|
"plugin-cmp-luasnip": "plugin-cmp-luasnip",
|
||||||
"plugin-cmp-nvim-lsp": "plugin-cmp-nvim-lsp",
|
"plugin-cmp-nvim-lsp": "plugin-cmp-nvim-lsp",
|
||||||
"plugin-cmp-path": "plugin-cmp-path",
|
"plugin-cmp-path": "plugin-cmp-path",
|
||||||
"plugin-cmp-treesitter": "plugin-cmp-treesitter",
|
"plugin-cmp-treesitter": "plugin-cmp-treesitter",
|
||||||
"plugin-cmp-vsnip": "plugin-cmp-vsnip",
|
|
||||||
"plugin-codewindow-nvim": "plugin-codewindow-nvim",
|
"plugin-codewindow-nvim": "plugin-codewindow-nvim",
|
||||||
"plugin-comment-nvim": "plugin-comment-nvim",
|
"plugin-comment-nvim": "plugin-comment-nvim",
|
||||||
"plugin-copilot-cmp": "plugin-copilot-cmp",
|
"plugin-copilot-cmp": "plugin-copilot-cmp",
|
||||||
|
|
@ -1844,6 +1860,7 @@
|
||||||
"plugin-fastaction-nvim": "plugin-fastaction-nvim",
|
"plugin-fastaction-nvim": "plugin-fastaction-nvim",
|
||||||
"plugin-fidget-nvim": "plugin-fidget-nvim",
|
"plugin-fidget-nvim": "plugin-fidget-nvim",
|
||||||
"plugin-flutter-tools": "plugin-flutter-tools",
|
"plugin-flutter-tools": "plugin-flutter-tools",
|
||||||
|
"plugin-friendly-snippets": "plugin-friendly-snippets",
|
||||||
"plugin-gesture-nvim": "plugin-gesture-nvim",
|
"plugin-gesture-nvim": "plugin-gesture-nvim",
|
||||||
"plugin-gitsigns-nvim": "plugin-gitsigns-nvim",
|
"plugin-gitsigns-nvim": "plugin-gitsigns-nvim",
|
||||||
"plugin-glow-nvim": "plugin-glow-nvim",
|
"plugin-glow-nvim": "plugin-glow-nvim",
|
||||||
|
|
@ -1859,6 +1876,7 @@
|
||||||
"plugin-lspkind": "plugin-lspkind",
|
"plugin-lspkind": "plugin-lspkind",
|
||||||
"plugin-lspsaga": "plugin-lspsaga",
|
"plugin-lspsaga": "plugin-lspsaga",
|
||||||
"plugin-lualine": "plugin-lualine",
|
"plugin-lualine": "plugin-lualine",
|
||||||
|
"plugin-luasnip": "plugin-luasnip",
|
||||||
"plugin-mind-nvim": "plugin-mind-nvim",
|
"plugin-mind-nvim": "plugin-mind-nvim",
|
||||||
"plugin-minimap-vim": "plugin-minimap-vim",
|
"plugin-minimap-vim": "plugin-minimap-vim",
|
||||||
"plugin-modes-nvim": "plugin-modes-nvim",
|
"plugin-modes-nvim": "plugin-modes-nvim",
|
||||||
|
|
@ -1917,7 +1935,6 @@
|
||||||
"plugin-vim-markdown": "plugin-vim-markdown",
|
"plugin-vim-markdown": "plugin-vim-markdown",
|
||||||
"plugin-vim-repeat": "plugin-vim-repeat",
|
"plugin-vim-repeat": "plugin-vim-repeat",
|
||||||
"plugin-vim-startify": "plugin-vim-startify",
|
"plugin-vim-startify": "plugin-vim-startify",
|
||||||
"plugin-vim-vsnip": "plugin-vim-vsnip",
|
|
||||||
"plugin-which-key": "plugin-which-key",
|
"plugin-which-key": "plugin-which-key",
|
||||||
"rnix-lsp": "rnix-lsp",
|
"rnix-lsp": "rnix-lsp",
|
||||||
"systems": "systems_2"
|
"systems": "systems_2"
|
||||||
|
|
|
||||||
19
flake.nix
19
flake.nix
|
|
@ -277,11 +277,6 @@
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
plugin-cmp-vsnip = {
|
|
||||||
url = "github:hrsh7th/cmp-vsnip";
|
|
||||||
flake = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
plugin-cmp-path = {
|
plugin-cmp-path = {
|
||||||
url = "github:hrsh7th/cmp-path";
|
url = "github:hrsh7th/cmp-path";
|
||||||
flake = false;
|
flake = false;
|
||||||
|
|
@ -292,9 +287,19 @@
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
plugin-cmp-luasnip = {
|
||||||
|
url = "github:saadparwaiz1/cmp_luasnip";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
|
||||||
# snippets
|
# snippets
|
||||||
plugin-vim-vsnip = {
|
plugin-luasnip = {
|
||||||
url = "github:hrsh7th/vim-vsnip";
|
url = "github:L3MON4D3/LuaSnip";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
plugin-friendly-snippets = {
|
||||||
|
url = "github:rafamadriz/friendly-snippets";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,12 @@
|
||||||
inherit (lib.strings) optionalString;
|
inherit (lib.strings) optionalString;
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (lib.nvim.binds) addDescriptionsToMappings;
|
inherit (lib.nvim.binds) addDescriptionsToMappings;
|
||||||
inherit (lib.nvim.dag) entryAnywhere;
|
inherit (lib.nvim.dag) entryAfter;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
inherit (builtins) attrNames;
|
inherit (builtins) attrNames;
|
||||||
|
|
||||||
cfg = config.vim.autocomplete.nvim-cmp;
|
cfg = config.vim.autocomplete.nvim-cmp;
|
||||||
vsnipEnable = config.vim.snippets.vsnip.enable;
|
luasnipEnable = config.vim.snippets.luasnip.enable;
|
||||||
|
|
||||||
self = import ./nvim-cmp.nix {inherit lib config;};
|
self = import ./nvim-cmp.nix {inherit lib config;};
|
||||||
mappingDefinitions = self.options.vim.autocomplete.nvim-cmp.mappings;
|
mappingDefinitions = self.options.vim.autocomplete.nvim-cmp.mappings;
|
||||||
|
|
@ -32,8 +32,6 @@ in {
|
||||||
path = "[Path]";
|
path = "[Path]";
|
||||||
};
|
};
|
||||||
|
|
||||||
autopairs.nvim-autopairs.setupOpts.map_cr = false;
|
|
||||||
|
|
||||||
autocomplete.nvim-cmp.setupOpts = {
|
autocomplete.nvim-cmp.setupOpts = {
|
||||||
sources = map (s: {name = s;}) (attrNames cfg.sources);
|
sources = map (s: {name = s;}) (attrNames cfg.sources);
|
||||||
|
|
||||||
|
|
@ -46,133 +44,74 @@ in {
|
||||||
formatting.format = cfg.format;
|
formatting.format = cfg.format;
|
||||||
};
|
};
|
||||||
|
|
||||||
pluginRC.nvim-cmp = mkIf cfg.enable (entryAnywhere ''
|
pluginRC.nvim-cmp = mkIf cfg.enable (entryAfter ["autopairs"] ''
|
||||||
|
local luasnip = require("luasnip")
|
||||||
local cmp = require("cmp")
|
local cmp = require("cmp")
|
||||||
cmp.setup(${toLuaObject cfg.setupOpts})
|
cmp.setup(${toLuaObject cfg.setupOpts})
|
||||||
|
|
||||||
${
|
|
||||||
optionalString config.vim.autopairs.nvim-autopairs.enable
|
|
||||||
''
|
|
||||||
cmp.event:on('confirm_done', require("nvim-autopairs.completion.cmp").on_confirm_done({ map_char = { text = "" } }))
|
|
||||||
''
|
|
||||||
}
|
|
||||||
'');
|
'');
|
||||||
|
|
||||||
keymaps = [
|
# `cmp` and `luasnip` are defined above, in the `nvim-cmp` section
|
||||||
{
|
autocomplete.nvim-cmp.setupOpts.mapping = {
|
||||||
mode = ["i" "c"];
|
${mappings.complete.value} = mkLuaInline "cmp.mapping.complete()";
|
||||||
key = mappings.complete.value;
|
${mappings.close.value} = mkLuaInline "cmp.mapping.abort()";
|
||||||
lua = true;
|
${mappings.scrollDocsUp.value} = mkLuaInline "cmp.mapping.scroll_docs(-4)";
|
||||||
action = "require('cmp').complete";
|
${mappings.scrollDocsDown.value} = mkLuaInline "cmp.mapping.scroll_docs(4)";
|
||||||
desc = mappings.complete.description;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
${mappings.confirm.value} = mkLuaInline ''
|
||||||
mode = "i";
|
cmp.mapping(function(fallback)
|
||||||
key = mappings.confirm.value;
|
if cmp.visible() then
|
||||||
lua = true;
|
|
||||||
action = let
|
|
||||||
defaultKeys =
|
|
||||||
if config.vim.autopairs.nvim-autopairs.enable
|
|
||||||
then "require('nvim-autopairs').autopairs_cr()"
|
|
||||||
else "vim.api.nvim_replace_termcodes(${toLuaObject mappings.confirm.value}, true, false, true)";
|
|
||||||
in ''
|
|
||||||
function()
|
|
||||||
if not require('cmp').confirm({ select = true }) then
|
|
||||||
vim.fn.feedkeys(${defaultKeys}, 'n')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
'';
|
|
||||||
desc = mappings.confirm.description;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
mode = ["i" "s"];
|
|
||||||
key = mappings.next.value;
|
|
||||||
lua = true;
|
|
||||||
action = ''
|
|
||||||
function()
|
|
||||||
local has_words_before = function()
|
|
||||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
|
||||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local cmp = require('cmp')
|
|
||||||
|
|
||||||
local feedkey = function(key, mode)
|
|
||||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_next_item()
|
|
||||||
${
|
${
|
||||||
optionalString vsnipEnable
|
if luasnipEnable
|
||||||
''
|
then ''
|
||||||
elseif vim.fn['vsnip#available'](1) == 1 then
|
if luasnip.expandable() then
|
||||||
feedkey("<Plug>(vsnip-expand-or-jump)", "")
|
luasnip.expand()
|
||||||
''
|
|
||||||
}
|
|
||||||
elseif has_words_before() then
|
|
||||||
cmp.complete()
|
|
||||||
else
|
else
|
||||||
vim.fn.feedkeys(vim.api.nvim_replace_termcodes(${toLuaObject mappings.next.value}, true, false, true), 'n')
|
cmp.confirm({ select = true })
|
||||||
end
|
end
|
||||||
|
''
|
||||||
|
else "cmp.confirm({ select = true })"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
end
|
end
|
||||||
'';
|
end)
|
||||||
desc = mappings.next.description;
|
'';
|
||||||
}
|
|
||||||
|
|
||||||
{
|
${mappings.next.value} = mkLuaInline ''
|
||||||
mode = ["i" "s"];
|
cmp.mapping(function(fallback)
|
||||||
key = mappings.previous.value;
|
local has_words_before = function()
|
||||||
lua = true;
|
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||||
action = ''
|
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||||
function()
|
|
||||||
local cmp = require('cmp')
|
|
||||||
|
|
||||||
local feedkey = function(key, mode)
|
|
||||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_prev_item()
|
|
||||||
${
|
|
||||||
optionalString vsnipEnable
|
|
||||||
''
|
|
||||||
elseif vim.fn['vsnip#available'](-1) == 1 then
|
|
||||||
feedkeys("<Plug>(vsnip-jump-prev)", "")
|
|
||||||
''
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
'';
|
|
||||||
desc = mappings.previous.description;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
if cmp.visible() then
|
||||||
mode = ["i" "c"];
|
cmp.select_next_item()
|
||||||
key = mappings.close.value;
|
${optionalString luasnipEnable ''
|
||||||
lua = true;
|
elseif luasnip.locally_jumpable(1) then
|
||||||
action = "require('cmp').mapping.abort()";
|
luasnip.jump(1)
|
||||||
desc = mappings.close.description;
|
''}
|
||||||
}
|
elseif has_words_before() then
|
||||||
|
cmp.complete()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
'';
|
||||||
|
|
||||||
{
|
${mappings.previous.value} = mkLuaInline ''
|
||||||
mode = ["i" "c"];
|
cmp.mapping(function(fallback)
|
||||||
key = mappings.scrollDocsUp.value;
|
if cmp.visible() then
|
||||||
lua = true;
|
cmp.select_prev_item()
|
||||||
action = "require('cmp').mapping.scroll_docs(-4)";
|
${optionalString luasnipEnable ''
|
||||||
desc = mappings.scrollDocsUp.description;
|
elseif luasnip.locally_jumpable(-1) then
|
||||||
}
|
luasnip.jump(-1)
|
||||||
|
''}
|
||||||
{
|
else
|
||||||
mode = ["i" "c"];
|
fallback()
|
||||||
key = mappings.scrollDocsDown.value;
|
end
|
||||||
lua = true;
|
end)
|
||||||
action = "require('cmp').mapping.scroll_docs(4)";
|
'';
|
||||||
desc = mappings.scrollDocsDown.description;
|
};
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,8 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let inherit (builtins) attrNames;
|
}: let
|
||||||
|
inherit (builtins) attrNames;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.options) mkOption mkEnableOption;
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
inherit (lib.strings) optionalString;
|
inherit (lib.strings) optionalString;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./vsnip
|
./luasnip
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
17
modules/plugins/snippets/luasnip/config.nix
Normal file
17
modules/plugins/snippets/luasnip/config.nix
Normal 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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
6
modules/plugins/snippets/luasnip/default.nix
Normal file
6
modules/plugins/snippets/luasnip/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./luasnip.nix
|
||||||
|
./config.nix
|
||||||
|
];
|
||||||
|
}
|
||||||
36
modules/plugins/snippets/luasnip/luasnip.nix
Normal file
36
modules/plugins/snippets/luasnip/luasnip.nix
Normal 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()
|
||||||
|
```
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -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
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
})
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
./vsnip.nix
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
{lib, ...}: let
|
|
||||||
inherit (lib.options) mkEnableOption;
|
|
||||||
in {
|
|
||||||
options.vim.snippets.vsnip = {
|
|
||||||
enable = mkEnableOption "vim-vsnip: snippet LSP/VSCode's format";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue