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

bug: markdown syntax highlighting doesn't work in chat #602

Open
matthewblott opened this issue Sep 18, 2024 · 12 comments
Open

bug: markdown syntax highlighting doesn't work in chat #602

matthewblott opened this issue Sep 18, 2024 · 12 comments
Labels
bug Something isn't working

Comments

@matthewblott
Copy link

Describe the bug

I have a pretty bland looking chat with no colours for the code snippets:

Screenshot 2024-09-18 at 00 59 38

To reproduce

Open the chat window and type a command.

Expected behavior

Avante produced code to have proper syntax highlighting.

Environment

NVIM v0.10.1
Build type: Release
LuaJIT 2.1.1720049189
OS: macOS 14.5

Repro

require('user.plugins')
require('user.config')
@matthewblott matthewblott added the bug Something isn't working label Sep 18, 2024
@aarnphm
Copy link
Collaborator

aarnphm commented Sep 18, 2024

can you provide a reproducer? that is actually not a reproducer

@matthewblott
Copy link
Author

matthewblott commented Sep 18, 2024

Okay. I've tried a fresh install with a bare bones configuration and lazy.nvim installed at ${HOME}/.local/share/nvim/lazy.nvim. The result is the same. Here is the init.lua config in full:

local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'

if not vim.loop.fs_stat(lazypath) then
  vim.fn.system {
    'git',
    'clone',
    '--filter=blob:none',
    'https://github.com/folke/lazy.nvim.git',
    '--branch=stable', -- latest stable release
    lazypath,
  }
end

vim.opt.rtp:prepend(lazypath)

require('lazy').setup({
  {
    'yetone/avante.nvim',
    event = 'VeryLazy',
    lazy = false,
    version = false, 
    opts = {
      provider = "openai",
    },
    build = 'make BUILD_FROM_SOURCE=true',
    dependencies = {
      'stevearc/dressing.nvim',
      'nvim-lua/plenary.nvim',
      'MunifTanjim/nui.nvim',
      {
        'MeanderingProgrammer/render-markdown.nvim',
        opts = {
          file_types = { 'markdown', 'Avante' },
        },
        ft = { 'markdown', 'Avante' },
      },
    },
  },

}) 

vim.wo.number = true
vim.wo.relativenumber = true
vim.opt.expandtab = true
vim.opt.clipboard = 'unnamedplus'

vim.g.mapleader = ' '

I tried to keep everything to a minimum. I also tried the config as suggested on the homepage of this site.

@ddillert
Copy link
Contributor

Have you tested with other languages? If they work, could you try running :TSInstall ruby? This command installs the Tree-sitter plugin for Ruby.

@matthewblott
Copy link
Author

I've tried a few languages, it's the same issue for all of them. I've tried with Treesiter and without and the result is the same 🤷‍♂️

@saifulapm
Copy link

Same also here..

@radwo
Copy link
Contributor

radwo commented Nov 25, 2024

Does it work for other *.md files? I had the same issue and was missing the markdown parser for treesitter.

@yetone
Copy link
Owner

yetone commented Nov 26, 2024

:TSInstall markdown may be help

@saifulapm
Copy link

I have TS installed for markdown and markdown_inline

my plugin config

{
    "yetone/avante.nvim",
    version = "*",
    build = "make",
    cmd = "AvanteChat",
    opts = {
      provider = "copilot",
    },
  }
{
    "MeanderingProgrammer/render-markdown.nvim",
    opts = {
      file_types = { "markdown", "Avante", "codecompanion", "AvanteInput" },
      code = {
        position = "right",
      },
    },
    ft = { "markdown", "Avante", "codecompanion", "AvanteInput" },
  }

You can check this video:

Screen.Recording.2024-11-26.at.11.20.08.AM.mov

I am having same issue for codecompanion also. But on copilot-chat, syntax highlight working good. I don;t know when not working for Avante and codecompanion.

Any Idea ?

@malkoG
Copy link

malkoG commented Nov 30, 2024

Did you open to check markdown files?
I also facing this issue and code block inside markdown is not properly highlighted.

I think this is render-markdown.nvim's issue

@devstefancho
Copy link

In my case, I can't not reproduce this issue, Could you share render-markdown commit version?
Fyi, my commit version in lazy-lock.json

"avante.nvim": { "branch": "main", "commit": "71c9a7911b9cd91c946f22099a515bb495a4b256" },
"render-markdown.nvim": { "branch": "main", "commit": "82184c4a3c3580a7a859b2cb7e58f16c10fd29ef" },

@theahura
Copy link

theahura commented Dec 4, 2024

I am also struggling with this.

At first I thought it was my render-markdown.nvim package, because opening a standard *.md file would show the same non-highlighting. I was able to fix this by adding the following explicitly:

vim.opt.syntax = "on"
vim.g.markdown_fenced_languages = {'Avante', 'python', 'javascript', 'html', 'bash', 'sh'}

However, this did not fix the in-chat behavior of the markdown plugin. In chat, I was still getting no syntax highlighting for languages.

As we would expect, the set ifletype? command shows the file is of type Avante. Same with echo b:current_syntax. Setting the syntax to markdown explicitly (using set syntax=markdown) or to the markdown filetype (using set filetype=markdown) didn't fix the problem unfortunately.

As a last attempt, I copied the entire chat buffer into a markdown file to see what would happen. Interestingly this DID screw up the syntax highlighting. On further inspection, it looks like something weird is going on in the interaction between the markdown > quote block and the multiline syntax-highlighted code block. More investigation required...

@theahura
Copy link

theahura commented Dec 5, 2024

Filed a potentially related bug on render-markdown.nvim -- MeanderingProgrammer/render-markdown.nvim#249

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

9 participants