From 7e0140a6a9eff2ab3292d8269bc99efeb3581835 Mon Sep 17 00:00:00 2001 From: xinyangli Date: Mon, 2 Sep 2024 11:29:17 +0800 Subject: [PATCH] feat: auto save and fix cmp keymap --- config/core.nix | 9 +++++++++ config/nvim-cmp.nix | 46 +++++++++++++++++++++++++++++++++------------ 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/config/core.nix b/config/core.nix index 189f31f..ff6990d 100644 --- a/config/core.nix +++ b/config/core.nix @@ -47,6 +47,8 @@ signcolumn = "yes"; # Search case sensitivity. ic = true; + # For dragging windows + mouse = "a"; }; # Clipboard. @@ -54,5 +56,12 @@ register = "unnamedplus"; providers.xclip.enable = true; }; + autoCmd = [ + { + event = "InsertLeave"; + pattern = "*"; + command = "silent! update"; + } + ]; }; } diff --git a/config/nvim-cmp.nix b/config/nvim-cmp.nix index 3f6fc5a..df8f3f1 100644 --- a/config/nvim-cmp.nix +++ b/config/nvim-cmp.nix @@ -2,7 +2,6 @@ plugins = { cmp = { enable = true; - autoEnableSources = false; settings = { sources = [ { name = "nvim_lsp"; } @@ -20,20 +19,43 @@ keywordLength = 3; } ]; - mapping = { - "" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})"; - "" = "cmp.mapping.select_next_item()"; - "" = "cmp.mapping.select_prev_item()"; - "" = "cmp.mapping.abort()"; - "" = "cmp.mapping.scroll_docs(-4)"; - "" = "cmp.mapping.scroll_docs(4)"; - "" = "cmp.mapping.complete()"; - "" = "cmp.mapping.confirm({ select = true })"; - "" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })"; - };}; + mapping = { + "" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})"; + "" = "cmp.mapping.select_next_item()"; + "" = "cmp.mapping.select_prev_item()"; + "" = "cmp.mapping.abort()"; + "" = "cmp.mapping.scroll_docs(-4)"; + "" = "cmp.mapping.scroll_docs(4)"; + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping.confirm({ select = true })"; + "" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })"; + }; + }; }; cmp-nvim-lsp.enable = true; cmp-path.enable = true; cmp-buffer.enable = true; }; + keymaps = [ + # Need to map macro recording to another key due to: + # https://github.com/hrsh7th/nvim-cmp/issues/1692 + { + mode = [ "n" ]; + key = "q"; + action = "q"; + options = { + noremap = true; + silent = true; + }; + } + { + mode = [ "n" ]; + key = "q"; + action = ""; + options = { + noremap = true; + silent = true; + }; + } + ]; }