JohnnyMorganz / luau-lsp

Language Server Implementation for Luau
MIT License
242 stars 58 forks source link

Ignore globs often or always have no effect on diagnosis #462

Open colbert2677 opened 1 year ago

colbert2677 commented 1 year ago

Picture of the root hierarchy:

image

I wish to ignore node_modules and private, however at present no globs work for them.

At the time of posting, the following have been tried with no success:

I feel it may be worth noting that removing Wally's default glob match, **/_Index/**, similarly does not affect diagnosis (that is, the modules are not picked up during workspace diagnosis), as though luau-lsp.ignoreGlobs is frozen in time.

At the time of posting, I carry the following modified settings excluding ignoreGlobs:

JohnnyMorganz commented 1 year ago

I cannot reproduce the behaviour where removing **/_Index/** does not affect diagnostics - if I remove this glob locally I do start getting diagnostics for this folder. Similarly using the glob node_modules/** works for me in the above scenario.

We still need to write better tests/logic for this though

colbert2677 commented 1 year ago

Mm, yeah. I myself don't particularly know what causes this or if I need to refresh anything in my environment but occasionally the globs don't work and then in other cases they behave exactly as I would expect. "Often or always" is probably a bit inaccurate. Sometimes even I myself can't reproduce the issue in my repositories, and at other times it flares up. Not quite sure on this one.

Thank you for looking into it though!

colbert2677 commented 1 year ago

I think I may have figured out what triggers this for me: workspace settings. I noticed that I have luau-lsp.ignoreGlobs configured in both my user and workspace settings. What's probably happening here is that my workspace settings are taking precedence so the user globs are ignored completely rather than merged.

After removing all LSP settings from my workspace settings, I saw immediate results with my user settings taking effect and properly skipping diagnosis on my ignored globs. Likely then what happened here is that instead of merging the settings together, it will only read the ignore globs from the configuration with the highest precedence.

Weird how I chanced across that at random - I removed my workspace globs because I didn't need them anymore or wanted to redo them (changed project structure) and then I saw proper results.

Thought about closing this issue with this comment but I'll leave it open in case it's still genuinely an issue. Now that I know the root cause, I'm not sure whether this would qualify as a bug or a feature request - I do know that other extensions do merge arrays when configured in both workspace and user (e.g. PKief.material-icon-theme).

jeparlefrancais commented 4 months ago

If that can help, if found this today:

Running this will ignore on my windows machine, but fail on CI (using a linux image)

luau-lsp analyze --base-luaurc=.luaurc --settings=.luau-analyze.json --ignore '**/node_modules/**'

I can work around this by running with both --ignore '**/node_modules/**' --ignore 'node_modules/**', which will work both locally and inside my github workflows:

luau-lsp analyze --base-luaurc=.luaurc --settings=.luau-analyze.json --ignore '**/node_modules/**' --ignore 'node_modules/**'
nightcycle commented 1 month ago

Wanted to bump this - the ignore parameter is practically unusable due to all these strange edge cases. It's gotten to the point where I'm having situations where I'm unable to ignore specific files despite using their exact paths.

What's strange is the inconsistency - like this works:

--ignore="**/src/Server/Lunatic.luau",

this does not:

--ignore="**/src/Server/Simulate.luau"

View of the layout of the files. image

Simulate is also special in the sense that nothing depends on it - in order for the type to be accessed it needs to be analyzed directly.

It's not the only script doing this, but it's the most clearly "I can't possibly be doing it wrong" example due to Lunatic.luau being ignored fine, so I thought it would be best to lead with it to avoid wasting anyone's time on the off chance I'm making a mistake somewhere else.

Anyways, let me know if there's anything I can do to help narrow it down. Thank you!