From 0a002a8b80471a1c8a8caff658c5c279b491bcfa Mon Sep 17 00:00:00 2001 From: Olivier Roques Date: Fri, 10 Dec 2021 20:27:30 +0100 Subject: [PATCH] Use new diagnostic API Fix #29 --- README.md | 5 ++--- lua/hardline/parts/lsp.lua | 13 +++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 18d8157..e582d36 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,8 @@ A statusline / bufferline for Neovim written in Lua. It is inspired by [vim-airline](https://github.com/vim-airline/vim-airline) but aims to be as light and simple as possible. -_**Note**: this plugin is mainly for my own use. I won't add new -features/parts/themes if I don't need them. Feel free to submit PRs or fork the -plugin though._ +_**Note**: I won't add new features/parts/themes if I don't need them. Feel free +to submit PRs or fork the plugin though._ ![screenshot](./screenshot.png) diff --git a/lua/hardline/parts/lsp.lua b/lua/hardline/parts/lsp.lua index 923f163..3bd5636 100644 --- a/lua/hardline/parts/lsp.lua +++ b/lua/hardline/parts/lsp.lua @@ -1,8 +1,17 @@ -local lsp = vim.lsp +local diagnostic, fn, lsp = vim.diagnostic, vim.fn, vim.lsp local fmt = string.format local function get_diagnostic(prefix, severity) - local count = lsp.diagnostic.get_count(0, severity) + local count + if fn.has('nvim-0.6') == 0 then + count = lsp.diagnostic.get_count(0, severity) + else + local severities = { + ['Warning'] = diagnostic.severity.WARNING, + ['Error'] = diagnostic.severity.ERROR, + } + count = #diagnostic.get(0, {severity=severities[severity]}) + end if count < 1 then return '' end