-
Notifications
You must be signed in to change notification settings - Fork 66
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
offer markdown highlighting in aichat files #83
base: main
Are you sure you want to change the base?
Conversation
Markdown highlighting within aichat files is controlled by a global variable `g:aichat_markdown`. The Vim documentation and the syntax file for aichat have been updated. Markdown highlighting is disabled by default when editing .aichat files, but can be enabled by a user variable.
The output is often markdown with code in codeblock. For highlighting, including codeblocks, just reuse that of |
Yes, the screenshot is taken with |
Yes. What is the correct syntax highlighting for the user input? One could explicitly override it, but in practice it is often simple text. This is just a suggestion that seems more maintainable than the |
Regarding the correct highlighting of the user input, an idea could have been to add code fence markers for the current file type, except for text selected in a comment syntax region. However, in the end, users might rather (ab)use the source code file as a scratchpad for sending text into the chat, so that this assumption is perhaps a bit patronizing. |
I am not sure is syntax highlighting of the user input is needed. If you for instance use ChatGPT on web, you cannot use formatting your prompt. And it wouldn't make any difference to the model too. I would say formatting code blocks should be enough but I might be wrong |
I agree with you. |
diff --git a/syntax/aichat.vim b/syntax/aichat.vim: -syntax region myRegion start=/>>>.*$\zs/ end=/\ze<<<.*$/ -highlight default link myRegion Normal -
User input is now using default highlighting, whereas the output uses built-in markdown highlighting, in particular for the fenced code blocks. |
Still having the same issue (see screenshot in the comments above). I think you tried to fix it with >>> <<<, that that' boundary isn't respected in my environment |
This is somewhat to be expected, as I had the impression that |
Yes, I think that this solution is much better and I would like to replace the current highlighting with this one. But first I need to get this working. I have found that there is a conflict with the plugin preservim/vim-markdown that I use, which causes the weird highlighting I posted in the screenshot. |
Hard to say from afar, but https://github.com/preservim/vim-markdown/blob/a657e697376909c41475a686eeef7fc7a4972d94/ftplugin/markdown.vim#L789 shows that this also does what the built-in markdown ftplugin tries to achieve, so a careful setup is needed to avoid mutual interference |
Maybe this way around the highlighting is more robust? |
See madox2/vim-ai#83 Signed-off-by: Gabriel Linder <linder.gabriel@gmail.com>
I came here wanting to do the same thing, thanks for your diff it works flawlessly for me ! |
Markdown highlighting within aichat files is controlled by a global variable
g:aichat_markdown
.The Vim documentation and the syntax file for aichat have been updated. Markdown highlighting is disabled by default when editing .aichat files, but can be enabled by a user variable.