{ 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() ${ lib.optionalString (lib.elem "nvim::lsp" config.machine.pkgs) # lua '' local lsp_zero = require('lsp-zero') lsp_zero.extend_cmp() '' } local cmp = require('cmp') local cmp_action = lsp_zero.cmp_action() cmp.setup({ ${ lib.optionalString (lib.elem "nvim::lsp" config.machine.pkgs) # lua ''formatting = lsp_zero.cmp_format(),'' } mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.complete(), [''] = cmp.mapping.confirm({ select = true }), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp_action.luasnip_jump_forward(), [''] = cmp_action.luasnip_jump_backward(), }) }) end ''; } { dir = vPlug: vPlug.luasnip; lazy = true; } ]; }