Skip to content

sticky prompts provided to open() do not appear in chat window #1475

@garcia5

Description

@garcia5

Description

When I open the chat window with a sticky prompt specified in the config I pass in, those sticky messages are not shown in the chat window. This appears to be related to 1ff0bb3

Reproducer

:lua require("CopilotChat").open({ sticky = { "@copilot", "A custom sticky message" } })

Current Behavior

Image

Expected Behavior

Image

Config

local chat = {
    "CopilotC-Nvim/CopilotChat.nvim",
    branch = "main",
    dependencies = {
        { "zbirenbaum/copilot.lua" },
        { "nvim-lua/plenary.nvim" },
    },
    build = "make tiktoken",
    opts = {
        debug = false,
        model = "claude-sonnet-4", -- default model
        auto_insert_mode = false, -- Automatically enter insert mode when opening window and on new prompt
        insert_at_end = false, -- Move cursor to end of buffer when inserting text
        remember_as_sticky = true,
        diff = "block", -- default to markdown diff blocks
        sticky = { "@copilot" }, -- automatically use copilot tools in every sesssion
        -- open window in right 1/3rd of window
        window = {
            layout = "vertical",
            width = 0.3,
            title = " Copilot Chat",
        },
        headers = {
            user = "󰀉 User",
            assistant = "󰚩 Assistant",
            tool = "󱁤 Tool",
        },
        -- Use render-markdown for nicer rendering
        highlight_headers = true,
        separator = "---",
        error_header = "> [!ERROR] Error",
        -- custom prompts
        prompts = {
            PythonExpert = {
                system_prompt = "You are an expert Python developer with knowledge of language best practices, helping an experienced software engineer in their day to day work",
            },
        },
        -- custom mappings within copilot chat buffer
        mappings = {
            submit_prompt = {
                normal = "<CR>",
                insert = "<C-y>",
            },
            accept_diff = {
                normal = "<C-s>",
                insert = "<C-s>",
            },
            -- make it hard to accidentally reset the chat
            reset = {
                normal = "ggr",
                insert = "<C-r><C-y>",
            },
        },
    },
    keys = {
        {
            "<Leader>co",
            function()
                local config = {}
                if vim.bo.filetype == "python" then config.sticky = {"@copilot", "/PythonExpert"} end
                require("CopilotChat").open(config) end,
            mode = { "n", "v" },
        },
    },
    cmd = {
        "CopilotChat",
        "CopilotChatOpen",
        "CopilotChatToggle",
        "CopilotChatExplain",
        "CopilotChatReview",
        "CopilotChatFix",
        "CopilotChatOptimize",
        "CopilotChatDocs",
        "CopilotChatTests",
        "CopilotChatFixDiagnostic",
        "CopilotChatCommit",
        "CopilotChatCommitStaged",
        "CopilotChatModels",
        "CopilotChatLoad",
    },
    init = function()
        vim.api.nvim_create_autocmd("BufEnter", {
            pattern = "copilot-*",
            callback = function()
                vim.opt_local.relativenumber = false
                vim.opt_local.number = false
            end,
        })
    end,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions