j-hui / fidget.nvim

💫 Extensible UI for Neovim notifications and LSP progress messages.
MIT License
1.99k stars 59 forks source link

feat: Add max-width for messages #199

Open USER-5 opened 10 months ago

USER-5 commented 10 months ago

Particularly when used in combination with java (https://github.com/mfussenegger/nvim-jdtls), a lot of the messages are quite wide - it would be nice to truncate some of these messages so they don't display on top of the code (especially since they appear while typing, not just upon save / load).

j-hui commented 10 months ago

For completeness, can you give an example of these messages?

In particular, I'd like to know whether it's the annote or the message field that is too wide.

j-hui commented 10 months ago

In 09f0c91d23c3e5939f79c80be2e7bc448d3cbc7d I introduced a new option, render_message, which you can use to truncate messages as you see fit, e.g.,:

render_message = function(msg, cnt)
  msg = cnt == 1 and msg or string.format("(%dx) %s", cnt, msg)
  msg = vim.fn.strcharpart(msg, 0, 16) -- truncate to 16 characters
  return msg
end

Does this suffice? (Admittedly, it does not account for newlines, nor does it do anything about the annote part.)

USER-5 commented 10 months ago

It's usually the text on the left that is too long (can include URLs, etc.).

I haven't tried a custom formatter yet - I'm a little hesitant to add in-depth custom config myself... image