~nman


#5 add some config options 2 years ago

Ticket created by ~nman on ~whynothugo/lsp_lines.nvim

Hey oh The diagnostic virtual text has some options to add the source of each diagnostic as well as a callback to change the diagnostic before it is displayed. I use the latter to filter by new lines so that diagnostics which have multiple lines only display the first one. No such options are exported in the plugin. I added them if you are interested you can have a look. I don't know how to add diffs here so I'll do it the old fashioned way

Line 59:

local prefix = opts.virtual_lines.prefix or "▼"
local use_source = opts.virtual_lines.source or false
local truncate_new_line = opts.virtual_lines.truncate_new_line or false

Line 62:

local source = string.lower(use_source and diagnostic.source or "")

Line 74:

{              
  string.format("%s %s %s", lprefix, source, diag_line),
  highlight_groups[diagnostic.severity],
}

Line 79:

if truncate_new_line then
  break
end

That's it. It is now possible to do:

vim.diagnostic.config({
  virtual_text = false,
  virtual_lines = {
    source = true,
    truncate_new_line = true
  }
})

Thanks for the plugin it's very helpful