From f422cec5d99efbe56a0f73a1efe60636d3f87a75 Mon Sep 17 00:00:00 2001 From: Anton Nesterov Date: Mon, 11 Nov 2024 04:33:29 +0100 Subject: [PATCH] disable annoying shit autocomplete and copilot --- lazy-lock.json | 22 +++++++++++----------- lua/config/keymaps.lua | 23 +++++++++++++++++++++++ lua/plugins/cmp.lua | 29 +++++++++++++++++++++++++++++ lua/plugins/default.lua | 2 +- 4 files changed, 64 insertions(+), 12 deletions(-) create mode 100644 lua/plugins/cmp.lua diff --git a/lazy-lock.json b/lazy-lock.json index 42de648..dfe313b 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,23 +1,23 @@ { - "LazyVim": { "branch": "main", "commit": "5efb88f44a03d0fd8ca3801067de904aecf7e86d" }, + "LazyVim": { "branch": "main", "commit": "f57944f926176a9782c5e3f2804bec0132195d77" }, "SchemaStore.nvim": { "branch": "main", "commit": "5f0639d68cbea3ab8a9a24a51a5f984d86ea8438" }, "bufferline.nvim": { "branch": "main", "commit": "5cc447cb2b463cb499c82eaeabbed4f5fa6a0a44" }, - "catppuccin": { "branch": "main", "commit": "35d8057137af463c9f41f169539e9b190d57d269" }, - "cmake-tools.nvim": { "branch": "master", "commit": "d8eb4372fff47028c36f6bec6a8318b166092ed0" }, + "catppuccin": { "branch": "main", "commit": "637d99e638bc6f1efedac582f6ccab08badac0c6" }, + "cmake-tools.nvim": { "branch": "master", "commit": "15a095c151364baa4cddc553f121e8df087983a6" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-git": { "branch": "main", "commit": "ec049036e354ed8ed0215f2427112882e1ea7051" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, - "conform.nvim": { "branch": "master", "commit": "d28ccf945374edd9f1c34a82f6c22261dbd8ab98" }, + "conform.nvim": { "branch": "master", "commit": "8c354323201d04530727d8bdcc4669791ee082ef" }, "copilot-cmp": { "branch": "master", "commit": "b6e5286b3d74b04256d0a7e3bd2908eabec34b44" }, "copilot.lua": { "branch": "master", "commit": "f8d8d872bb319f640d5177dad5fbf01f7a16d7d0" }, "dashboard-nvim": { "branch": "master", "commit": "ae309606940d26d8c9df8b048a6e136b6bbec478" }, - "dressing.nvim": { "branch": "master", "commit": "6ef1ca479d37d4ff66f13eed44d08912caff483a" }, + "dressing.nvim": { "branch": "master", "commit": "43b8f74e0b1e3f41e51f640f8efa3bcd401cea0d" }, "flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" }, "friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" }, "gitsigns.nvim": { "branch": "main", "commit": "4daf7022f1481edf1e8fb9947df13bb07c18e89a" }, "grug-far.nvim": { "branch": "main", "commit": "26415d3cc2fef99ccefa019cbc3969f404a83e70" }, - "indent-blankline.nvim": { "branch": "master", "commit": "04e44b09ee3ff189c69ab082edac1ef7ae2e256c" }, + "indent-blankline.nvim": { "branch": "master", "commit": "e51b651ca26cba250ef3a1150c8d35045eee2a84" }, "lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" }, "lazydev.nvim": { "branch": "main", "commit": "d5800897d9180cea800023f2429bce0a94ed6064" }, "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, @@ -25,21 +25,21 @@ "mason-lspconfig.nvim": { "branch": "main", "commit": "4d0e5b49363cac187326998b96aa6a2884e0e89b" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "mini.ai": { "branch": "main", "commit": "31c149067d38b97720d2a179619f7745a0006ecc" }, - "mini.icons": { "branch": "main", "commit": "a2742459f0ee32806c2438ca06b4d8b331f3f4d4" }, + "mini.icons": { "branch": "main", "commit": "54686be7d58807906cb2c8c2216e0bf9c044f19a" }, "mini.pairs": { "branch": "main", "commit": "7e834c5937d95364cc1740e20d673afe2d034cdb" }, "neo-tree.nvim": { "branch": "main", "commit": "a77af2e764c5ed4038d27d1c463fa49cd4794e07" }, - "noice.nvim": { "branch": "main", "commit": "eac7e84b16765066dc235a4d6cf8102d7436f6cd" }, + "noice.nvim": { "branch": "main", "commit": "2087bbf8cd64482b47fb5f33b5e0eabf329ab14b" }, "nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" }, "nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" }, "nvim-lint": { "branch": "master", "commit": "36da8dd0ddc4f88e0beae234c20e75397326f143" }, - "nvim-lspconfig": { "branch": "master", "commit": "d01864641c6e43c681c3e9f6cf4745c75fdd9dcc" }, + "nvim-lspconfig": { "branch": "master", "commit": "4cb925e96288a71409a86c84fd97f4434a95453e" }, "nvim-snippets": { "branch": "main", "commit": "56b4052f71220144689caaa2e5b66222ba5661eb" }, - "nvim-treesitter": { "branch": "master", "commit": "0603b3e3d21ebe2fa82dc5361a3d500e0d3ad3a8" }, + "nvim-treesitter": { "branch": "master", "commit": "a069bb62a86caaa15ea68af9e6a3bcd8cbc3608d" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "3e450cd85243da99dc23ebbf14f9c70e9a0c26a4" }, "nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" }, "persistence.nvim": { "branch": "main", "commit": "f6aad7dde7fcf54148ccfc5f622c6d5badd0cc3d" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, - "snacks.nvim": { "branch": "main", "commit": "7f9f691a12d0665146b25a44323f21e18aa46c24" }, + "snacks.nvim": { "branch": "main", "commit": "166aed6c5d9b94a1989db1625f4893b2110a8be1" }, "tailwindcss-colorizer-cmp.nvim": { "branch": "main", "commit": "3d3cd95e4a4135c250faf83dd5ed61b8e5502b86" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, "telescope.nvim": { "branch": "master", "commit": "85922dde3767e01d42a08e750a773effbffaea3e" }, diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index 2c134f7..6400cc5 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -1,3 +1,26 @@ -- Keymaps are automatically loaded on the VeryLazy event -- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua -- Add any additional keymaps here +-- +local Snacks = require("snacks") +local copilot_exists = pcall(require, "copilot") + +if copilot_exists then + Snacks.toggle({ + name = "Copilot Completion", + color = { + enabled = "azure", + disabled = "orange", + }, + get = function() + return not require("copilot.client").is_disabled() + end, + set = function(state) + if state then + require("copilot.command").enable() + else + require("copilot.command").disable() + end + end, + }):map("at") +end diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua new file mode 100644 index 0000000..d8eddb9 --- /dev/null +++ b/lua/plugins/cmp.lua @@ -0,0 +1,29 @@ +local cmp = require("cmp") + +return { + "hrsh7th/nvim-cmp", + opts = { + enabled = function() + local context = require("cmp.config.context") + local disabled = false + disabled = disabled or (vim.api.nvim_get_option_value("buftype", { buf = 0 }) == "prompt") + disabled = disabled or (vim.fn.reg_recording() ~= "") + disabled = disabled or (vim.fn.reg_executing() ~= "") + disabled = disabled or context.in_treesitter_capture("comment") + return not disabled + end, + mapping = { + [""] = cmp.mapping({ + i = function(fallback) + if cmp.visible() and cmp.get_active_entry() then + cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) + else + fallback() + end + end, + s = cmp.mapping.confirm({ select = true }), + c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), + }), + }, + }, +} diff --git a/lua/plugins/default.lua b/lua/plugins/default.lua index 17f53d6..4f7d32c 100644 --- a/lua/plugins/default.lua +++ b/lua/plugins/default.lua @@ -36,7 +36,7 @@ return { dependencies = { "hrsh7th/cmp-emoji" }, ---@param opts cmp.ConfigSchema opts = function(_, opts) - table.insert(opts.sources, { name = "emoji" }) + table.insert(opts.sources, { name = "emoji" }) -- disable auto-select on enter end, },