LuaLS / lua-language-server

A language server that offers Lua language support - programmed in Lua
https://luals.github.io
MIT License
3.33k stars 316 forks source link

Ignoring dir doesn't work when checking diagnostics #2548

Open wojciech-kulik opened 8 months ago

wojciech-kulik commented 8 months ago

How are you using the lua-language-server?

NeoVim

Which OS are you using?

MacOS

What is the issue affecting?

Diagnostics/Syntax Checking

Expected Behaviour

When I set workspace.ignoreDir in .luarc.json it should exclude these folders from check when calling:

lua-language-server --check="some/path" --configpath="some/path/.luarc.json"

Actual Behaviour

The tool still prints errors in 3rd party dir.

Reproduction steps

  1. Create .luarc.json and put:
    {
    "workspace.library": ["${3rd}/luassert/library"],
    "workspace.ignoreDir": ["${3rd}/luassert/library"],
    "diagnostics.globals": ["vim", "require", "describe", "it", "P"],
    "diagnostics.disable": ["different-requires"]
    }
  2. Run:
    lua-language-server --check="${DIR_SRC}" --configpath="${PWD}/.luarc.json" --checklevel=Information --logpath="${DIR_OUT}" --loglevel=error

Additional Notes

No response

Log File

No response

emmericp commented 8 months ago

I believe https://github.com/LuaLS/lua-language-server/pull/2546 probably solves your problem (but ignoreDir not working is still a bug)

wojciech-kulik commented 8 months ago

@emmericp thank you! Any advice on how can I quickly verify it? I see that there is no new release yet and I can't find any information how to build it.

./make.sh

This command requires some dependency:

./make.sh: line 7: ./3rd/luamake/luamake: No such file or directory
emmericp commented 8 months ago

that indicates the previous step failed, it compiles luamake first, so you are missing part of the error. likely dependencies, which are only gcc and ninja-build

but since my patch is lua only you can just apply it to your existing installation

wojciech-kulik commented 7 months ago

but since my patch is lua only you can just apply it to your existing installation

what did you mean by that? I installed LuaLS from Homebrew, so I've got only the binary file. I'm not sure how could I apply it?

wojciech-kulik commented 7 months ago

I think I solved the problem by setting in .luarc.json:

{
  "workspace.library": ["${3rd}/luassert/library"],
  "workspace.checkThirdParty": false,
  "diagnostics.libraryFiles": "Disable",
}

Specifically:

"diagnostics.libraryFiles": "Disable",
TOMO-CAT commented 2 days ago

workspace.library

Excuse me, I tried your method but it didn't work.

I want to disable Lua diagnostics for the whole folder ./xmake/templatesimage

here is my .luarc.json:

"workspace.library": [
        "xmake/templates"
    ],
"diagnostics.libraryFiles": "Disable"

For now, I can only disable the diagnosis of the entire project to workaround:

"diagnostics.disable": [
        "unknown-symbol",
        "exp-in-action"
    ]

thankyou so much!

tomlau10 commented 2 days ago

Hi @TOMO-CAT, there seems to be some problems related to workspace.library and "diagnostics.libraryFiles": "Disable" when the library path is relative to the workspace root, as discussed here: https://github.com/LuaLS/lua-language-server/issues/2905

Unfortunately the cause of this issue is not identified yet 😕