diff --git a/.dotter/machines/fedora.toml b/.dotter/machines/fedora.toml index 291e7c8..ee05f71 100644 --- a/.dotter/machines/fedora.toml +++ b/.dotter/machines/fedora.toml @@ -41,7 +41,7 @@ cli = [ dev = [ "gcc", "gcc-c++", - "just" + "just", "nodejs", "openssl", "openssl-devel", diff --git a/config/nvim/lazy-lock.json b/config/nvim/lazy-lock.json index f9a1db0..fb0acf6 100644 --- a/config/nvim/lazy-lock.json +++ b/config/nvim/lazy-lock.json @@ -1,18 +1,13 @@ { "CopilotChat.nvim": { "branch": "canary", "commit": "df19e7ab15537436a26f59fa991f2fa81d847a0d" }, "LuaSnip": { "branch": "master", "commit": "ce0a05ab4e2839e1c48d072c5236cce846a387bc" }, + "blink-cmp-copilot": { "branch": "main", "commit": "e3eedf36ceda1932e296ec894de4ceea8ddeacb6" }, + "blink.cmp": { "branch": "main", "commit": "81069e3955a8b4d5063287a2a6a47a844e9ca2cb" }, + "blink.compat": { "branch": "main", "commit": "08943fdf2eb00432d6205db6d0239434135416bd" }, "catppuccin": { "branch": "main", "commit": "637d99e638bc6f1efedac582f6ccab08badac0c6" }, "ccc.nvim": { "branch": "main", "commit": "4fb5abaef2f2e0540fe22d4d74a9841205fff9e4" }, - "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, - "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, - "cmp-conventionalcommits": { "branch": "master", "commit": "a4dfacf0601130b7f8afa7c948d735c27802fb7f" }, - "cmp-git": { "branch": "main", "commit": "22116bdffbe68bfc6ca05d52e9f217587cbfea8b" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, - "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, - "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "comment-box.nvim": { "branch": "main", "commit": "06bb771690bc9df0763d14769b779062d8f12bc5" }, "conform.nvim": { "branch": "master", "commit": "0ebe875d9c306f5fc829db38492ffff2a70d8e9d" }, - "copilot-cmp": { "branch": "master", "commit": "b6e5286b3d74b04256d0a7e3bd2908eabec34b44" }, "copilot-lualine": { "branch": "main", "commit": "f40450c3e138766026327e7807877ea860618258" }, "copilot.lua": { "branch": "master", "commit": "f8d8d872bb319f640d5177dad5fbf01f7a16d7d0" }, "dressing.nvim": { "branch": "master", "commit": "fc78a3ca96f4db9f8893bb7e2fd9823e0780451b" }, @@ -33,7 +28,6 @@ "noice.nvim": { "branch": "main", "commit": "6263b6696811f0b11c88d8d2371134b1cc1762fc" }, "nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" }, "nvim-autopairs": { "branch": "master", "commit": "78a4507bb9ffc9b00f11ae0ac48243d00cb9194d" }, - "nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" }, "nvim-lint": { "branch": "master", "commit": "efc6fc83f0772283e064c53a8f9fb5645bde0bc0" }, "nvim-lspconfig": { "branch": "master", "commit": "216deb2d1b5fbf24398919228208649bbf5cbadf" }, "nvim-notify": { "branch": "master", "commit": "fbef5d32be8466dd76544a257d3f3dce20082a07" }, diff --git a/config/nvim/lua/aleidk/constants.lua b/config/nvim/lua/aleidk/constants.lua index 0d9495c..52cdd9f 100644 --- a/config/nvim/lua/aleidk/constants.lua +++ b/config/nvim/lua/aleidk/constants.lua @@ -29,7 +29,7 @@ return { Color = " ", Constant = " ", Constructor = " ", - Copilot = " ", + Copilot = " ", Enum = " ", EnumMember = " ", Event = " ", diff --git a/config/nvim/lua/aleidk/plugins-core/colorscheme.lua b/config/nvim/lua/aleidk/plugins-core/colorscheme.lua index ff0bf3f..92a58d4 100644 --- a/config/nvim/lua/aleidk/plugins-core/colorscheme.lua +++ b/config/nvim/lua/aleidk/plugins-core/colorscheme.lua @@ -7,17 +7,15 @@ return { -- Change colors.none if not using a transparent background transparent_background = true, integrations = { aerial = true, + blink_cmp = true, cmp = true, - notify = true, harpoon = false, + indent_blankline = { enabled = true, scope_color = "text", }, + lsp_trouble = true, mason = true, neogit = true, noice = true, - lsp_trouble = true, - indent_blankline = { - enabled = true, - scope_color = "text", - }, + notify = true, }, custom_highlights = function(colors) return { diff --git a/config/nvim/lua/aleidk/plugins-ide/ai.lua b/config/nvim/lua/aleidk/plugins-ide/ai.lua index f6e9df7..aa9a4c1 100644 --- a/config/nvim/lua/aleidk/plugins-ide/ai.lua +++ b/config/nvim/lua/aleidk/plugins-ide/ai.lua @@ -12,8 +12,15 @@ return { config = function() require("copilot").setup({ suggestion = { enabled = false }, - panel = { enabled = true, auto_refresh = true }, + panel = { enabled = false }, }) + + vim.g.copilot_autocomplete_enabled = false + + vim.api.nvim_create_user_command("CopilotToggleAutocomplete", function() + vim.g.copilot_autocomplete_enabled = not vim.g.copilot_autocomplete_enabled + print("Copilot autocompletion: " .. tostring(vim.g.copilot_autocomplete_enabled)) + end, { desc = "Toggle Copilot autocompletion" }) end, }, }, @@ -62,6 +69,7 @@ return { }, } end, + keys = { { "at", diff --git a/config/nvim/lua/aleidk/plugins-ide/completion.lua b/config/nvim/lua/aleidk/plugins-ide/completion.lua index a267bfd..d46396b 100644 --- a/config/nvim/lua/aleidk/plugins-ide/completion.lua +++ b/config/nvim/lua/aleidk/plugins-ide/completion.lua @@ -1,120 +1,107 @@ ----@diagnostic disable: missing-fields return { - "hrsh7th/nvim-cmp", - version = false, -- last release is way too old - event = "InsertEnter", + "saghen/blink.cmp", + lazy = false, + version = "*", dependencies = { - "L3MON4D3/LuaSnip", - "davidsierradz/cmp-conventionalcommits", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-cmdline", - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-path", - "petertriho/cmp-git", - "saadparwaiz1/cmp_luasnip", - "windwp/nvim-autopairs", - { - "zbirenbaum/copilot-cmp", - config = function() - require("copilot_cmp").setup() - end - }, + "rafamadriz/friendly-snippets", + "giuxtaposition/blink-cmp-copilot", + "folke/lazydev.nvim", + { "saghen/blink.compat", version = "*", }, }, - config = function() - vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) - local cmp = require("cmp") - - local cmp_autopairs = require("nvim-autopairs.completion.cmp") - cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) - - local defaults = require("cmp.config.default")() - local window_opts = { + opts = function() + local window_options = { border = "rounded", - side_padding = 1, - -- fix colors for catppuccin colorscheme - winhighlight = "Normal:Pmenu,FloatBorder:FloatBorder,CursorLine:PmenuSel,Search:None", + winblend = vim.o.pumblend, } - local opts = { - visible_docs = false, - completion = { - completeopt = "menu,menuone,noinsert", + + ---@module 'blink.cmp' + ---@type blink.cmp.Config + return { + sources = { + providers = { + dadbod = { name = "Dadbod", module = "vim_dadbod_completion.blink" }, + lazydev = { name = "LazyDev", module = "lazydev.integrations.blink" }, + copilot = { + name = "copilot", + module = "blink-cmp-copilot", + score_offset = 5, + enabled = function() + if vim.g.copilot_autocomplete_enabled == nil then + return false + end + return vim.g.copilot_autocomplete_enabled + end, + }, + luasnip = { + name = 'luasnip', + module = 'blink.compat.source', + score_offset = -3, + opts = { + use_show_condition = false, + show_autosnippets = true, + }, + }, + }, + -- nvim-cmp sources + compat = {}, + completion = { + enabled_providers = { + "copilot", + "lsp", + "path", + "snippets", + "buffer", + "dadbod", + "lazydev", + }, + }, }, - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, + accept = { + auto_brackets = { enabled = true }, + expand_snippet = function(snippet) require('luasnip').lsp_expand(snippet) end, }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), - [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), - [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), - [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = function() - if cmp.visible_docs() then - cmp.close_docs() - else - cmp.open_docs() - end - end, - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.abort(), - ["
"] = cmp.mapping.abort(), - [""] = cmp.mapping.confirm({ select = false }), -- Confirm only if selected an item - [""] = cmp.mapping.confirm({ - -- Auto confirms first item - behavior = cmp.ConfirmBehavior.Replace, - select = true, + trigger = { signature_help = { enabled = true } }, + keymap = { + preset = "enter", + [""] = { 'scroll_documentation_up', 'fallback' }, + [""] = { 'scroll_documentation_down', 'fallback' }, + }, + highlight = { + -- sets the fallback highlight groups to nvim-cmp's highlight groups + -- useful for when your theme doesn't support blink.cmp + -- will be removed in a future release, assuming themes add support + use_nvim_cmp_as_default = false, + }, + -- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- adjusts spacing to ensure icons are aligned + nerd_font_variant = "mono", + windows = { + autocomplete = vim.tbl_extend("force", window_options, { + selection = "manual", + ---@type blink.cmp.Draw + draw = { + components = { + kind_icon = { + text = function(ctx) + if ctx.item.source_name == "copilot" then + ctx.kind_icon = require("aleidk.constants").icons.kinds.Copilot + end + + return ctx.kind_icon .. ctx.icon_gap + end, + } + } + } + }), + documentation = vim.tbl_extend("force", window_options, { + auto_show = true, + winblend = 0, }), - }), - sources = cmp.config.sources({ - { name = "conventionalcommits" }, - { name = "copilot" }, - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "buffer" }, - { name = "path" }, - }), - formatting = { - fields = { "kind", "abbr", "menu" }, - format = function(_, item) - local icons = require("aleidk.constants").icons.kinds - if icons[item.kind] then - item.kind = icons[item.kind] .. item.kind - end - return item - end, - }, - window = { - completion = cmp.config.window.bordered(window_opts), - documentation = cmp.config.window.bordered(window_opts), - }, - experimental = { ghost_text = { - hl_group = "CmpGhostText", - }, - }, - sorting = { - priority_weight = 2, - comparators = { - require("copilot_cmp.comparators").prioritize, - - -- Below is the default comparitor list and order for nvim-cmp - cmp.config.compare.offset, - -- cmp.config.compare.scopes, --this is commented in nvim-cmp too - cmp.config.compare.exact, - cmp.config.compare.score, - cmp.config.compare.recently_used, - cmp.config.compare.locality, - cmp.config.compare.kind, - cmp.config.compare.sort_text, - cmp.config.compare.length, - cmp.config.compare.order, + enabled = true, }, }, + kind_icons = require("aleidk.constants").icons.kinds, } - - cmp.setup(opts) - end, + end } diff --git a/config/nvim/lua/aleidk/plugins-ide/lsp.lua b/config/nvim/lua/aleidk/plugins-ide/lsp.lua index 2565d96..fd35eea 100644 --- a/config/nvim/lua/aleidk/plugins-ide/lsp.lua +++ b/config/nvim/lua/aleidk/plugins-ide/lsp.lua @@ -21,6 +21,7 @@ return { -- Automatically install LSPs to stdpath for neovim { "williamboman/mason.nvim", config = true }, "williamboman/mason-lspconfig.nvim", + { 'saghen/blink.cmp' } -- autocompletion }, config = function() @@ -146,7 +147,7 @@ return { -- nvim-cmp supports additional completion capabilities, so broadcast that to servers local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) + capabilities = require("blink.cmp").get_lsp_capabilities(capabilities) -- Ensure the servers above are installed local mason_lspconfig = require("mason-lspconfig")