about summary refs log tree commit diff
path: root/fnl/nvrc/ui/modules/diagnostics.fnl
blob: a1e253026ad3a4ab1f52bfe1e9f72f2013b19cb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
(fn diagnostics []
  (let [count {}
        levels {:errors :Error :warnings :Warn :info :Info :hints :Hint}]
    (each [k level (pairs levels)]
      (tset count k (vim.tbl_count (vim.diagnostic.get 0 {:severity level}))))
    (var errors "")
    (var warnings "")
    (var hints "")
    (var info "")
    (when (not= (. count :errors) 0)
      (set errors (.. "%#DiagnosticSignError#E" (. count :errors))))
    (when (not= (. count :warnings) 0)
      (set warnings
           (.. " %#DiagnosticSignWarning#W" (. count :warnings))))
    (when (not= (. count :hints) 0)
      (set hints (.. " %#DiagnosticSignHint#H" (. count :hints))))
    (when (not= (. count :info) 0)
      (set info (.. " %#DiagnosticSignInformation#I" (. count :info))))
    (.. errors warnings hints info "%#StatusLine#")))

{: diagnostics}