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

Completion function parameter only inserts first word #40

Open
Denomycor opened this issue Jul 25, 2023 · 1 comment
Open

Completion function parameter only inserts first word #40

Denomycor opened this issue Jul 25, 2023 · 1 comment

Comments

@Denomycor
Copy link

Hi, I've started to use this source to get function overloads while working with c++. However, When I trigger the completion of the parameters of a function only the first word gets inserted:

image

image

Please tell me which information do you need to troubleshoot this issue, Thanks for your help!

@oleksiivelychko
Copy link

oleksiivelychko commented Jan 26, 2025

I faced with the same problem, bur for PHP, and after research I managed to achieve these by adding these settings inside my existing configuration:

cmp.setup.filetype('php', {
    mapping = {
        ['<CR>'] = cmp.mapping(function(fallback)
            local selected_entry = cmp.get_selected_entry()

            if selected_entry and selected_entry.source.name == 'nvim_lsp_signature_help' then

                if selected_entry.completion_item.label:match("%s") then
                    local varType, varValue = selected_entry.completion_item.label:match("^(%S+)%s+(%S+)$")

                    if varValue then
                        vim.api.nvim_put({varValue}, 'c', true, true)
                    end
                else
                    vim.api.nvim_put({selected_entry.completion_item.label}, 'c', true, true)
                end
            else
                cmp.mapping.confirm({ select = true })(fallback)
            end
        end, { 'i', 's' }),
    }
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants