-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion to simplify source.provider
config
#144
Comments
Yeah, totally agree with you, I've got a few commits locally implementing this: sources = {
--- @type string[] | fun(ctx: blink.cmp.Context): string[]
completion = { 'lsp', 'path', 'buffer', 'snippets' }
cmdline = { 'commands', 'path' }
search = { 'buffer' },
providers = {
lsp = {
--- @type string
name = 'LSP',
--- @type string
module = 'blink.cmp.sources.lsp',
--- @type fun(ctx: blink.cmp.Context)
enabled = true,
--- @type table
opts = {}
--- @type fun(ctx: blink.cmp.Context, items: blink.cmp.Item[]): blink.cmp.Item[]
transform_items = nil,
--- @type fun(ctx: blink.cmp.Context, items: blink.cmp.Item[]): boolean
should_show_items = nil,
--- @type number | fun(ctx: blink.cmp.Context, items: blink.cmp.Item[]): boolean
max_items = nil,
--- @type number
min_keyword_length = nil,
--- @type string[] | fun(ctx: blink.cmp.Context, enabled_sources: string[]): string[]
fallback_for = {},
--- @type number | fun(ctx: blink.cmp.Context, enabled_sources: string[]): number
score_offset = 0,
-- override any builtin function of the source
override = { ... },
},
path = { ... },
buffer = { ... },
snippets = { ... }
},
} Not settled on this though so feedback is welcome |
just giving some ideas sources_list = {
'lsp',
'path',
'snippets',
'buffer',
},
sources = {
snippets = {
opts = {
search_paths = { '/my/snippets' },
},
},
},
-- is "auto" in "autocompletion" a bit too much?
sources_completion = { "lsp", "path", "snippet", "buffer" },
sources_cmdline = {
[":"] = { "cmdline" },
["/"] = { "buffer" },
["?"] = { "buffer" },
},
sources_by_ft = {
gitcommit = { "git" },
} blink will search for sources in local source = {}
source.name = "LSP"
function source.new()
return setmetatable({}, { __index = source })
end |
Saghen
added a commit
that referenced
this issue
Oct 24, 2024
mikavilpas
added a commit
to mikavilpas/blink.cmp
that referenced
this issue
Nov 26, 2024
No references to this field are left, so it looks like it was left behind from the issue Saghen#144 and closed by the commit in that issue, Saghen@7fea65c
Saghen
pushed a commit
that referenced
this issue
Nov 26, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The problem
As some issues (e.g., #132) or discussions on reddit show, the current way to configure sources appears to be confusing to some users. I think the problem derives from the fact that
sources.providers
is a list and not a dictionary.Using lists of non-primitives is somewhat counterintuitive for many people, since the way
vim.tbl_deep_extend()
works, you need to copypaste the whole list if you want to adjust one property in one of the list elements. This leads to confusions, as can be seen in #132. Using lists of non-primitives is a pretty rare occurrence in nvim plugins to begin with, probably due to this problem.Other than being less intuitive, the need to specify the full list unnecessarily creates the need to copy a lot of default configs, even if you intend to only change one detail. Furthermore, exposing
"blink.cmp.sources.lsp"
to the user feels unnecessary to me, just referring to a source via its name"LSP"
should be enough?Suggested change
I suggest using a dict to configure the individual sources, something like this:
Comparison of the current config and the suggested change
If a user just wants to specify the path to their snippet folder, but not change anything else regarding
blink.cmp
's default config, their config currently will have to look like this:With the suggested change, they only need to do this:
The text was updated successfully, but these errors were encountered: