How to configure like this


how to configure it to be like this image? i looks cool amd useful for me. How to configure the error message like in the image above?

Screenshot_2022-01-07_at_21.04.49
other example… how to add the count, icons, and custom error or warning messages?

It would be useful if it is like that

1 Like

Hi creator of this here (except someone has 1:1 created the same without me knowing)
Actually everything is just diagnostic for float (in vim.diagnostic.conf here.
Everything except the custom error messages is actually quite simple to do and also kinda stable I think.

focusable = false,
    border = border,
    scope = "cursor",
    header = { "Cursor Diagnostics:", "DiagnosticHeader" },
    pos = 1,
    prefix = function(diagnostic, i, total)
      local icon, highlight
      if diagnostic.severity == 1 then
        icon = ""
        highlight = "DiagnosticError"
      elseif diagnostic.severity == 2 then
        icon = ""
        highlight = "DiagnosticWarn"
      elseif diagnostic.severity == 3 then
        icon = ""
        highlight = "DiagnosticInfo"
      elseif diagnostic.severity == 4 then
        icon = ""
        highlight = "DiagnosticHint"
      end
      return i .. "/" .. total .. " " .. icon .. "  ", highlight
    end,

The custom message are a bit trickier and also not so stable I think.
You can specify a function with diagnostic as parameter as format option for the float config.
A diagnostic looks like this:

{
  bufnr = 1,
  col = 0,
  end_col = 1,
  end_lnum = 54,
  lnum = 54,
  message = "Global variable in lowercase initial, Did you miss `local` or misspell it?",
  namespace = 10,
  severity = 3,
  source = "Lua Diagnostics.",
  user_data = {
    lsp = {
      code = "lowercase-global"
    }
  }
}

So I just wrote some files with a lot of errors in different filetypes, searched for similar errors and grouped together the user_data.lsp.code (notice that not all servers provide this) values and put a message for each group into a table.
Then I loop through this an check if the diagnostic of the float that opens matches one of the groups and then return that message. the table
But as I said the custom messages aren’t possible for all the language servers and all have do be done manually by hand.


(the float for the diagnostic sent above)

1 Like

thanks for the help. (≧▽≦)