From 8894b0ccdb661bf2dc20583ca406d39f46ed827c Mon Sep 17 00:00:00 2001 From: Ruslan Date: Wed, 18 Dec 2024 17:07:37 +0200 Subject: [PATCH] replace cmp with blink-cmp --- lazy-lock.json | 8 +++- lua/crentist/lazy/autopairs.lua | 7 ++-- lua/crentist/lazy/completion.lua | 39 ++++++++++++++++++ lua/crentist/lazy/lsp.lua | 71 ++------------------------------ 4 files changed, 52 insertions(+), 73 deletions(-) create mode 100644 lua/crentist/lazy/completion.lua diff --git a/lazy-lock.json b/lazy-lock.json index 0483779..0894517 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,4 +1,5 @@ { +<<<<<<< HEAD "LuaSnip": { "branch": "master", "commit": "33b06d72d220aa56a7ce80a0dd6f06c70cd82b9d" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, @@ -6,6 +7,10 @@ "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, +======= + "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, + "blink.cmp": { "branch": "main", "commit": "a8222cf1ccbf24818ae926f94779267659809ab0" }, +>>>>>>> 9de81ef (replace cmp with blink-cmp) "dressing.nvim": { "branch": "master", "commit": "fc78a3ca96f4db9f8893bb7e2fd9823e0780451b" }, "fidget.nvim": { "branch": "main", "commit": "9238947645ce17d96f30842e61ba81147185b657" }, "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, @@ -21,8 +26,6 @@ "mason-lspconfig.nvim": { "branch": "main", "commit": "8e46de9241d3997927af12196bd8faa0ed08c29a" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "none-ls.nvim": { "branch": "main", "commit": "40dc2e983560acaea29d6312b33fafba37b0c272" }, - "nvim-autopairs": { "branch": "master", "commit": "b464658e9b880f463b9f7e6ccddd93fb0013f559" }, - "nvim-cmp": { "branch": "main", "commit": "98e8b9d593a5547c126a39212d6f5e954a2d85dd" }, "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, "nvim-lspconfig": { "branch": "master", "commit": "056f569f71e4b726323b799b9cfacc53653bceb3" }, "nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" }, @@ -45,3 +48,4 @@ "vim-fugitive": { "branch": "master", "commit": "fcb4db52e7f65b95705aa58f0f2df1312c1f2df2" }, "vim-helm": { "branch": "master", "commit": "ae1ebc160d2b9b90108477ab10df7a4fc501e358" } } + diff --git a/lua/crentist/lazy/autopairs.lua b/lua/crentist/lazy/autopairs.lua index 5698563..8f0d4df 100644 --- a/lua/crentist/lazy/autopairs.lua +++ b/lua/crentist/lazy/autopairs.lua @@ -1,5 +1,6 @@ return { - 'windwp/nvim-autopairs', - event = "InsertEnter", - config = true +-- 'windwp/nvim-autopairs', +-- event = "InsertEnter", +-- config = true } + diff --git a/lua/crentist/lazy/completion.lua b/lua/crentist/lazy/completion.lua new file mode 100644 index 0000000..65e3f0d --- /dev/null +++ b/lua/crentist/lazy/completion.lua @@ -0,0 +1,39 @@ +return { + 'saghen/blink.cmp', + -- optional: provides snippets for the snippet source + dependencies = { + 'rafamadriz/friendly-snippets', + { 'L3MON4D3/LuaSnip', version = 'v2.*' } + }, + -- use a release tag to download pre-built binaries + -- version = 'v0.*', + build = 'cargo build --release', + + opts = { + snippets = { + expand = function(snippet) require('luasnip').lsp_expand(snippet) end, + active = function(filter) + if filter and filter.direction then + return require('luasnip').jumpable(filter.direction) + end + return require('luasnip').in_snippet() + end, + jump = function(direction) require('luasnip').jump(direction) end, + }, + + keymap = { preset = 'enter' }, + + appearance = { + use_nvim_cmp_as_default = true, + nerd_font_variant = 'mono' + }, + + sources = { + default = { 'lsp', 'luasnip', 'path', 'buffer' }, + cmdline = {}, + }, + + signature = { enabled = true } + }, +} + diff --git a/lua/crentist/lazy/lsp.lua b/lua/crentist/lazy/lsp.lua index 7a635bb..fd81969 100644 --- a/lua/crentist/lazy/lsp.lua +++ b/lua/crentist/lazy/lsp.lua @@ -4,13 +4,7 @@ return { dependencies = { 'williamboman/mason.nvim', 'williamboman/mason-lspconfig.nvim', - 'hrsh7th/nvim-cmp', - 'hrsh7th/cmp-nvim-lsp', - 'hrsh7th/cmp-buffer', - 'hrsh7th/cmp-path', - 'SergioRibera/cmp-dotenv', - 'hrsh7th/cmp-cmdline', - 'saadparwaiz1/cmp_luasnip', + 'saghen/blink.cmp', 'L3MON4D3/LuaSnip', 'j-hui/fidget.nvim', 'rafamadriz/friendly-snippets', @@ -31,7 +25,6 @@ return { config = function() local lspconfig = require('lspconfig') - local cmp = require('cmp') local luasnip = require('luasnip') -- load snippets from friendly-snippets @@ -56,69 +49,13 @@ return { }, handlers = { function(server_name) - local capabilities = require('cmp_nvim_lsp').default_capabilities() + local capabilities = require('blink.cmp').get_lsp_capabilities() require('lspconfig')[server_name].setup({ capabilities = capabilities }) end, } }) - cmp.setup({ - sources = { - { name = 'path' }, - { name = 'nvim_lsp' }, - { name = 'luasnip', keyword_length = 2 }, - { name = 'buffer', keyword_length = 3 }, - }, - mapping = cmp.mapping.preset.insert({ - -- `Enter` key to confirm completion - [''] = cmp.mapping({ - i = function(fallback) - if cmp.visible() and cmp.get_active_entry() then - cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }) - else - fallback() - end - end, - s = cmp.mapping.confirm({ select = true }), - c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), - }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.locally_jumpable(1) then - luasnip.jump(1) - else - fallback() - end - end, { 'i', 's' }), - - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { 'i', 's' }), - - -- Ctrl+Space to trigger completion menu - [''] = cmp.mapping.complete(), - - -- Scroll up and down in the completion documentation - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - }), - snippet = { - expand = function(args) - require('luasnip').lsp_expand(args.body) - end, - }, - - }) - - local capabilities = require('cmp_nvim_lsp').default_capabilities() local pythonLineLength = 95 lspconfig.pylsp.setup { settings = { @@ -146,9 +83,7 @@ return { } } - lspconfig.yamlls.setup { - capabilities = capabilities, - } + lspconfig.yamlls.setup { } lspconfig.terraformls.setup { filetypes = { 'terraform', 'terraform-vars', 'tf' }