From 5941502e37368cb99a7b9f1e7a4c23c49418f0b4 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 18 Apr 2023 04:13:24 +0300 Subject: [PATCH] feat: enable vim-vsnip if nvim-cmp is enabled --- modules/completion/nvim-cmp/config.nix | 1 + modules/completion/nvim-cmp/nvim-cmp.nix | 25 +++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/modules/completion/nvim-cmp/config.nix b/modules/completion/nvim-cmp/config.nix index b9fececb..36aee08e 100644 --- a/modules/completion/nvim-cmp/config.nix +++ b/modules/completion/nvim-cmp/config.nix @@ -35,6 +35,7 @@ in { "cmp-buffer" "cmp-vsnip" "cmp-path" + "vim-vsnip" ]; vim.autocomplete.sources = { diff --git a/modules/completion/nvim-cmp/nvim-cmp.nix b/modules/completion/nvim-cmp/nvim-cmp.nix index bb6f7f98..9010a998 100644 --- a/modules/completion/nvim-cmp/nvim-cmp.nix +++ b/modules/completion/nvim-cmp/nvim-cmp.nix @@ -5,7 +5,30 @@ ... }: with lib; -with builtins; { +with builtins; let + cfg = config.vim.autocomplete; + lspkindEnabled = config.vim.lsp.enable && config.vim.lsp.lspkind.enable; + builtSources = + concatMapStringsSep + "\n" + (n: "{ name = '${n}'},") + (attrNames cfg.sources); + + builtMaps = + concatStringsSep + "\n" + (mapAttrsToList + (n: v: + if v == null + then "" + else "${n} = '${v}',") + cfg.sources); + + dagPlacement = + if lspkindEnabled + then nvim.dag.entryAfter ["lspkind"] + else nvim.dag.entryAnywhere; +in { options.vim = { autocomplete = { enable = mkOption {