Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stevenrchun
Copy link

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

vim.lsp.start({
	name = "kotlin-language-server",
	cmd = {
		...
	},
	filetypes = ....
	root_dir = ...
	init_options = {
		storagePath = ....,
		additionalSourceExclusions = { "new", "source", "exclusions*" },
	},
	settings = {
		kotlin = {
			scripts = {
				...
			},
			completion = {
				...
			},
		},
	},
})

@stevenrchun
Copy link
Author

@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.

Copy link
Owner

@fwcd fwcd left a 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())
Copy link
Owner

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.

Comment on lines +73 to +77
private var exclusions = SourceExclusions(
workspaceRoots,
scriptsConfig,
additionalSourceExclusions
)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nit:

Suggested change
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>?
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants