-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow user specified exclusion patterns #574
base: main
Are you sure you want to change the base?
Conversation
@fwcd I'm not sure if there are any additional actions I need to take (the labeling github action didn't seem to apply any labels to this PR) but this PR should be ready for your review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, left a few notes below
databaseService.setup(options?.storagePath) | ||
|
||
if(options?.additionalSourceExclusions != null) { | ||
sourceFiles.updateAdditionalExclusions(options.additionalSourceExclusions.toMutableList()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we refactor this to use immutable lists?
Mutable structures make it harder to reason about where updates are happening and passing them around make it easier for things to get out-of-sync, therefore I usually prefer the functional style.
private var exclusions = SourceExclusions( | ||
workspaceRoots, | ||
scriptsConfig, | ||
additionalSourceExclusions | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style nit:
private var exclusions = SourceExclusions( | |
workspaceRoots, | |
scriptsConfig, | |
additionalSourceExclusions | |
) | |
private var exclusions = SourceExclusions( | |
workspaceRoots, | |
scriptsConfig, | |
additionalSourceExclusions | |
) |
val storagePath: Path? | ||
val storagePath: Path?, | ||
// Additional paths to exclude from source files. | ||
val additionalSourceExclusions: List<String>? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about whether we should put this into the initialization options. That makes it a bit more cumbersome on the VSCode side and I think it could be nice (in the future) if these options could be updated while the language server is running, even if we don't fully support "hot" configuration updates yet.
Reads initialization options for additional patterns to exclude from source files.
#560 demonstrated that users need to be able to specify patterns to exclude and that hardcoding it forever probably wasn't sustainable. So this makes it configureable.
It seems to me the initialization options is the most natural place to do this (rather than the settings configuration, for example). Similar to adding workspace roots, the user provided exclusions are provided to
SourceFiles
at initialization time.This probably merits updating the documentation, but since I'd also like to improve the neovim documentation anyway I'll probably do that in another PR (mainly, there's no documentation that you need to have a "kotlin" object under settings, since the configuration parser is tailored to the configuration response that VSCode gives).
For example, in my neovim init.lua I'd write