fwcd/kotlin-language-server

Incorrectly excluded directory

fw623 opened this issue · 1 comments

fw623 commented

A problem I had was that some references remained unresolved by the language server although they were correct.
The problem turned out to be that they were under a target directory, which is excluded by the language server, as seen in the following snippet.

private val excludedPatterns = listOf(".*", "bazel-*", "bin", "build", "node_modules", "target").map { FileSystems.getDefault().getPathMatcher("glob:$it") }

Solution

I think ideally, the language server should do something more sensible than using the hardcoded exclusion rules and allow customization of that behaviour via options.

But for now, a workaround is to symlink the incorrectly excluded directories to a non-excluded name.
E.g. in my case I used ln -s target trgt.

fwcd commented

I agree, the current solution is not optimal and we should either query the build system (ideal) or at least the .gitignore as a heuristic on which files to exclude. Letting the user configure these exclusions manually could be convenient too. There's a todo comment a few lines above that addresses this:

// TODO: Read exclusions from gitignore/settings.json/... instead of
// hardcoding them