feat: auto save and fix cmp keymap

This commit is contained in:
xinyangli 2024-09-02 11:29:17 +08:00
parent 4138a017a3
commit 7e0140a6a9
Signed by: xin
SSH key fingerprint: SHA256:qZ/tzd8lYRtUFSrfBDBMcUqV4GHKxqeqRA3huItgvbk
2 changed files with 43 additions and 12 deletions

View file

@ -47,6 +47,8 @@
signcolumn = "yes"; signcolumn = "yes";
# Search case sensitivity. # Search case sensitivity.
ic = true; ic = true;
# For dragging windows
mouse = "a";
}; };
# Clipboard. # Clipboard.
@ -54,5 +56,12 @@
register = "unnamedplus"; register = "unnamedplus";
providers.xclip.enable = true; providers.xclip.enable = true;
}; };
autoCmd = [
{
event = "InsertLeave";
pattern = "*";
command = "silent! update";
}
];
}; };
} }

View file

@ -2,7 +2,6 @@
plugins = { plugins = {
cmp = { cmp = {
enable = true; enable = true;
autoEnableSources = false;
settings = { settings = {
sources = [ sources = [
{ name = "nvim_lsp"; } { name = "nvim_lsp"; }
@ -20,20 +19,43 @@
keywordLength = 3; keywordLength = 3;
} }
]; ];
mapping = { mapping = {
"<Tab>" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})"; "<Tab>" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})";
"<C-j>" = "cmp.mapping.select_next_item()"; "<C-j>" = "cmp.mapping.select_next_item()";
"<C-k>" = "cmp.mapping.select_prev_item()"; "<C-k>" = "cmp.mapping.select_prev_item()";
"<C-e>" = "cmp.mapping.abort()"; "<C-e>" = "cmp.mapping.abort()";
"<C-b>" = "cmp.mapping.scroll_docs(-4)"; "<C-b>" = "cmp.mapping.scroll_docs(-4)";
"<C-f>" = "cmp.mapping.scroll_docs(4)"; "<C-f>" = "cmp.mapping.scroll_docs(4)";
"<C-Space>" = "cmp.mapping.complete()"; "<C-Space>" = "cmp.mapping.complete()";
"<CR>" = "cmp.mapping.confirm({ select = true })"; "<CR>" = "cmp.mapping.confirm({ select = true })";
"<S-CR>" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })"; "<S-CR>" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })";
};}; };
};
}; };
cmp-nvim-lsp.enable = true; cmp-nvim-lsp.enable = true;
cmp-path.enable = true; cmp-path.enable = true;
cmp-buffer.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 = "<leader>q";
action = "q";
options = {
noremap = true;
silent = true;
};
}
{
mode = [ "n" ];
key = "q";
action = "<Nop>";
options = {
noremap = true;
silent = true;
};
}
];
} }