diff --git a/lua/lsp.lua b/lua/lsp.lua index 8e3e8b8..7478d58 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -42,7 +42,7 @@ local function set_keymaps(bufnr) end, }, { - mode = "i", + mode = { "i", "s" }, lhs = "", rhs = function() vim.lsp.buf.signature_help({ @@ -141,12 +141,6 @@ function M.on_attach(client, bufnr) string.format(".%s.json", client.name), client.settings ) or client.settings - - if client:supports_method("textDocument/completion") then - vim.lsp.completion.enable(true, client.id, bufnr, { - autotrigger = true, - }) - end end function M.setup() @@ -192,6 +186,11 @@ function M.setup() }) local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities = vim.tbl_deep_extend( + "force", + capabilities, + require("blink.cmp").get_lsp_capabilities({}, false) + ) vim.lsp.config("*", { capabilities = capabilities, on_attach = M.on_attach, diff --git a/lua/plugins/blink.lua b/lua/plugins/blink.lua new file mode 100644 index 0000000..efb4173 --- /dev/null +++ b/lua/plugins/blink.lua @@ -0,0 +1,105 @@ +---@type LazyPluginSpec +return { + "saghen/blink.cmp", + dependencies = { "rafamadriz/friendly-snippets" }, + -- use a release tag to download pre-built binaries + version = "1.*", + ---@module 'blink.cmp' + ---@type blink.cmp.Config + opts = { + cmdline = { + completion = { + menu = { + auto_show = true, + }, + }, + keymap = { + preset = "inherit", + }, + }, + completion = { + documentation = { + auto_show = true, + window = { + border = "rounded", + winhighlight = "", + }, + }, + ghost_text = { + enabled = true, + }, + list = { + selection = { + preselect = false, + auto_insert = false, + }, + }, + menu = { + draw = { + align_to = "simple_label", + columns = { + { "simple_label" }, + { "kind_icon", "label_description", gap = 1 }, + }, + components = { + simple_label = { + width = { fill = true, max = 60 }, + text = function(ctx) + return ctx.label + end, + highlight = function(ctx) + local highlights = { + { + 0, + #ctx.label, + group = ctx.deprecated + and "BlinkCmpLabelDeprecated" + or "BlinkCmpLabel", + }, + } + for _, idx in ipairs(ctx.label_matched_indices) do + table.insert(highlights, { + idx, + idx + 1, + group = "BlinkCmpLabelMatch", + }) + end + + return highlights + end, + }, + }, + }, + }, + }, + fuzzy = { + implementation = "prefer_rust_with_warning", + }, + signature = { + enabled = true, + window = { + border = "rounded", + winhighlight = "", + show_documentation = false, + }, + }, + -- Default list of enabled providers defined so that you can extend it + -- elsewhere in your config, without redefining it, due to `opts_extend` + sources = { + default = { + "lsp", + "path", + "snippets", + "buffer", + }, + }, + keymap = { + preset = "none", + [""] = { "insert_next", "fallback" }, + [""] = { "insert_prev", "fallback" }, + [""] = { "accept", "fallback" }, + [""] = { "show_signature", "hide_signature", "fallback" }, + }, + }, + opts_extend = { "sources.default" }, +}