diff options
| author | kylo252 <[email protected]> | 2021-07-31 14:52:25 +0200 | 
|---|---|---|
| committer | GitHub <[email protected]> | 2021-07-31 12:52:25 +0000 | 
| commit | f36082da0dccf4cfc50dd3fec271b7a5cd41aaea (patch) | |
| tree | 8e312e6cda690e5e4aaf158cef70ddc4223705cb /lua/lsp | |
| parent | 679b8b69fb0ee8c5249a416845054a1734815d43 (diff) | |
feat: add diagnostics source name (#1147)
Diffstat (limited to 'lua/lsp')
| -rw-r--r-- | lua/lsp/handlers.lua | 34 | 
1 files changed, 34 insertions, 0 deletions
| diff --git a/lua/lsp/handlers.lua b/lua/lsp/handlers.lua index d3a487ae..3a467d42 100644 --- a/lua/lsp/handlers.lua +++ b/lua/lsp/handlers.lua @@ -9,6 +9,40 @@ function M.setup()      underline = lvim.lsp.document_highlight,    }) +  vim.lsp.handlers["textDocument/publishDiagnostics"] = function(_, _, params, client_id, _) +    local config = { -- your config +      virtual_text = lvim.lsp.diagnostics.virtual_text, +      signs = lvim.lsp.diagnostics.signs, +      underline = lvim.lsp.diagnostics.underline, +      update_in_insert = lvim.lsp.diagnostics.update_in_insert, +      severity_sort = lvim.lsp.diagnostics.severity_sort, +    } +    local uri = params.uri +    local bufnr = vim.uri_to_bufnr(uri) + +    if not bufnr then +      return +    end + +    local diagnostics = params.diagnostics + +    for i, v in ipairs(diagnostics) do +      diagnostics[i].message = string.format("%s: %s", v.source, v.message) + +      if vim.tbl_contains(vim.tbl_keys(v), "code") then +        diagnostics[i].message = diagnostics[i].message .. string.format(" [%s]", v.code) +      end +    end + +    vim.lsp.diagnostic.save(diagnostics, bufnr, client_id) + +    if not vim.api.nvim_buf_is_loaded(bufnr) then +      return +    end + +    vim.lsp.diagnostic.display(diagnostics, bufnr, client_id, config) +  end +    vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {      border = lvim.lsp.popup_border,    }) | 
