From 3afcb7d1be4d8e3389db4f3e3c3f08f4a817d631 Mon Sep 17 00:00:00 2001 From: Tigor Hutasuhut Date: Fri, 11 Oct 2024 13:55:29 +0700 Subject: [PATCH] blink.cmp: disabled and return to nvim-cmp --- lazy-lock.json | 8 ++++++ lua/plugins/blink.cmp.lua | 58 ++++++++++++++++++++++++++++++++++++++- lua/plugins/cmp.lua | 2 +- 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 1f1ca37..0f631df 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -9,10 +9,18 @@ "blink.cmp": { "branch": "main", "commit": "8fb9d72ee4e7ce79144df48dad9d58e102053bd3" }, "bufferline.nvim": { "branch": "main", "commit": "0b2fd861eee7595015b6561dade52fb060be10c4" }, "catppuccin": { "branch": "main", "commit": "7be452ee067978cdc8b2c5f3411f0c71ffa612b9" }, + "cmp-async-path": { "branch": "main", "commit": "03fac5dfd6f7880be2c059d58bebe007f0d6d8ee" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp-nvim-lsp-document-symbol": { "branch": "main", "commit": "f94f7ba948e32cd302caba1c2ca3f7c697fb4fcf" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp-rg": { "branch": "master", "commit": "677a7874ee8f1afc648c2e7d63a97bc21a7663c5" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "codesnap.nvim": { "branch": "main", "commit": "6400480aa6cc366cbd931146c429aaa64680dab9" }, "conform.nvim": { "branch": "master", "commit": "40d4e98fcc3e6f485f0e8924c63734bc7e305967" }, "copilot.lua": { "branch": "master", "commit": "1a237cf50372830a61d92b0adf00d3b23882e0e1" }, + "crates.nvim": { "branch": "main", "commit": "8bf8358ee326d5d8c11dcd7ac0bcc9ff97dbc785" }, "dashboard-nvim": { "branch": "master", "commit": "fabf5feec96185817c732d47d363f34034212685" }, "diagflow.nvim": { "branch": "main", "commit": "fc09d55d2e60edc8ed8f9939ba97b7b7e6488c99" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, diff --git a/lua/plugins/blink.cmp.lua b/lua/plugins/blink.cmp.lua index 5ad62cb..54ed03f 100644 --- a/lua/plugins/blink.cmp.lua +++ b/lua/plugins/blink.cmp.lua @@ -3,6 +3,7 @@ return { lazy = false, -- lazy loading handled internally -- optional: provides snippets for the snippet source dependencies = "rafamadriz/friendly-snippets", + enabled = false, -- use a release tag to download pre-built binaries version = "v0.*", @@ -24,7 +25,11 @@ return { accept = { auto_brackets = { enabled = true } }, -- experimental signature help support - trigger = { signature_help = { enabled = true } }, + trigger = { + signature_help = { + enabled = true, + }, + }, keymap = { accept = "", select_prev = { "" }, @@ -32,5 +37,56 @@ return { snippet_forward = { "" }, snippet_backward = { "" }, }, + sources = { + -- similar to nvim-cmp's sources, but we point directly to the source's lua module + -- multiple groups can be provided, where it'll fallback to the next group if the previous + -- returns no completion items + -- WARN: This API will have breaking changes during the beta + -- providers = { + -- { + -- { "blink.cmp.sources.lsp" }, + -- { "blink.cmp.sources.path" }, + -- { "blink.cmp.sources.snippets", score_offset = -3 }, + -- }, + -- { { "blink.cmp.sources.buffer" } }, + -- }, + -- FOR REF: full example + providers = { + { + -- all of these properties work on every source + { + "blink.cmp.sources.lsp", + keyword_length = 0, + score_offset = 0, + opts = {}, + }, + -- the follow two sources have additional options + { + "blink.cmp.sources.path", + opts = { + trailing_slash = false, + label_trailing_slash = true, + get_cwd = function(context) + return vim.fn.expand(("#%d:p:h"):format(context.bufnr)) + end, + show_hidden_files_by_default = true, + }, + }, + { + "blink.cmp.sources.snippets", + score_offset = -3, + -- similar to https://github.com/garymjr/nvim-snippets + opts = { + friendly_snippets = true, + search_paths = { vim.fn.stdpath "config" .. "/snippets" }, + global_snippets = { "all" }, + extended_filetypes = {}, + ignored_filetypes = {}, + }, + }, + }, + { { "blink.cmp.sources.buffer" } }, + }, + }, }, } diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 10284ce..32a3048 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -5,7 +5,7 @@ return { }, { "hrsh7th/nvim-cmp", - enabled = false, + enabled = true, dependencies = { "hrsh7th/cmp-cmdline", "hrsh7th/cmp-nvim-lsp-document-symbol",