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

feat: extend builtin diagnostic to allow displayed text customization #3281

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dansdantas
Copy link

This extends builtin.diagnostic opts, allowing to use a custom function. Solves #2544

@jamestrew
Copy link
Contributor

How does this resolve #2544?

@dansdantas
Copy link
Author

dansdantas commented Sep 19, 2024

When writing a diagnostic picker, allow to pass a function in the text option that formats how text is displayed on the picker. First argument for that function is the diagnostic, allowing to add source into the displayed text. Then you can filter like normally you would do with telescope.

require('telescope.builtin').diagnostics({
    text = function(diagnostic)
        return vim.trim(diagnostic.message:gsub("[\n]", "") .. " (" .. diagnostic.source .. ")")
    end,
})

@jamestrew
Copy link
Contributor

I think I would prefer we just implement that as oppose to adding a mechanism that allows people the option to implement it.

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

Successfully merging this pull request may close these issues.

2 participants