Add dap to blink

This commit is contained in:
Thomas Avé 2025-02-28 13:03:34 +01:00
parent 6740f1bdb7
commit 6d7540715a
1 changed files with 215 additions and 193 deletions

View File

@ -1,10 +1,23 @@
local function is_dap_buffer()
return require("cmp_dap").is_dap_buffer()
end
return {
{
'saghen/blink.compat',
version = '*',
lazy = true,
opts = {},
},
{
'saghen/blink.cmp',
dependencies = {
'rafamadriz/friendly-snippets',
'honza/vim-snippets',
'neovim/nvim-lspconfig',
'williamboman/mason-lspconfig.nvim',
"rcarriga/cmp-dap",
"mfussenegger/nvim-dap"
},
build = 'nix run --extra-experimental-features flakes --extra-experimental-features nix-command .#build-plugin',
keys = {
@ -32,35 +45,42 @@ return {
appearance = {
nerd_font_variant = 'mono'
},
sources = {
default = { 'lsp', 'path', 'snippets', 'buffer' },
transform_items = function(_, items)
for _, item in ipairs(items) do
local types = require('blink.cmp.types')
local map = {}
map[types.CompletionItemKind.Text] = -3
map[types.CompletionItemKind.Method] = 10
map[types.CompletionItemKind.Function] = 9
map[types.CompletionItemKind.Field] = 8
map[types.CompletionItemKind.Class] = 7
map[types.CompletionItemKind.Variable] = 6
map[types.CompletionItemKind.Property] = 5
if map[item.kind] ~= nil then
item.score_offset = item.score_offset + map[item.kind]
end
if item.label:match("^__") then
item.score_offset = item.score_offset - 3
end
end
return items
enabled = function()
return vim.bo.buftype ~= "prompt" or is_dap_buffer()
end,
sources = {
default = function(_)
if is_dap_buffer() then
return { "dap", "snippets", "buffer" }
else
return { "lsp", "path", "snippets", "buffer" }
end
end,
-- transform_items = function(_, items)
-- for _, item in ipairs(items) do
-- local types = require('blink.cmp.types')
-- local map = {}
-- map[types.CompletionItemKind.Text] = -3
-- map[types.CompletionItemKind.Method] = 10
-- map[types.CompletionItemKind.Function] = 9
-- map[types.CompletionItemKind.Field] = 8
-- map[types.CompletionItemKind.Class] = 7
-- map[types.CompletionItemKind.Variable] = 6
-- map[types.CompletionItemKind.Property] = 5
--
-- if map[item.kind] ~= nil then
-- item.score_offset = item.score_offset + map[item.kind]
-- end
-- if item.label:match("^__") then
-- item.score_offset = item.score_offset - 3
-- end
-- end
-- return items
-- end,
providers = {
lsp = {
async = true,
timeout_ms = 0,
}
}
dadbod = { name = "Dadbod", module = "vim_dadbod_completion.blink" },
dap = { name = "dap", module = "blink.compat.source" },
},
},
completion = {
menu = {
@ -79,6 +99,7 @@ return {
-- experimental signature help support
signature = { enabled = true }
},
opts_extend = { "sources.default" },
lazy = false,
config = function(_, opts)
require('blink.cmp').setup(opts)
@ -202,3 +223,4 @@ return {
})
end
}
}