Add blink.cmp
This commit is contained in:
parent
3c21b8ba57
commit
cb34b3c371
2
init.lua
2
init.lua
|
|
@ -10,7 +10,7 @@ require('treesitter-textobjects-config')
|
|||
require('noice-config')
|
||||
require('plugin-mappings')
|
||||
require('gopls')
|
||||
require('code-completion')
|
||||
-- require('code-completion')
|
||||
require('commands')
|
||||
require('lsp-config')
|
||||
require('theme-config')
|
||||
|
|
|
|||
|
|
@ -1,16 +1,10 @@
|
|||
{
|
||||
"LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
|
||||
"auto-pairs": { "branch": "master", "commit": "39f06b873a8449af8ff6a3eee716d3da14d63a76" },
|
||||
"auto-session": { "branch": "main", "commit": "af2219b9fa99c1d7ac409bd9eac094c459d3f52d" },
|
||||
"blame.nvim": { "branch": "main", "commit": "dedbcdce857f708c63f261287ac7491a893912d0" },
|
||||
"blink.cmp": { "branch": "main", "commit": "b6f11a0aa33e601c469a126e3ed6e35208fe3ea3" },
|
||||
"bookmarks.nvim": { "branch": "main", "commit": "546de255a9d3d977d0ad44a225349fcf0d0d2b44" },
|
||||
"bufferline.nvim": { "branch": "main", "commit": "2e3c8cc5a57ddd32f1edd2ffd2ccb10c09421f6c" },
|
||||
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
|
||||
"cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "031e6ba70b0ad5eee49fd2120ff7a2e325b17fa7" },
|
||||
"cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" },
|
||||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||
"cmp-vsnip": { "branch": "main", "commit": "989a8a73c44e926199bfd05fa7a516d51f2d2752" },
|
||||
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
||||
"colorful-winsep.nvim": { "branch": "alpha", "commit": "49ffe1e45c94ce379596eb78ec9f88e69e2e2221" },
|
||||
"conform.nvim": { "branch": "master", "commit": "797d1f622a23d4a21bb58218bdf5999a9beac4ef" },
|
||||
|
|
@ -22,6 +16,7 @@
|
|||
"fastaction.nvim": { "branch": "main", "commit": "886e22d85e13115808e81ca367d5aaba02d9a25b" },
|
||||
"faster.nvim": { "branch": "main", "commit": "e85c5bdff0cd1e17cbee855ae23c25e7b8e597cb" },
|
||||
"flatten.nvim": { "branch": "main", "commit": "e420e531d2ab24aebcf7b3c9fca28e6c5c34964d" },
|
||||
"friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" },
|
||||
"fuzzy-oil.nvim": { "branch": "master", "commit": "0537d3816b0b69c438db88c9cdf41ab881ef4576" },
|
||||
"git-messenger.vim": { "branch": "master", "commit": "8a61bdfa351d4df9a9118ee1d3f45edbed617072" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "47c8e3e571376b24de62408fd0c9d12f0a9fc0a3" },
|
||||
|
|
@ -37,7 +32,6 @@
|
|||
"inc-rename.nvim": { "branch": "main", "commit": "8ba77017ca468f3029bf88ef409c2d20476ea66b" },
|
||||
"indent-blankline.nvim": { "branch": "master", "commit": "d98f537c3492e87b6dc6c2e3f66ac517528f406f" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "eb4957442e3182f051b0ae11da32e06d22c190e3" },
|
||||
"lspkind.nvim": { "branch": "master", "commit": "cff4ae321a91ee3473a92ea1a8c637e3a9510aec" },
|
||||
"lspsaga.nvim": { "branch": "main", "commit": "6f920cfabddb9b7de5a3a4d0b7cd4f0774ae23e2" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "37a336b653f8594df75c827ed589f1c91d91ff6c" },
|
||||
|
|
@ -53,7 +47,6 @@
|
|||
"nightfox.nvim": { "branch": "main", "commit": "d3e8b1acc095baf57af81bb5e89fe7c4359eb619" },
|
||||
"noice.nvim": { "branch": "main", "commit": "f65b6b7ab87796f93ea8f8a92d5a64dc53d912d1" },
|
||||
"nui.nvim": { "branch": "main", "commit": "322978c734866996274467de084a95e4f9b5e0b1" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" },
|
||||
"nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" },
|
||||
"nvim-lint": { "branch": "master", "commit": "a7ce9c78a7c710c28bee56dfab10a5c0c80b7fb5" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "37f362ef42d1a604d332e8d3d7d47593852b4313" },
|
||||
|
|
@ -94,7 +87,6 @@
|
|||
"ts-comments.nvim": { "branch": "main", "commit": "872dcfa0418f4a33b7437fb4d9f4e89f2f000d74" },
|
||||
"vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" },
|
||||
"vim-visual-multi": { "branch": "master", "commit": "b84a6d42c1c10678928b0bf8327f378c8bc8af5a" },
|
||||
"vim-vsnip": { "branch": "master", "commit": "02a8e79295c9733434aab4e0e2b8c4b7cea9f3a9" },
|
||||
"which-key.nvim": { "branch": "main", "commit": "0099511294f16b81c696004fa6a403b0ae61f7a0" },
|
||||
"yeet.nvim": { "branch": "master", "commit": "4db5a452ec6b093e5e31cebc9bede2ca103cab5c" }
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
---@diagnostic disable: missing-fields
|
||||
require("noice").setup {
|
||||
cmdline = {
|
||||
enabled = true, -- enables the Noice cmdline UI
|
||||
|
|
|
|||
|
|
@ -41,24 +41,129 @@ return {
|
|||
})
|
||||
end,
|
||||
},
|
||||
'hrsh7th/nvim-cmp',
|
||||
'onsails/lspkind.nvim',
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
'hrsh7th/cmp-nvim-lua',
|
||||
'hrsh7th/cmp-nvim-lsp-signature-help',
|
||||
'hrsh7th/cmp-vsnip',
|
||||
'hrsh7th/cmp-path',
|
||||
'hrsh7th/cmp-buffer',
|
||||
'hrsh7th/vim-vsnip',
|
||||
{
|
||||
"smjonas/inc-rename.nvim",
|
||||
config = function()
|
||||
require("inc_rename").setup()
|
||||
"saghen/blink.cmp",
|
||||
version = '*',
|
||||
opts_extend = {
|
||||
"sources.completion.enabled_providers",
|
||||
"sources.compat",
|
||||
"sources.default",
|
||||
},
|
||||
dependencies = {
|
||||
"rafamadriz/friendly-snippets",
|
||||
-- add blink.compat to dependencies
|
||||
},
|
||||
event = "InsertEnter",
|
||||
|
||||
---@module 'blink.cmp'
|
||||
---@type blink.cmp.Config
|
||||
opts = {
|
||||
appearance = {
|
||||
use_nvim_cmp_as_default = false,
|
||||
nerd_font_variant = "mono",
|
||||
},
|
||||
completion = {
|
||||
accept = {
|
||||
-- experimental auto-brackets support
|
||||
auto_brackets = {
|
||||
enabled = true,
|
||||
},
|
||||
},
|
||||
menu = {
|
||||
draw = {
|
||||
treesitter = { "lsp" },
|
||||
},
|
||||
},
|
||||
documentation = {
|
||||
auto_show = true,
|
||||
auto_show_delay_ms = 200,
|
||||
},
|
||||
ghost_text = {
|
||||
enabled = vim.g.ai_cmp,
|
||||
},
|
||||
},
|
||||
|
||||
-- experimental signature help support
|
||||
signature = { enabled = true },
|
||||
--
|
||||
sources = {
|
||||
-- adding any nvim-cmp sources here will enable them
|
||||
-- with blink.compat
|
||||
compat = {},
|
||||
default = { "lsp", "path", "snippets", "buffer" },
|
||||
cmdline = {}, -- This is what prevents blink from showing up when using noice
|
||||
},
|
||||
|
||||
keymap = {
|
||||
preset = "enter",
|
||||
["<C-y>"] = { "select_and_accept" },
|
||||
},
|
||||
},
|
||||
---@param opts blink.cmp.Config | { sources: { compat: string[] } }
|
||||
config = function(_, opts)
|
||||
-- setup compat sources
|
||||
local enabled = opts.sources.default
|
||||
for _, source in ipairs(opts.sources.compat or {}) do
|
||||
opts.sources.providers[source] = vim.tbl_deep_extend(
|
||||
"force",
|
||||
{ name = source, module = "blink.compat.source" },
|
||||
opts.sources.providers[source] or {}
|
||||
)
|
||||
if type(enabled) == "table" and not vim.tbl_contains(enabled, source) then
|
||||
table.insert(enabled, source)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- TODO: Re-enable this to use tab and super-tab
|
||||
-- add ai_accept to <Tab> key
|
||||
-- if not opts.keymap["<Tab>"] then
|
||||
-- if opts.keymap.preset == "super-tab" then -- super-tab
|
||||
-- opts.keymap["<Tab>"] = {
|
||||
-- require("blink.cmp.keymap.presets")["super-tab"]["<Tab>"][1],
|
||||
-- LazyVim.cmp.map({ "snippet_forward", "ai_accept" }),
|
||||
-- "fallback",
|
||||
-- }
|
||||
-- else -- other presets
|
||||
-- opts.keymap["<Tab>"] = {
|
||||
-- LazyVim.cmp.map({ "snippet_forward", "ai_accept" }),
|
||||
-- "fallback",
|
||||
-- }
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- Unset custom prop to pass blink.cmp validation
|
||||
opts.sources.compat = nil
|
||||
|
||||
-- check if we need to override symbol kinds
|
||||
for _, provider in pairs(opts.sources.providers or {}) do
|
||||
---@cast provider blink.cmp.SourceProviderConfig|{kind?:string}
|
||||
if provider.kind then
|
||||
local CompletionItemKind = require("blink.cmp.types").CompletionItemKind
|
||||
local kind_idx = #CompletionItemKind + 1
|
||||
|
||||
CompletionItemKind[kind_idx] = provider.kind
|
||||
---@diagnostic disable-next-line: no-unknown
|
||||
CompletionItemKind[provider.kind] = kind_idx
|
||||
|
||||
---@type fun(ctx: blink.cmp.Context, items: blink.cmp.CompletionItem[]): blink.cmp.CompletionItem[]
|
||||
local transform_items = provider.transform_items
|
||||
---@param ctx blink.cmp.Context
|
||||
---@param items blink.cmp.CompletionItem[]
|
||||
provider.transform_items = function(ctx, items)
|
||||
items = transform_items and transform_items(ctx, items) or items
|
||||
for _, item in ipairs(items) do
|
||||
item.kind = kind_idx or item.kind
|
||||
end
|
||||
return items
|
||||
end
|
||||
|
||||
-- Unset custom prop to pass blink.cmp validation
|
||||
provider.kind = nil
|
||||
end
|
||||
end
|
||||
|
||||
require("blink.cmp").setup(opts)
|
||||
end,
|
||||
},
|
||||
{
|
||||
'Chaitanyabsprip/fastaction.nvim',
|
||||
---@type FastActionConfig
|
||||
opts = {},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,7 +167,6 @@ return {
|
|||
},
|
||||
event = "VeryLazy",
|
||||
},
|
||||
{ 'saadparwaiz1/cmp_luasnip' },
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
version = "v2.*",
|
||||
|
|
|
|||
Loading…
Reference in New Issue