lsp-zero.nvim icon indicating copy to clipboard operation
lsp-zero.nvim copied to clipboard

Strange "Error executing vim.schedule lua callback' issue, resolved when lsp-zero is uninstalled

Open ablechow29 opened this issue 1 year ago • 2 comments

This error specifically occurs when I open an R script file. It does not happen when I edit .lua files in .config/nvim or any .tex files. Unfortunately I do not have other programming language files to test.

I have no idea why this happens. I found some posts saying this is an error due to nvim-treesitter, but when I disable the plugin the problem persists.

When I uninstall the auto-completion packages

{'hrsh7th/nvim-cmp'}, 
{'hrsh7th/cmp-nvim-lsp'}, 
{'L3MON4D3/LuaSnip'}, 

The exact same problem persists.

When the mason packages are disabled, the lsp gets disabled all together and the problem goes away.

Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/diagnostic.lua:406: attempt to compare string with number
stack traceback:
        /usr/share/nvim/runtime/lua/vim/diagnostic.lua:406: in function 'add'
        /usr/share/nvim/runtime/lua/vim/diagnostic.lua:422: in function 'add_all_diags'
        /usr/share/nvim/runtime/lua/vim/diagnostic.lua:443: in function 'get_diagnostics'
        /usr/share/nvim/runtime/lua/vim/diagnostic.lua:1191: in function 'show'
        /usr/share/nvim/runtime/lua/vim/diagnostic.lua:703: in function 'set'
        /usr/share/nvim/runtime/lua/vim/lsp/diagnostic.lua:236: in function 'handler'
        /usr/share/nvim/runtime/lua/vim/lsp.lua:1057: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>
Press ENTER or type command to continue

ablechow29 avatar Aug 14 '23 06:08 ablechow29

Update,

When all LSPs were uninstalled, I no longer see the error message when I open r script files in NVim. However, once r language server protocol was reinstalled via mason, the problem shows itself again.

ablechow29 avatar Aug 14 '23 07:08 ablechow29

Here's the block of code specified by /usr/share/nvim/runtime/lua/vim/diagnostic.lua:406: in function 'add' starting from 395--417

  ---@private
  local function add(b, d)
    if not opts.lnum or d.lnum == opts.lnum then
      if clamp and api.nvim_buf_is_loaded(b) then
        local line_count = buf_line_count[b] - 1
        if
          d.lnum > line_count
          or d.end_lnum > line_count
          or d.lnum < 0
          or d.end_lnum < 0
          or d.col < 0
          or d.end_col < 0
        then
          d = vim.deepcopy(d)
          d.lnum = math.max(math.min(d.lnum, line_count), 0)
          d.end_lnum = math.max(math.min(d.end_lnum, line_count), 0)
          d.col = math.max(d.col, 0)
          d.end_col = math.max(d.end_col, 0)
        end
      end
      table.insert(diagnostics, d)
    end
  end


ablechow29 avatar Aug 14 '23 08:08 ablechow29