From ea13297b188e6dec8c17288b9ef82511ec3a18ee Mon Sep 17 00:00:00 2001 From: meml0rz Date: Tue, 12 Nov 2024 23:06:28 +0100 Subject: [PATCH] kekl --- modules/nix/nvim/cmp.nix | 29 ++++++++--- modules/nix/nvim/opts.nix | 107 +++++--------------------------------- 2 files changed, 34 insertions(+), 102 deletions(-) diff --git a/modules/nix/nvim/cmp.nix b/modules/nix/nvim/cmp.nix index 88dd88e..0ce1445 100644 --- a/modules/nix/nvim/cmp.nix +++ b/modules/nix/nvim/cmp.nix @@ -7,13 +7,28 @@ cmp = { enable = true; autoEnableSources = true; - settings = { - sources = [ - {name = "nvim_lsp";} - {name = "path";} - {name = "buffer";} - {name = "luasnip";} - ]; + settings = { + mapping = { + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping.scroll_docs(-4)"; + "" = "cmp.mapping.close()"; + "" = "cmp.mapping.scroll_docs(4)"; + "" = "cmp.mapping.confirm({ select = true })"; + "" = { + action = "cmp.mapping.select_prev_item()"; + modes = [ + "i" + "s" + ]; + }; + "" = { + action = "cmp.mapping.select_next_item()"; + modes = [ + "i" + "s" + ]; + }; + }; }; }; }; diff --git a/modules/nix/nvim/opts.nix b/modules/nix/nvim/opts.nix index 8c98dc1..b8d83ad 100644 --- a/modules/nix/nvim/opts.nix +++ b/modules/nix/nvim/opts.nix @@ -20,101 +20,18 @@ vim.opt.smartindent = true vim.opt.softtabstop = 4 vim.opt.numbers = true; - - - # cmp - return { - { - "hrsh7th/nvim-cmp", - dependencies = { - 'hrsh7th/cmp-nvim-lsp', - 'hrsh7th/cmp-buffer', - 'hrsh7th/cmp-path', - 'hrsh7th/cmp-cmdline', - 'hrsh7th/cmp-nvim-lua', - 'hrsh7th/cmp-calc', - 'f3fora/cmp-spell', - 'hrsh7th/cmp-emoji', - 'saadparwaiz1/cmp_luasnip', - 'L3MON4D3/LuaSnip', - - { - 'windwp/nvim-autopairs', - event = "InsertEnter", - config = true - }, - }, - config = function() - local cmp = require("cmp") - - vim.opt.completeopt = { "menu", "menuone", "noinsert", "noselect" } - - cmp.setup({ - sorting = { - comparators = { - cmp.config.compare.offset, - cmp.config.compare.exact, - cmp.config.compare.recently_used, - require("clangd_extensions.cmp_scores"), - cmp.config.compare.kind, - cmp.config.compare.sort_text, - cmp.config.compare.length, - cmp.config.compare.order, - }, - }, - window = { - completion = { - autocomplete = true, - col_offset = -3, - side_padding = 0, - }, - }, - - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - else - fallback() - end - end, { "i", "s" }), - - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - else - fallback() - end - end, { "i", "s" }), - - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.abort(), - [""] = cmp.mapping.abort(), - [""] = cmp.mapping.confirm({ select = false }), - }), - - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - { name = 'buffer' }, - { name = 'path' }, - { name = 'nvim_lua' }, - { name = 'calc' }, - { name = 'spell' }, - { name = 'emoji' }, - { name = 'crates' }, - }), - highlight = { - default = "Subtle" - - }; - }) - end - }, - } - + vim.cmd [[ + cnoreabbrev W! w! + cnoreabbrev Q! q! + cnoreabbrev Qall! qall! + cnoreabbrev Wq wq + cnoreabbrev Wa wa + cnoreabbrev wQ wq + cnoreabbrev WQ wq + cnoreabbrev W w + cnoreabbrev Q q + cnoreabbrev Qall qall + ]] ''; }; }