Skip to content
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

Complete the source issue #183

Closed
Tridays opened this issue Dec 5, 2024 · 1 comment
Closed

Complete the source issue #183

Tridays opened this issue Dec 5, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Tridays
Copy link

Tridays commented Dec 5, 2024

In this file, 'dressing. nvim/lua/pressing/input.lua'
The source for completion is sources, which should be added by the user themselves. The suggestion is: sources=opts.source. If it is empty, use the built-in completion source

--------------------------------------------------------------------------------------------------input.lua
-- Configure nvim-cmp if installed
local has_cmp, cmp = pcall(require, "cmp")
if has_cmp then
cmp.setup.buffer({
enabled = opts.completion ~= nil,
sources = {
{ name = "omni" }, --Hard coding, this is very unfriendly
},
})
end


for example:

vim.ui.input({
prompt = "Title",
completion = true, --Activate completion function
sources = {“path”, "buffer"},--Set more sources
telescope = require("telescope.themes").get_cursor(),
},
function(input)
print(input)
end)

@Tridays Tridays added the bug Something isn't working label Dec 5, 2024
@stevearc
Copy link
Owner

The reason it is hard coded to omni is because we also set omnifunc when a completion argument is passed to vim.ui.input.

if opts.completion then
vim.bo[bufnr].completefunc = "v:lua.require'dressing.input'.completefunc"
vim.bo[bufnr].omnifunc = "v:lua.require'dressing.input'.completefunc"

This is what allows the callsite for vim.ui.input to customize the completion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants