Skip to content

Commit

Permalink
fix(blink-cmp): improve command line completion
Browse files Browse the repository at this point in the history
  • Loading branch information
mehalter committed Jan 2, 2025
1 parent 31e12fd commit 3be4148
Showing 1 changed file with 8 additions and 32 deletions.
40 changes: 8 additions & 32 deletions lua/astrocommunity/completion/blink-cmp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ end

local function get_icon_provider()
local _, mini_icons = pcall(require, "mini.icons")
if _G.MiniIcons then
return function(kind) return mini_icons.get("lsp", kind or "") end
end
if _G.MiniIcons then return function(kind) return mini_icons.get("lsp", kind or "") end end
local lspkind_avail, lspkind = pcall(require, "lspkind")
if lspkind_avail then
return function(kind) return lspkind.symbolic(kind, { mode = "symbol" }) end
end
if lspkind_avail then return function(kind) return lspkind.symbolic(kind, { mode = "symbol" }) end end
end
---@type function|false|nil
local icon_provider = false
Expand Down Expand Up @@ -46,10 +42,6 @@ return {
-- remember to enable your providers here
sources = {
default = { "lsp", "path", "snippets", "buffer" },
min_keyword_length = function(ctx)
if ctx.mode == "cmdline" and string.find(ctx.line, " ") == nil then return 2 end
return 0
end,
},
keymap = {
["<C-Space>"] = { "show", "show_documentation", "hide_documentation" },
Expand All @@ -64,29 +56,17 @@ return {
["<C-e>"] = { "hide", "fallback" },
["<CR>"] = { "accept", "fallback" },
["<Tab>"] = {
"select_next",
"snippet_forward",
function(cmp)
if cmp.is_visible() then
return cmp.select_next()
elseif cmp.snippet_active { direction = 1 } then
return cmp.snippet_forward()
elseif has_words_before() then
return cmp.show()
end
end,
"fallback",
},
["<S-Tab>"] = {
function(cmp)
if cmp.is_visible() then
return cmp.select_prev()
elseif cmp.snippet_active { direction = -1 } then
return cmp.snippet_backward()
end
if has_words_before() then return cmp.show() end
end,
"fallback",
},
["<S-Tab>"] = { "select_prev", "snippet_backward", "fallback" },
},
completion = {
list = { selection = function(ctx) return ctx.mode == "cmdline" and "auto_insert" or "preselect" end },
menu = {
border = "rounded",
winhighlight = "Normal:NormalFloat,FloatBorder:FloatBorder,CursorLine:PmenuSel,Search:None",
Expand Down Expand Up @@ -125,10 +105,7 @@ return {
{
"AstroNvim/astrolsp",
optional = true,
opts = function(_, opts)
opts.capabilities =
require("astrocore").extend_tbl(opts.capabilities, require("blink.cmp").get_lsp_capabilities())
end,
opts = function(_, opts) opts.capabilities = require("blink.cmp").get_lsp_capabilities(opts.capabilities) end,
},
{
"folke/lazydev.nvim",
Expand All @@ -155,7 +132,6 @@ return {
-- disable built in completion plugins
{ "hrsh7th/nvim-cmp", enabled = false },
{ "rcarriga/cmp-dap", enabled = false },
{ "petertriho/cmp-git", enabled = false },
{ "L3MON4D3/LuaSnip", enabled = false },
{ "onsails/lspkind.nvim", enabled = false },
},
Expand Down

0 comments on commit 3be4148

Please sign in to comment.