Skip to content

feature: add custom icons for html like files in codecompanion #336

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

Closed
petobens opened this issue Feb 18, 2025 · 3 comments
Closed

feature: add custom icons for html like files in codecompanion #336

petobens opened this issue Feb 18, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@petobens
Copy link

petobens commented Feb 18, 2025

Is your feature request related to a problem? Please describe.

When adding files to the chat buffer in codecompanion they look like this:

Image

Describe the solution you'd like

I was wondering whether it was possible to replace the <file>...</file>, <buf>...</buf> and <url>...</url> with some fancy icons.

Describe alternatives you've considered

Additional information

No response

@petobens petobens added the enhancement New feature or request label Feb 18, 2025
MeanderingProgrammer added a commit that referenced this issue Feb 20, 2025
## Details

Request: #336

By default no tags are configured so nothing happens.

If matching tags are found the start & end tags get concealed and the
configured icon / highlight are inlined at the start.

Example configuration:

```lua
require('render-markdown').setup({
    html = {
        tag = {
            file = { icon = '󰨸 ', highlight = 'Normal' },
        },
    },
})
```
@MeanderingProgrammer
Copy link
Owner

Added here: 6d446de

You can configure something like:

require('render-markdown').setup({
    html = {
        tag = {
            file = { icon = '󰨸 ', highlight = 'Normal' },
        },
    },
})

To modify the file tags.

You can do something similar for buf & url.

The value for icon and highlight can be whatever you want.

@petobens
Copy link
Author

petobens commented Mar 2, 2025

Hi @MeanderingProgrammer! Sorry for the terribly late reply. Mmm from what I reckon the codecompanion chat doesn't render those <file>...</file>, <buffer>.. </buffer> etc tags as html so your solution doesn't quite work (though it clearly is the the natural way of doing it). I guess a followup question/request would then be if it possible to add custom icons for a particular regex in a specific filetype. Something along the lines of:

overrides = {
    filetype = {
        codecompanion = {
            regex = {
                custom = {
                    file_tag = {
                        pattern = '<file_tag_regex>',
                        icon = 'some_icon ',
                        background = 'some_hl',
                    },
                },
            },
        },
    },
}

@MeanderingProgrammer
Copy link
Owner

codecompanion doesn't need to do anything to have them be "rendered as html".

This just comes from treesitter, in particular support for injecting html for tags: https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/markdown_inline/injections.scm

The only thing you need to make this work is to have the html parser installed: :TSInstall html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants