From 8d5967c1cb18a8c1c1fec02912a9f6ed7606e845 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 10 Nov 2022 18:53:16 +0000 Subject: [PATCH] lspking: add function to run after --- plugins/completion/lspkind.nix | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/plugins/completion/lspkind.nix b/plugins/completion/lspkind.nix index dd383331..93053e9c 100644 --- a/plugins/completion/lspkind.nix +++ b/plugins/completion/lspkind.nix @@ -48,6 +48,12 @@ in default = null; description = "Show source names in the popup"; }; + + after = mkOption { + type = with types; nullOr types.str; + default = null; + description = "Function to run after calculating the formatting. function(entry, vim_item, kind)"; + }; }; }; @@ -71,8 +77,15 @@ in require('lspkind').init(${helpers.toLuaObject options}) ''; - plugins.nvim-cmp.formatting.format = '' - require('lspkind').cmp_format(${helpers.toLuaObject options}) - ''; + plugins.nvim-cmp.formatting.format = + if cfg.cmp.after != null then '' + function(entry, vim_item) + local kind = require('lspkind').cmp_format(${helpers.toLuaObject options})(entry, vim_item) + + return ${cmp.cfg.after}(entry, vim_after, kind) + end + '' else '' + require('lspkind').cmp_format(${helpers.toLuaObject options}) + ''; }; }