nvim-lua / lsp-status.nvim

Utility functions for getting diagnostic status and progress messages from LSP servers, for use in the Neovim statusline
MIT License
625 stars 41 forks source link

Error using build-in neovim diagnostics #19

Closed ner0-m closed 3 years ago

ner0-m commented 3 years ago

As neovim/neovim#12655 was merged and using neovim with it, I get the following:

Error detected while processing function LspStatus: line 2: buf_diagnostics_count is deprecated. Use 'vim.lsp.diagnostic.get_count'

With my function to update the statusline being:

function! LspStatus() abort
  if luaeval('#vim.lsp.buf_get_clients() > 0')
    return luaeval("require('lsp-status').status()")
  endif
  return ''
endfunction

The error seems to be in lsp-status/diagnostics.lua:11 Changing it to:

result[k] = vim.lsp.diagnostic.get_count(level)

fixes my error.

rockerBOO commented 3 years ago

18 should resolve this

wbthomason commented 3 years ago

Thanks @babariviere for the quick PR! (and @tjdevries for the quick merge)

@ner0-m, does this resolve your problem?

creativenull commented 3 years ago

Hey there! I'm not OP but I am also getting a similar error. That is, after updating the plugin with the included merge #18

Error executing lua ...lsp-status.nvim/lua/lsp-status/diagnostics.lua:12: attempt to index field 'diagnostic' (a nil value)
babariviere commented 3 years ago

@creativenull You need to upgrade to the latest version of nightly neovim 😄

creativenull commented 3 years ago

Oops you're right, I took the easy way out (installed via appimage, 2 days old 😅) and didn't see that it was related to a recently updated nightly.

Let me make a build from source and report back...

jasonrhansen commented 3 years ago

@ner0-m, @rockerBOO

vim.lsp.diagnostic.get_count takes a buffer number before the severity.

Wouldn't it need to be changed to

result[k] = vim.lsp.diagnostic.get_count(0, level)

to get the count for the current buffer?

wbthomason commented 3 years ago

@jasonrhansen: Nice catch; you're correct. Addressed in 9750f45.

ner0-m commented 3 years ago

@wbthomason Thanks I just tried and it seems to work perfectly fine! Then this can be closed :smile: