Skip to content

No completions inside brackets () in zig code #176

@NicoElbers

Description

@NicoElbers

I get no completions when inside brackets (). I checked with cmp and there I do get completions, with the same code and the same characters typed.

Interestingly, if I try to reproduce this behavior in lua, everything works fine. But in zig code I don't get completions.

tested languages
language completions inside ()
lua yes
zig no
typescript no
rust yes

Left is blink, right is cmp:
image

If I remove the () completions work as expected.

blink config
return {
    "saghen/blink.cmp",
    event = "InsertEnter",

    -- optional: provides snippets for the snippet source
    dependencies = { "rafamadriz/friendly-snippets" },

    version = "v0.*",

    opts = {
        keymap = {
            show = "<C-s>",
            hide = "<C-e>",

            show_documentation = "<C-s>",
            hide_documentation = "<C-s>",

            accept = "<C-space>",

            select_next = "<C-n>",
            select_prev = "<C-p>",

            snippet_forward = "<C-n>",
            snippet_backward = "<C-p>",
        },

        highlight = {
            -- sets the fallback highlight groups to nvim-cmp's highlight groups
            -- useful for when your theme doesn't support blink.cmp
            -- will be removed in a future release, assuming themes add support
            use_nvim_cmp_as_default = true,
        },

        -- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
        -- adjusts spacing to ensure icons are aligned
        nerd_font_variant = "mono",

        accept = {
            auto_brackets = {
                enabled = true,
            },
        },

        trigger = {
            signature_help = {
                enabled = true,
            },
            completion = {
                show_in_snippet = true,
            },
        },

        windows = {
            autocomplete = {
                border = utils.border,
                draw = "reversed",
            },
            documentation = {
                border = utils.border,
                auto_show = true,
                auto_show_delay_ms = 0,
            },
            signature_help = {
                border = utils.border,
            },
        },
    },
}
cmp config
return {
    {
        "hrsh7th/nvim-cmp",
        enabled = true,
        event = "InsertEnter",
        dependencies = {
            {
                "L3MON4D3/LuaSnip",
                dependencies = { "rafamadriz/friendly-snippets" },
                config = function()
                    require("luasnip.loaders.from_vscode").lazy_load()
                end,
            },
            "hrsh7th/cmp-nvim-lsp",
            "saadparwaiz1/cmp_luasnip",
            "L3MON4D3/LuaSnip",
            "hrsh7th/cmp-nvim-lua",
            "hrsh7th/cmp-nvim-lsp-signature-help",
            "hrsh7th/cmp-path",
            "hrsh7th/cmp-buffer",
        },
        config = function()
            local cmp = require("cmp")
            local luasnip = require("luasnip")

            cmp.setup({
                snippet = {
                    expand = function(args)
                        luasnip.lsp_expand(args.body)
                    end,
                },
                window = {
                    completion = cmp.config.window.bordered(),
                    documentation = cmp.config.window.bordered(),
                },
                mapping = cmp.mapping.preset.insert({
                    ["<C-d>"] = cmp.mapping.scroll_docs(-4),
                    ["<C-f>"] = cmp.mapping.scroll_docs(4),
                    ["<C-space>"] = cmp.mapping.confirm({
                        behavior = cmp.ConfirmBehavior.Replace,
                        select = true,
                    }),
                    ["<C-n>"] = cmp.mapping(function(fallback)
                        if cmp.visible() then
                            cmp.select_next_item()
                        elseif luasnip.expand_or_locally_jumpable() then
                            luasnip.expand_or_jump()
                        else
                            fallback()
                        end
                    end, { "i", "s" }),
                    ["<C-p>"] = cmp.mapping(function(fallback)
                        if cmp.visible() then
                            cmp.select_prev_item()
                        elseif luasnip.locally_jumpable(-1) then
                            luasnip.jump(-1)
                        else
                            fallback()
                        end
                    end, { "i", "s" }),
                }),
                sources = cmp.config.sources({
                    { name = "path" },
                    { name = "nvim_lsp" },
                    { name = "nvim_lsp_signature_help" },
                    { name = "luasnip" },
                    { name = "nvim_lua" },
                    { name = "buffer" },
                    { name = "calc" },
                }, {}),
            })
        end,
    },
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions