artemave / workspace-diagnostics.nvim

Populate diagnostics for all projects files, not just the opened ones.
https://artem.rocks/posts/workspace_diagnostics_nvim
MIT License
109 stars 3 forks source link

Error in java projects (jdtls.nvim) #8

Open SebasF1349 opened 1 month ago

SebasF1349 commented 1 month ago

Description

I've been using the plugin for months and it worked great for lua and js/ts, but now I have started working on Java and this error keeps poping the first time I open a Java project:

Error detected while processing LspAttach Autocommands for "*":
Error executing lua callback: vim/shared.lua:0: t: expected table, got nil
stack traceback:
    [C]: in function 'error'
    vim/shared.lua: in function 'validate'
    vim/shared.lua: in function 'tbl_contains'
    ...pace-diagnostics.nvim/lua/workspace-diagnostics/init.lua:113: in function 'populate_workspace_diagnostics'
    /home/sebas/.config/nvim/lua/plugins/lsp-config.lua:290: in function </home/sebas/.config/nvim/lua/plugins/lsp-config.lua:251>
    [C]: in function 'nvim_exec_autocmds'
    /usr/share/nvim/runtime/lua/vim/lsp/client.lua:946: in function '_on_attach'
    /usr/share/nvim/runtime/lua/vim/lsp/client.lua:615: in function ''
    vim/_editor.lua: in function <vim/_editor.lua:0>

I'm using nvim-jdtls for the lsp stuff. I can of course disable the plugin for Java, as workspace diagnostics work by default, but I guess it would be better if it wasn't needed. Or it's expected by the user to select on which lsp to load the plugin?

Steps to reproduce

  1. Create any Maven or Gradle project. No need to add code.
  2. Open a java file in the project
  3. Error (only the first time in the first file I open)

Expected behavior

Not having an error and just don't do anything, as it is not needed in this case.

Environment

artemave commented 1 month ago

This code assumes that lsp client.config.filetypes exists, but that's evidently not the case with jdtls. Could you run :lua= vim.lsp.get_active_client(), and paste here the output that corresponds to the client named jdtls?

SebasF1349 commented 1 month ago

You are right, it doesn't set a filetype as it's executed on filetype event so no needed (filetypes = { 'java' }, on lazy). I have to go now, but can try to post the client data later. Right now it's too large for a message and it gets cut off.