{ helpers, ... }: let inherit (helpers) mkRaw; in { plugins.luasnip = { enable = true; filetypeExtend = { lua = [ "c" "cpp" ]; }; settings = { # https://github.com/L3MON4D3/LuaSnip/blob/master/DOC.md#config-options enable_autosnippets = true; # https://github.com/L3MON4D3/LuaSnip/blob/master/DOC.md#variables cut_selection_keys = ""; update_events = "TextChanged,TextChangedI"; }; # https://github.com/L3MON4D3/LuaSnip/blob/master/DOC.md#lua fromLua = [ { paths = ./snippets; } # snippts attached to nixvim repo { paths = "~/snippets"; } # snippts in home dir ]; }; extraFiles = { "lua/luasnip-helper-funcs.lua".source = ./helpers/luasnip-helper-funcs.lua; }; # https://github.com/L3MON4D3/LuaSnip/wiki/Nice-Configs#hint-node-type-with-virtual-text extraConfigLua = '' local types = require("luasnip.util.types") require'luasnip'.config.setup({ ext_opts = { [types.choiceNode] = { active = { -- virt_text = {{"●", "GruvboxOrange"}} -- see ":h group-name" (syntax highlighting) virt_text = {{ '««« Choice Node', 'Constant', }} } }, [types.insertNode] = { active = { -- virt_text = {{"●", "GruvboxBlue"}} -- see ":h group-name" (syntax highlighting) virt_text = {{ '««« Insert Node', 'Comment', }} } } }, }) ''; keymaps = [ { mode = [ "i" "s" ]; key = ""; action = mkRaw '' function() local ls = require('luasnip') if ls.expand_or_jumpable() then ls.expand_or_jump() end end ''; options.silent = true; } { mode = [ "i" "s" ]; key = ""; action = mkRaw '' function() local ls = require('luasnip') if ls.jumpable(-1) then ls.jump(-1) end end ''; options.silent = true; } { mode = [ "i" "s" ]; key = ""; action = mkRaw '' function() local ls = require('luasnip') if ls.choice_active() then ls.change_choice(1) end end ''; options.silent = true; } ]; }