(import-macros {: vlua} :nvrc.macro.toolkit) (import-macros {: setl!} :nvrc.macro.set) (import-macros {: ag! : au!} :nvrc.macro.event) (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 [] (table.concat ["%#StatusLinePad#" "▊ " "%#StatusLine#" "%#StatusLineAccentBold#" "%<%f%m%r " "%#StatusLine#" "%l:%c | " (diagnostics) "%=" "%#StatusLineAccentBold#" "%y "]))) (ag! ui-statusline (au! [WinEnter BufEnter] * #(setl! statusline (.. "%!" (vlua statusline.enable)))) (au! [WinLeave BufLeave] * #(setl! statusline " ")))