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 {