1 parent
95dc3b686a
commit
b1a92f479d
4 files changed
+190
-149
No files matched your search
+135
-134
@@ -1,124 +1,125 @@
|
||||
return {
|
||||
'saghen/blink.cmp',
|
||||
-- optional: provides snippets for the snippet source
|
||||
dependencies = { 'rafamadriz/friendly-snippets', "onsails/lspkind.nvim", "xzbdmw/colorful-menu.nvim", "nvim-tree/nvim-web-devicons"},
|
||||
'saghen/blink.cmp',
|
||||
-- optional: provides snippets for the snippet source
|
||||
dependencies = { 'rafamadriz/friendly-snippets', "onsails/lspkind.nvim", "xzbdmw/colorful-menu.nvim", "nvim-tree/nvim-web-devicons" },
|
||||
|
||||
-- use a release tag to download pre-built binaries
|
||||
version = "v1.10.2",
|
||||
-- AND/OR build from source
|
||||
-- build = 'cargo build --release',
|
||||
-- If you use nix, you can build from source with:
|
||||
-- build = 'nix run .#build-plugin',
|
||||
-- use a release tag to download pre-built binaries
|
||||
version = "v1.10.2",
|
||||
-- AND/OR build from source
|
||||
-- build = 'cargo build --release',
|
||||
-- If you use nix, you can build from source with:
|
||||
-- build = 'nix run .#build-plugin',
|
||||
|
||||
---@module 'blink.cmp'
|
||||
---@type blink.cmp.Config
|
||||
opts = {
|
||||
-- 'default' (recommended) for mappings similar to built-in completions (C-y to accept)
|
||||
-- 'super-tab' for mappings similar to vscode (tab to accept)
|
||||
-- 'enter' for enter to accept
|
||||
-- 'none' for no mappings
|
||||
--
|
||||
-- All presets have the following mappings:
|
||||
-- C-space: Open menu or open docs if already open
|
||||
-- C-n/C-p or Up/Down: Select next/previous item
|
||||
-- C-e: Hide menu
|
||||
-- C-k: Toggle signature help (if signature.enabled = true)
|
||||
--
|
||||
-- See :h blink-cmp-config-keymap for defining your own keymap
|
||||
---@module 'blink.cmp'
|
||||
---@type blink.cmp.Config
|
||||
opts = {
|
||||
-- 'default' (recommended) for mappings similar to built-in completions (C-y to accept)
|
||||
-- 'super-tab' for mappings similar to vscode (tab to accept)
|
||||
-- 'enter' for enter to accept
|
||||
-- 'none' for no mappings
|
||||
--
|
||||
-- All presets have the following mappings:
|
||||
-- C-space: Open menu or open docs if already open
|
||||
-- C-n/C-p or Up/Down: Select next/previous item
|
||||
-- C-e: Hide menu
|
||||
-- C-k: Toggle signature help (if signature.enabled = true)
|
||||
--
|
||||
-- See :h blink-cmp-config-keymap for defining your own keymap
|
||||
-- in your blink configuration
|
||||
keymap = {
|
||||
preset = 'none',
|
||||
keymap = {
|
||||
preset = 'none',
|
||||
|
||||
-- If completion hasn't been triggered yet, insert the first suggestion; if it has, cycle to the next suggestion.
|
||||
['<C-space>'] = { 'show', 'show_documentation', 'hide_documentation' },
|
||||
['<C-e>'] = { 'hide', 'fallback' },
|
||||
-- If completion hasn't been triggered yet, insert the first suggestion; if it has, cycle to the next suggestion.
|
||||
['<C-space>'] = { 'show', 'show_documentation', 'hide_documentation' },
|
||||
['<C-e>'] = { 'hide', 'fallback' },
|
||||
|
||||
["<Tab>"] = { "select_next", "snippet_forward", "fallback" },
|
||||
["<S-Tab>"] = { "select_prev", "snippet_backward", "fallback" },
|
||||
["<Tab>"] = { "select_next", "snippet_forward", "fallback" },
|
||||
["<S-Tab>"] = { "select_prev", "snippet_backward", "fallback" },
|
||||
|
||||
-- Selection with Enter
|
||||
["<CR>"] = { "accept", "fallback" },
|
||||
-- Selection with Enter
|
||||
["<CR>"] = { "accept", "fallback" },
|
||||
|
||||
['<Up>'] = { 'select_prev', 'fallback' },
|
||||
['<Down>'] = { 'select_next', 'fallback' },
|
||||
['<C-p>'] = { 'select_prev', 'fallback_to_mappings' },
|
||||
['<C-n>'] = { 'select_next', 'fallback_to_mappings' },
|
||||
['<Up>'] = { 'select_prev', 'fallback' },
|
||||
['<Down>'] = { 'select_next', 'fallback' },
|
||||
['<C-p>'] = { 'select_prev', 'fallback_to_mappings' },
|
||||
['<C-n>'] = { 'select_next', 'fallback_to_mappings' },
|
||||
|
||||
['<C-b>'] = { 'scroll_documentation_up', 'fallback' },
|
||||
['<C-f>'] = { 'scroll_documentation_down', 'fallback' },
|
||||
['<C-b>'] = { 'scroll_documentation_up', 'fallback' },
|
||||
['<C-f>'] = { 'scroll_documentation_down', 'fallback' },
|
||||
|
||||
['<C-k>'] = { 'show_signature', 'hide_signature', 'fallback' },
|
||||
},
|
||||
appearance = {
|
||||
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
|
||||
-- Adjusts spacing to ensure icons are aligned
|
||||
nerd_font_variant = 'mono'
|
||||
},
|
||||
|
||||
-- (Default) Only show the documentation popup when manually triggered
|
||||
completion = {
|
||||
ghost_text = {
|
||||
enabled = true
|
||||
['<C-k>'] = { 'show_signature', 'hide_signature', 'fallback' },
|
||||
},
|
||||
accept = {
|
||||
create_undo_point = true,
|
||||
auto_brackets = {
|
||||
enabled = true,
|
||||
kind_resolution = {
|
||||
enabled = true,
|
||||
},
|
||||
semantic_token_resolution = {
|
||||
appearance = {
|
||||
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
|
||||
-- Adjusts spacing to ensure icons are aligned
|
||||
nerd_font_variant = 'mono'
|
||||
},
|
||||
|
||||
-- (Default) Only show the documentation popup when manually triggered
|
||||
completion = {
|
||||
ghost_text = {
|
||||
enabled = true
|
||||
},
|
||||
accept = {
|
||||
create_undo_point = true,
|
||||
auto_brackets = {
|
||||
enabled = true,
|
||||
kind_resolution = {
|
||||
enabled = true,
|
||||
},
|
||||
semantic_token_resolution = {
|
||||
enabled = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
menu = {
|
||||
direction_priority = function()
|
||||
local ctx = require('blink.cmp').get_context()
|
||||
local item = require('blink.cmp').get_selected_item()
|
||||
if ctx == nil or item == nil then return { 's', 'n' } end
|
||||
menu = {
|
||||
direction_priority = function()
|
||||
local ctx = require('blink.cmp').get_context()
|
||||
local item = require('blink.cmp').get_selected_item()
|
||||
if ctx == nil or item == nil then return { 's', 'n' } end
|
||||
|
||||
local item_text = item.textEdit ~= nil and item.textEdit.newText or item.insertText or item.label
|
||||
local is_multi_line = item_text:find('\n') ~= nil
|
||||
local item_text = item.textEdit ~= nil and item.textEdit.newText or item.insertText or item.label
|
||||
local is_multi_line = item_text:find('\n') ~= nil
|
||||
|
||||
-- after showing the menu upwards, we want to maintain that direction
|
||||
-- until we re-open the menu, so store the context id in a global variable
|
||||
if is_multi_line or vim.g.blink_cmp_upwards_ctx_id == ctx.id then
|
||||
vim.g.blink_cmp_upwards_ctx_id = ctx.id
|
||||
return { 'n', 's' }
|
||||
end
|
||||
return { 's', 'n' }
|
||||
end,
|
||||
columns = { { "kind_icon" }, { "label", gap = 1 } },
|
||||
components = {
|
||||
-- after showing the menu upwards, we want to maintain that direction
|
||||
-- until we re-open the menu, so store the context id in a global variable
|
||||
if is_multi_line or vim.g.blink_cmp_upwards_ctx_id == ctx.id then
|
||||
vim.g.blink_cmp_upwards_ctx_id = ctx.id
|
||||
return { 'n', 's' }
|
||||
end
|
||||
return { 's', 'n' }
|
||||
end,
|
||||
draw = {
|
||||
columns = { { "kind_icon" }, { "label", gap = 1 } },
|
||||
components = {
|
||||
kind_icon = {
|
||||
text = function(ctx)
|
||||
local icon = ctx.kind_icon
|
||||
if vim.tbl_contains({ "Path" }, ctx.source_name) then
|
||||
local dev_icon, _ = require("nvim-web-devicons").get_icon(ctx.label)
|
||||
if dev_icon then
|
||||
icon = dev_icon
|
||||
end
|
||||
else
|
||||
icon = require("lspkind").symbol_map[ctx.kind] or ""
|
||||
end
|
||||
local icon = ctx.kind_icon
|
||||
if vim.tbl_contains({ "Path" }, ctx.source_name) then
|
||||
local dev_icon, _ = require("nvim-web-devicons").get_icon(ctx.label)
|
||||
if dev_icon then
|
||||
icon = dev_icon
|
||||
end
|
||||
else
|
||||
icon = require("lspkind").symbol_map[ctx.kind] or ""
|
||||
end
|
||||
|
||||
return icon .. ctx.icon_gap
|
||||
end,
|
||||
return icon .. ctx.icon_gap
|
||||
end,
|
||||
|
||||
-- Optionally, use the highlight groups from nvim-web-devicons
|
||||
-- You can also add the same function for `kind.highlight` if you want to
|
||||
-- keep the highlight groups in sync with the icons.
|
||||
highlight = function(ctx)
|
||||
local hl = ctx.kind_hl
|
||||
if vim.tbl_contains({ "Path" }, ctx.source_name) then
|
||||
local dev_icon, dev_hl = require("nvim-web-devicons").get_icon(ctx.label)
|
||||
if dev_icon then
|
||||
hl = dev_hl
|
||||
end
|
||||
end
|
||||
return hl
|
||||
end,
|
||||
-- Optionally, use the highlight groups from nvim-web-devicons
|
||||
-- You can also add the same function for `kind.highlight` if you want to
|
||||
-- keep the highlight groups in sync with the icons.
|
||||
highlight = function(ctx)
|
||||
local hl = ctx.kind_hl
|
||||
if vim.tbl_contains({ "Path" }, ctx.source_name) then
|
||||
local dev_icon, dev_hl = require("nvim-web-devicons").get_icon(ctx.label)
|
||||
if dev_icon then
|
||||
hl = dev_hl
|
||||
end
|
||||
end
|
||||
return hl
|
||||
end,
|
||||
},
|
||||
label = {
|
||||
width = { fill = true, max = 60 },
|
||||
@@ -144,40 +145,40 @@ return {
|
||||
return highlights
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
documentation = {
|
||||
auto_show = true,
|
||||
draw = function(opts)
|
||||
if opts.item and opts.item.documentation and opts.item.documentation.value then
|
||||
local out = require("pretty_hover.parser").parse(opts.item.documentation.value)
|
||||
opts.item.documentation.value = out:string()
|
||||
end
|
||||
},
|
||||
}
|
||||
},
|
||||
documentation = {
|
||||
auto_show = true,
|
||||
draw = function(opts)
|
||||
if opts.item and opts.item.documentation and opts.item.documentation.value then
|
||||
local out = require("pretty_hover.parser").parse(opts.item.documentation.value)
|
||||
opts.item.documentation.value = out:string()
|
||||
end
|
||||
|
||||
opts.default_implementation(opts)
|
||||
end,
|
||||
},
|
||||
list = {
|
||||
selection = {
|
||||
preselect = false,
|
||||
auto_insert = false
|
||||
opts.default_implementation(opts)
|
||||
end,
|
||||
},
|
||||
list = {
|
||||
selection = {
|
||||
preselect = false,
|
||||
auto_insert = 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' },
|
||||
},
|
||||
|
||||
-- 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' },
|
||||
-- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
|
||||
-- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation,
|
||||
-- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`
|
||||
--
|
||||
-- See the fuzzy documentation for more information
|
||||
fuzzy = { implementation = "prefer_rust_with_warning" },
|
||||
signature = { enabled = true }
|
||||
},
|
||||
|
||||
-- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
|
||||
-- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation,
|
||||
-- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`
|
||||
--
|
||||
-- See the fuzzy documentation for more information
|
||||
fuzzy = { implementation = "prefer_rust_with_warning" },
|
||||
signature = { enabled = true }
|
||||
},
|
||||
opts_extend = { "sources.default" }
|
||||
}
|
||||
opts_extend = { "sources.default" }
|
||||
}
|
||||
Reference in new issue
Block a user