From a2721e5adabaa9535768bde7155c6f1dfac59418 Mon Sep 17 00:00:00 2001 From: Yusei Ueno Date: Mon, 29 Mar 2021 23:53:19 +0900 Subject: [PATCH] feat: add diagnostic sources option vim_lsp (#151) --- README.md | 2 +- doc/lualine.txt | 2 +- lua/lualine/components/diagnostics.lua | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 78cb648..e500578 100644 --- a/README.md +++ b/README.md @@ -219,7 +219,7 @@ In addition, some components have unique options. Option | Default | Behaviour | Format :------: | :------: | :----: | :---: -sources | `nil` | displays diagnostic count from defined source | array containing one or many string from set `{'nvim_lsp', 'coc', 'ale'}` +sources | `nil` | displays diagnostic count from defined source | array containing one or many string from set `{'nvim_lsp', 'coc', 'ale', 'vim_lsp'}` sections | `{'error', 'warn', 'info'}` | displays diagnostics of defined severity | array containing one or many string from set `{'error', 'warn', 'info'}` color_error | `DiffDelete` foreground color | changes diagnostic's error section foreground color | color in `#rrggbb` format color_warn | `DiffText` foreground color | changes diagnostic's warn section foreground color | color in `#rrggbb` format diff --git a/doc/lualine.txt b/doc/lualine.txt index a943112..5bfeaa8 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -277,7 +277,7 @@ List of options are given below. • sources (nil) displays diagnostic count from defined source. array containing one or many string from set - {'nvim_lsp', 'coc', 'ale'} + {'nvim_lsp', 'coc', 'ale', 'vim_lsp'} • sections ({'error', 'warn', 'info'}) displays diagnostics of defined severity. diff --git a/lua/lualine/components/diagnostics.lua b/lua/lualine/components/diagnostics.lua index de095b1..372bfe3 100644 --- a/lua/lualine/components/diagnostics.lua +++ b/lua/lualine/components/diagnostics.lua @@ -32,6 +32,14 @@ local diagnostic_sources = { else return 0, 0, 0 end + end, + vim_lsp = function() + local ok, data = pcall(vim.fn['lsp#get_buffer_diagnostics_counts']) + if ok then + return data.error, data.warning, data.information + else + return 0, 0, 0 + end end }