return { -- Autocompletion "saghen/blink.cmp", event = "VimEnter", version = "1.*", dependencies = { -- Snippet Engine { "L3MON4D3/LuaSnip", version = "2.*", build = (function() -- Build Step is needed for regex support in snippets. -- This step is not supported in many windows environments. -- Remove the below condition to re-enable on windows. if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then return end return "make install_jsregexp" end)(), dependencies = { -- `friendly-snippets` contains a variety of premade snippets. -- See the README about individual language/framework/plugin snippets: -- https://github.com/rafamadriz/friendly-snippets -- { -- 'rafamadriz/friendly-snippets', -- config = function() -- require('luasnip.loaders.from_vscode').lazy_load() -- end, -- }, }, opts = {}, }, "folke/lazydev.nvim", }, config = function(_, opts) -- Monkey-patch blink's text_edits.get_from_item to clamp textEdit ranges -- that extend past the cursor. Workaround for tsgo sending bad ranges -- that eat text (e.g. in JSX string attributes like className="..."). local text_edits = require("blink.cmp.lib.text_edits") local original_get_from_item = text_edits.get_from_item text_edits.get_from_item = function(item) local text_edit = original_get_from_item(item) local cursor_col = require("blink.cmp.completion.trigger.context").get_cursor()[2] if text_edit.range and text_edit.range["end"].character > cursor_col then text_edit.range["end"].character = cursor_col end return text_edit end require("blink.cmp").setup(opts) end, --- @module 'blink.cmp' --- @type blink.cmp.Config opts = { keymap = { -- 'default' (recommended) for mappings similar to built-in completions -- to accept ([y]es) the completion. -- This will auto-import if your LSP supports it. -- This will expand snippets if the LSP sent a snippet. -- 'super-tab' for tab to accept -- 'enter' for enter to accept -- 'none' for no mappings -- -- For an understanding of why the 'default' preset is recommended, -- you will need to read `:help ins-completion` -- -- No, but seriously. Please read `:help ins-completion`, it is really good! -- -- All presets have the following mappings: -- /: move to right/left of your snippet expansion -- : Open menu or open docs if already open -- / or /: Select next/previous item -- : Hide menu -- : Toggle signature help -- -- See :h blink-cmp-config-keymap for defining your own keymap preset = "default", -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps }, appearance = { -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' -- Adjusts spacing to ensure icons are aligned nerd_font_variant = "mono", }, completion = { -- By default, you may press `` to show the documentation. -- Optionally, set `auto_show = true` to show the documentation after a delay. documentation = { auto_show = false, auto_show_delay_ms = 500 }, }, sources = { default = { "lsp", "path", "snippets", "lazydev", "minuet" }, providers = { lazydev = { module = "lazydev.integrations.blink", score_offset = 100 }, minuet = { name = "minuet", module = "minuet.blink", async = true, timeout_ms = 3000, score_offset = 50, }, }, }, snippets = { preset = "luasnip" }, -- Blink.cmp includes an optional, recommended rust fuzzy matcher, -- which automatically downloads a prebuilt binary when enabled. -- -- By default, we use the Lua implementation instead, but you may enable -- the rust implementation via `'prefer_rust_with_warning'` -- -- See :h blink-cmp-config-fuzzy for more information fuzzy = { implementation = "lua" }, -- Shows a signature help window while you type arguments for a function signature = { enabled = true }, }, }