From b93ce3ced83c1b95d339bbf2dcc5a23630d85e37 Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Sun, 14 Apr 2024 22:10:41 +0200 Subject: [PATCH] plugins/nvim-cmp: add alwaysComplete option Disabling this option makes the completion window not popup by default, requiring manual activation. --- docs/release-notes/rl-0.6.md | 4 ++++ modules/plugins/completion/nvim-cmp/config.nix | 1 + modules/plugins/completion/nvim-cmp/nvim-cmp.nix | 10 ++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/rl-0.6.md b/docs/release-notes/rl-0.6.md index c6d7777..02a1ac6 100644 --- a/docs/release-notes/rl-0.6.md +++ b/docs/release-notes/rl-0.6.md @@ -88,3 +88,7 @@ Release notes for release 0.6 - Added plugin auto-discovery from plugin inputs. This is mostly from [JordanIsaac's neovim-flake](https://github.com/jordanisaacs/neovim-flake) + +[jacekpoz](https://github.com/jacekpoz): + +- Added `vim.autocomplete.alwaysComplete`. Allows users to have the autocomplete window popup only when manually activated. diff --git a/modules/plugins/completion/nvim-cmp/config.nix b/modules/plugins/completion/nvim-cmp/config.nix index 142a118..49522fb 100644 --- a/modules/plugins/completion/nvim-cmp/config.nix +++ b/modules/plugins/completion/nvim-cmp/config.nix @@ -219,6 +219,7 @@ in { completion = { completeopt = 'menu,menuone,noinsert', + ${optionalString (!cfg.alwaysComplete) "autocomplete = false"} }, formatting = { diff --git a/modules/plugins/completion/nvim-cmp/nvim-cmp.nix b/modules/plugins/completion/nvim-cmp/nvim-cmp.nix index ac89783..8efa649 100644 --- a/modules/plugins/completion/nvim-cmp/nvim-cmp.nix +++ b/modules/plugins/completion/nvim-cmp/nvim-cmp.nix @@ -1,11 +1,17 @@ {lib, ...}: let inherit (lib.options) mkEnableOption mkOption literalMD; inherit (lib.nvim.binds) mkMappingOption; - inherit (lib.types) enum attrsOf nullOr str; + inherit (lib.types) enum attrsOf nullOr str bool; in { options.vim = { autocomplete = { - enable = mkEnableOption "enable autocomplete" // {default = false;}; + enable = mkEnableOption "autocomplete" // {default = false;}; + + alwaysComplete = mkOption { + type = bool; + description = "Automatically show completion."; + default = true; + }; mappings = { complete = mkMappingOption "Complete [nvim-cmp]" "";