jellydn / CopilotChat.nvim

Chat with GitHub Copilot in Neovim
GNU General Public License v3.0
100 stars 9 forks source link

Syntax highlighting not working in Copilot chat #46

Closed k-martynov closed 8 months ago

k-martynov commented 8 months ago

Describe the bug

When I am using Copilot, my syntax highlighting is not working. What am I doing wrong? Here is my configuration:

  {
    "jellydn/CopilotChat.nvim",
    branch = "canary",
    dependencies = { "zbirenbaum/copilot.lua" },
    opts = {
      mode = "split",
      debug = false,
      prompts = {
        Explain = "Explain how it works.",
        Review = "Review the following code and provide concise suggestions.",
        Tests = "Briefly explain how the selected code works, then generate unit tests.",
        Refactor = "Refactor the code to improve clarity and readability.",
        Spelling = "Please correct any grammar and spelling errors in the following text.",
        Wording = "Please improve the grammar and wording of the following text.",
      },
    },
    build = function()
      vim.defer_fn(function()
        vim.cmd("UpdateRemotePlugins")
        vim.notify("CopilotChat - Updated remote plugins. Please restart Neovim.")
      end, 3000)
    end,
    event = "VeryLazy",
    keys = {
      { "<leader>cce", "<cmd>CopilotChatExplain<CR>",  desc = "CopilotChat - Explain code" },
      { "<leader>cct", "<cmd>CopilotChatTests<CR>",    desc = "CopilotChat - Generate tests" },
      { "<leader>ccr", "<cmd>CopilotChatReview<CR>",   desc = "CopilotChat - Review code" },
      { "<leader>ccR", "<cmd>CopilotChatRefactor<CR>", desc = "CopilotChat - Refactor code" },
      { "<leader>ccS", "<cmd>CopilotChatSpelling<CR>", desc = "CopilotChat - Correct spelling" },
      { "<leader>ccw", "<cmd>CopilotChatWording<CR>",  desc = "CopilotChat - Improve wording" },
    },
  },
Screenshot 2024-02-02 at 17 57 28

Reproduction

default config

System Info

System:
    OS: macOS 14.3
    CPU: (8) arm64 Apple M1 Pro
    Memory: 88.34 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.2.0 - ~/.nvm/versions/node/v21.2.0/bin/node
    Yarn: 1.22.21 - ~/.nvm/versions/node/v21.2.0/bin/yarn
    npm: 10.2.3 - ~/.nvm/versions/node/v21.2.0/bin/npm
  Browsers:
    Chrome: 121.0.6167.139
    Firefox: 120.0.1
    Safari: 17.3

Used Package Manager

yarn

Validations

jellydn commented 8 months ago

Hi @k-martynov, thanks for your report. I just tried with main branch. Your screenshot seems a old version.

Image from Gyazo

Could you try with below config? Please make sure that you run :UpdateRemotePlugins after update the plugin.

  {
    "jellydn/CopilotChat.nvim",
    dependencies = { "zbirenbaum/copilot.lua" },
    opts = {
      debug = false,
      prompts = {
        Explain = "Explain how it works.",
        Review = "Review the following code and provide concise suggestions.",
        Tests = "Briefly explain how the selected code works, then generate unit tests.",
        Refactor = "Refactor the code to improve clarity and readability.",
        Spelling = "Please correct any grammar and spelling errors in the following text.",
        Wording = "Please improve the grammar and wording of the following text.",
      },
    },
    build = function()
      vim.notify("Please update the remote plugins by running ':UpdateRemotePlugins', then restart Neovim.")
    end,
    event = "VeryLazy",
    keys = {
      { "<leader>cce", "<cmd>CopilotChatExplain<CR>",  desc = "CopilotChat - Explain code" },
      { "<leader>cct", "<cmd>CopilotChatTests<CR>",    desc = "CopilotChat - Generate tests" },
      { "<leader>ccr", "<cmd>CopilotChatReview<CR>",   desc = "CopilotChat - Review code" },
      { "<leader>ccR", "<cmd>CopilotChatRefactor<CR>", desc = "CopilotChat - Refactor code" },
      { "<leader>ccS", "<cmd>CopilotChatSpelling<CR>", desc = "CopilotChat - Correct spelling" },
      { "<leader>ccw", "<cmd>CopilotChatWording<CR>",  desc = "CopilotChat - Improve wording" },
    },
  },
k-martynov commented 8 months ago

@jellydn I've used your config but the result still the same:

Screenshot 2024-02-02 at 18 43 07
jellydn commented 8 months ago

Do you run UpdateRemotePlugins command restart Neovim? @k-martynov

k-martynov commented 8 months ago

@jellydn yes

jellydn commented 8 months ago

By the way, what is your Neovim version?