diff --git a/lua/plugins/completion.lua b/lua/plugins/completion.lua index af51344..226db89 100644 --- a/lua/plugins/completion.lua +++ b/lua/plugins/completion.lua @@ -1,108 +1,9 @@ return { - "hrsh7th/nvim-cmp", - dependencies = { - -- Adds LSP completion capabilities - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-cmdline", - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-path", - "saadparwaiz1/cmp_luasnip", - "neovim/nvim-lspconfig", + "saghen/blink.cmp", + dependencies = "rafamadriz/friendly-snippets", + version = "*", - -- Snippets - { - "L3MON4D3/LuaSnip", -- snippet engine - dependencies = { - "rafamadriz/friendly-snippets", -- pre-configured snippet texts - config = function() - require("luasnip.loaders.from_vscode").lazy_load() - end, - }, - }, + opts = { + keymap = { preset = "enter" }, }, - event = { "InsertEnter", "CmdlineEnter" }, - opts = function() - local cmp = require("cmp") - local luasnip = require("luasnip") - local has_words_before = function() - unpack = unpack or table.unpack - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil - end - - cmp.setup({ - -- keybinds - -- see: https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings - mapping = { - [""] = 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" }), - - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - if luasnip.expandable() then - luasnip.expand() - else - cmp.confirm({ - select = true, - }) - end - else - fallback() - end - end), - - [""] = cmp.mapping.select_prev_item({ behavior = "select" }), - [""] = cmp.mapping.select_next_item({ behavior = "select" }), - }, - - -- snippet engine - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - - -- completion source - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "buffer" }, - { name = "path" }, - }), - }) - - -- Use buffer source for `/` and `?` - cmp.setup.cmdline({ "/", "?" }, { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = "buffer" }, - }, - }) - - -- Use cmdline & path source for ':' - cmp.setup.cmdline(":", { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = "path" }, - { name = "cmdline" }, - }), - }) - end, } diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index 9414d92..f4abc51 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -1,25 +1,27 @@ return { "neovim/nvim-lspconfig", + dependencies = { "saghen/blink.cmp" }, init = function() - local capabilities = require("cmp_nvim_lsp").default_capabilities() -- needed for nvim-cmp + local capabilities = require("blink.cmp").get_lsp_capabilities() + local lspconfig = require("lspconfig") - require("lspconfig").lua_ls.setup({ + lspconfig.lua_ls.setup({ capabilities = capabilities, }) - require("lspconfig").ruff.setup({ + lspconfig.pyright.setup({ capabilities = capabilities, }) - require("lspconfig").nil_ls.setup({ + lspconfig.nil_ls.setup({ capabilities = capabilities, }) - require("lspconfig").gopls.setup({ + lspconfig.gopls.setup({ capabilities = capabilities, }) - require("lspconfig").ts_ls.setup({ + lspconfig.ts_ls.setup({ capabilities = capabilities, }) end,