blob: dd5699df4f4574b4b2de0c9dd708074c2cb9b882 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
(import-macros {: vlua} :nvrc.macro.toolkit)
(import-macros {: setl!} :nvrc.macro.set)
(import-macros {: ag!
: au!} :nvrc.macro.event)
(fn focus_hl [group focused?]
(string.format "%%#%s#" (if focused? group (.. group "NC"))))
(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
(.. "%#DiagnosticSignWarn#W" (. count :warnings) " ")))
(when (not= (. count :info) 0)
(set info (.. "%#DiagnosticSignInformation#I" (. count :info) " ")))
(when (not= (. count :hints) 0)
(set hints (.. "%#DiagnosticSignHint#H" (. count :hints))))
(.. errors warnings info hints "%#StatusLine#")))
(global statusline {})
(set statusline.enable (fn [focused?]
(let [hi (fn [group] (focus_hl group focused?))]
(table.concat [(hi "StatusLinePad")
"▊ "
(hi "StatusLine")
(hi "StatusLineAccentBold")
"%<%f%m%r "
(hi "StatusLine")
"%l:%c | "
(diagnostics)
"%="
(hi "StatusLineAccentBold")
"%y "]))))
(ag! ui-statusline
(au! [WinEnter BufEnter] * #(setl! statusline (.. "%!" (vlua statusline.enable "v:true"))))
(au! [WinLeave BufLeave] * #(setl! statusline (.. "%!" (vlua statusline.enable "v:false")))))
|