telescope.nvim
telescope.nvim copied to clipboard
feat(diagnosticts): add option to show the source of the entry
Description
Adds option to show LSP source to diagnostics picker. It's useful when you work on a multilanguage project.
Fixes https://github.com/nvim-telescope/telescope.nvim/issues/2544 Fixes https://github.com/nvim-telescope/telescope.nvim/issues/2110
Type of change
- New feature (non-breaking change which adds functionality)
- This change requires a documentation update
How Has This Been Tested?
- [x]
:lua require('telescope.builtin').diagnostics({ show_source = true })
In the end of every result there should be the source that created the entry
Configuration:
- Neovim version (nvim --version): v0.10.2
- Operating system and version: Ubuntu 24.04.1 LTS
Checklist:
- [x] My code follows the style guidelines of this project (stylua)
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation (lua annotations)
Any updates on this? It is a very desirable feature to know the source of the diagnostic. Thanks.
Looks like it's a quite demanded feature, is there something wrong with this PR? It's super simple and provides the feature, it can always be improved later, having it is better than not...
I could really use this - any idea of when/if it is going to be enabled? Otherwise any workarounds I could implement today?
Workaround that I have found:
In lua/telescope/builtin/__diagnostics.lua, you could change this:
text = vim.trim(diagnostic.message:gsub("[\n]", ""))
to this
text = string.format("[%s] %s", diagnostic.source, vim.trim(diagnostic.message:gsub("[\n]", "")))
which adds the diagnostic source to the start of the diagnostic message. There might be some issues with line_width but this is just a temporary fix that anyone could implement