enhance: undeprecate nvim_lsp and completely remove `nvim` diagnostics source 😉
- Now `nvim_lsp` source shows diagnostics generated by vim.lsp only avoids uses vim.diagnostic to avoid deprecation warning on nvim 0.6+ Why? `vim.lsp.diagnostic` deprecation warnings are way too aggressive. And I'm annoyed by people complaining here even though the warning is generated by some other plugin (After introduction of nvim_diagnostic source lualine just can't produce that warning it used to switch users to nvim_diagnostic source with a warning on nvim0.6+). Forget it just let anyone that wants lsp specific diagnostics have `nvim_lsp` . I'd still recommend using `nvim_diagnostic` over `nvim_lsp` as diagnostics generayed by plugins like `null-ls` won't showup in `nvim_lsp` - Remove remanents of `nvim` diagnostics source.
This commit is contained in:
parent
750a94baef
commit
70691ae350
|
@ -95,3 +95,5 @@ These were hard to understand before. Now the name should convey more info.
|
|||
- luae -> lua_expr
|
||||
- vimf -> vim_fun
|
||||
|
||||
### 'nvim' diagnostic soirce has been renamed to 'nvim_diagnostic'
|
||||
What the title says ☝️
|
||||
|
|
|
@ -53,51 +53,16 @@ function M:init(options)
|
|||
}
|
||||
end
|
||||
|
||||
-- Error out no source
|
||||
if #self.options.sources < 1 then
|
||||
print('no sources for diagnostics configured')
|
||||
return ''
|
||||
end
|
||||
if vim.fn.has('nvim-0.6') == 1 then
|
||||
for i, name in ipairs(self.options.sources) do
|
||||
if name == 'nvim_lsp' then
|
||||
self.options.sources[i] = 'nvim_diagnostic'
|
||||
modules.utils_notices.add_notice([[
|
||||
### diagnostics.source
|
||||
Diagnostics source `nvim_lsp` has been deprecated in favour of `nvim_diagnostic`.
|
||||
nvim_diagnostic shows diagnostics from neovim's diagnostics api
|
||||
while nvim_lsp used to only show lsp diagnostics.
|
||||
|
||||
You've something like this your config.
|
||||
```lua
|
||||
{'diagnostics', sources = {'nvim_lsp'}}
|
||||
```
|
||||
It needs to be updated to:
|
||||
```lua
|
||||
{'diagnostics', sources = {'nvim_diagnostic'}}
|
||||
```
|
||||
]])
|
||||
elseif name == 'nvim' then
|
||||
self.options.sources[i] = 'nvim_diagnostic'
|
||||
modules.utils_notices.add_notice([[
|
||||
### diagnostics.source
|
||||
Diagnostics source `nvim` has been renamed to `nvim_diagnostic`
|
||||
|
||||
You've something like this your config.
|
||||
```lua
|
||||
{'diagnostics', sources = {'nvim'}}
|
||||
```
|
||||
It needs to be updated to:
|
||||
```lua
|
||||
{'diagnostics', sources = {'nvim_diagnostic'}}
|
||||
```
|
||||
]])
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Initialize variable to store last update so we can use it in insert
|
||||
-- mode for no update_in_insert
|
||||
self.last_diagnostics_count = {}
|
||||
|
||||
-- Error out no source
|
||||
if #self.options.sources < 1 then
|
||||
modules.utils_notices.add_notice(
|
||||
'### diagnostics.sources\n\nno sources for diagnostics configured.\nPlease specify which diagnostics source you want lualine to use with `sources` option.\n'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
function M:update_status()
|
||||
|
|
|
@ -5,10 +5,29 @@ local M = {}
|
|||
--- info_count:number, hint_count:number
|
||||
M.sources = {
|
||||
nvim_lsp = function()
|
||||
local error_count = vim.lsp.diagnostic.get_count(0, 'Error')
|
||||
local warning_count = vim.lsp.diagnostic.get_count(0, 'Warning')
|
||||
local info_count = vim.lsp.diagnostic.get_count(0, 'Information')
|
||||
local hint_count = vim.lsp.diagnostic.get_count(0, 'Hint')
|
||||
local error_count, warning_count, info_count, hint_count
|
||||
if vim.fn.has('nvim-0.6') == 1 then
|
||||
-- On nvim 0.6+ use vim.diagnostic to get lsp generated diagnostic count.
|
||||
local diagnostics = vim.diagnostic.get(0)
|
||||
local count = { 0, 0, 0, 0 }
|
||||
for _, diagnostic in ipairs(diagnostics) do
|
||||
if vim.startswith(vim.diagnostic.get_namespace(diagnostic.namespace).name, 'vim.lsp') then
|
||||
count[diagnostic.severity] = count[diagnostic.severity] + 1
|
||||
end
|
||||
end
|
||||
error_count = count[vim.diagnostic.severity.ERROR]
|
||||
warning_count = count[vim.diagnostic.severity.WARN]
|
||||
info_count = count[vim.diagnostic.severity.INFO]
|
||||
hint_count = count[vim.diagnostic.severity.HINT]
|
||||
else
|
||||
-- On 0.5 use older vim.lsp.diagnostic module.
|
||||
-- Maybe we should phase out support for 0.5 though I haven't yet found a solid reason to.
|
||||
-- Eventually this will be removed when 0.5 is no longer supported.
|
||||
error_count = vim.lsp.diagnostic.get_count(0, 'Error')
|
||||
warning_count = vim.lsp.diagnostic.get_count(0, 'Warning')
|
||||
info_count = vim.lsp.diagnostic.get_count(0, 'Information')
|
||||
hint_count = vim.lsp.diagnostic.get_count(0, 'Hint')
|
||||
end
|
||||
return error_count, warning_count, info_count, hint_count
|
||||
end,
|
||||
nvim_diagnostic = function()
|
||||
|
|
Loading…
Reference in New Issue