{ lib, config, ... }: lib.mkIf (lib.elem "nvim::cmp" config.machine.pkgs) { programs.nvim-lazy.lazyPlugins = [ # Autocompletion { dir = vPlug: vPlug.nvim-cmp; event = [ "InsertEnter" ]; dependencies = ( vPlug: with vPlug; [ luasnip ] ); config = # lua '' function() local cmp = require('cmp') cmp.setup({ ${ lib.optionalString (lib.elem "nvim::lsp" config.machine.pkgs) # lua ''sources = { { name = 'nvim_lsp' }, },'' } mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.complete(), [''] = cmp.mapping.confirm({ select = true }), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), }) }) end ''; } { dir = vPlug: vPlug.luasnip; lazy = true; } ]; }