Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error using build-in neovim diagnostics #19

Closed
ner0-m opened this issue Nov 13, 2020 · 8 comments
Closed

Error using build-in neovim diagnostics #19

ner0-m opened this issue Nov 13, 2020 · 8 comments

Comments

@ner0-m
Copy link

ner0-m commented Nov 13, 2020

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
Copy link

#18 should resolve this

@wbthomason
Copy link
Collaborator

wbthomason commented Nov 13, 2020

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

@ner0-m, does this resolve your problem?

@creativenull
Copy link

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
Copy link
Contributor

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

@wbthomason wbthomason pinned this issue Nov 13, 2020
@creativenull
Copy link

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
Copy link

@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
Copy link
Collaborator

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

@ner0-m
Copy link
Author

ner0-m commented Nov 14, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants